Skip to content

Commit fe41f4a

Browse files
Merge branch 'master' into mitryakh/08-01
2 parents 8f79933 + 0e1c9ba commit fe41f4a

File tree

1,115 files changed

+836670
-93676
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,115 files changed

+836670
-93676
lines changed
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: Autogenerate (Batch 0)
4+
5+
on:
6+
push:
7+
branches: [ autogenerate ]
8+
9+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
10+
jobs:
11+
# This workflow contains a single job called "build"
12+
build:
13+
# The type of runner that the job will run on
14+
runs-on: ubuntu-latest
15+
16+
# Steps represent a sequence of tasks that will be executed as part of the job
17+
steps:
18+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
19+
- uses: actions/checkout@v2
20+
21+
- name: Configure Git
22+
run: |
23+
git config user.name "Autogenerator Pipeline"
24+
git config user.email "azure-resource-manager-schemas@noreply.github.com"
25+
26+
- name: Integrate main branch
27+
run: |
28+
git checkout autogenerate
29+
git pull
30+
git merge --no-commit --no-ff --strategy-option=theirs origin/master --allow-unrelated-histories
31+
if ! git diff-index --quiet HEAD --; then
32+
git commit -m "Merge remote-tracking branch 'origin/master' into autogenerate"
33+
git push origin autogenerate
34+
fi
35+
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v2.1.2
38+
with:
39+
node-version: 10.x
40+
41+
- name: Install packages
42+
run: npm install
43+
working-directory: ./generator
44+
45+
- name: Generate Schemas
46+
run: |
47+
npm run generate-all '{"batchCount": 4, "batchIndex": 0}'
48+
working-directory: ./generator
49+
50+
- name: Commit autogenerated schemas
51+
run: |
52+
git add --all schemas
53+
if ! git diff-index --quiet HEAD --; then
54+
git commit -m "Autogenerate schemas"
55+
git push origin autogenerate
56+
fi
57+
58+
- name: List resources
59+
run: |
60+
npm run list-resources resources.json
61+
62+
- name: Commit resource list
63+
run: |
64+
git add generator/resources.json
65+
if ! git diff-index --quiet HEAD --; then
66+
git commit -m "Update resource list"
67+
git push origin autogenerate
68+
fi

.github/workflows/main.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
branches: [ master ]
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
- uses: actions/checkout@v2
12+
13+
- name: Setup Node.js
14+
uses: actions/setup-node@v2.1.2
15+
with:
16+
node-version: 10.x
17+
18+
- name: GitHub context (actor and head ref)
19+
run: |
20+
echo ${{ github.actor }}
21+
echo ${{ github.head_ref }}
22+
23+
- name: Install NPM modules
24+
run: npm ci
25+
working-directory: ./tools
26+
27+
- name: Run CI tests
28+
run: npm test
29+
working-directory: ./tools
30+
31+
automerge:
32+
runs-on: ubuntu-latest
33+
needs: build
34+
env:
35+
PR_PREFIX: sdkAuto/
36+
if: ${{ github.event.pull_request.user.login == 'openapi-sdkautomation[bot]' }}
37+
steps:
38+
- uses: actions/checkout@v2
39+
40+
- name: Setup Node.js
41+
uses: actions/setup-node@v2.1.2
42+
with:
43+
node-version: 10.x
44+
45+
- name: Install NPM modules
46+
run: npm ci
47+
working-directory: ./generator
48+
49+
- name: Check RP in Autogenlist
50+
run: |
51+
check_result='';
52+
exec=$(npm run find-basepath ${{ github.head_ref }} $PR_PREFIX);
53+
while read line;
54+
do
55+
# overriding check_result until the last line is read, last line contains
56+
# the result to whether or not the basepath was found in autogenlist.
57+
check_result=$line;
58+
echo $check_result;
59+
done <<< "$exec";
60+
61+
if [ $check_result == 'false' ] ; then
62+
exit 1
63+
fi
64+
working-directory: ./generator

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
.vs
2-
.vscode
32
js-coverage
4-
node_modules
3+
npm-debug.log
4+
node_modules
5+
.DS_Store
6+
test-results.xml
7+
schemas/code-model-v1

.vscode/launch.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"type": "node",
6+
"request": "launch",
7+
"name": "List basepaths",
8+
"runtimeArgs": ["-r", "ts-node/register"],
9+
"cwd": "${workspaceFolder}/generator",
10+
"args": ["${workspaceFolder}/generator/cmd/listbasepaths.ts"]
11+
},
12+
{
13+
"type": "node",
14+
"request": "launch",
15+
"name": "List resources",
16+
"runtimeArgs": ["-r", "ts-node/register"],
17+
"cwd": "${workspaceFolder}/generator",
18+
"args": ["${workspaceFolder}/generator/cmd/listresources.ts"]
19+
},
20+
{
21+
"type": "node",
22+
"request": "launch",
23+
"name": "Generate single",
24+
"runtimeArgs": ["-r", "ts-node/register"],
25+
"cwd": "${workspaceFolder}/generator",
26+
"args": [
27+
"${workspaceFolder}/generator/cmd/generatesingle.ts",
28+
"${input:resourceProvider}/resource-manager"
29+
]
30+
},
31+
{
32+
"type": "node",
33+
"request": "launch",
34+
"name": "Generate all",
35+
"runtimeArgs": ["-r", "ts-node/register"],
36+
"cwd": "${workspaceFolder}/generator",
37+
"args": ["${workspaceFolder}/generator/cmd/generateall.ts"]
38+
}
39+
],
40+
"inputs": [
41+
{
42+
"id": "resourceProvider",
43+
"type": "promptString",
44+
"default": "alertsmanagement",
45+
"description": "The ResourceProvider name, e.g., compute, network"
46+
}
47+
]
48+
}

CredScanSuppressions.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"tool": "Credential Scanner",
3+
"suppressions": [
4+
{
5+
"hash": "/d5snlRGcdND41zmqGMEShzulA381IT1cTRpPVIzMi0=",
6+
"_justification": "Secret used as a sample in test library"
7+
},
8+
{
9+
"hash": "Dbm7cwbNwfW2wfoczuNvILGE4JN6/Qyd7R0PC0LFY0Q=",
10+
"_justification": "Secret used as a sample in test library"
11+
},
12+
{
13+
"hash": "DqnzqSuPoql8CRa0NwVQjvMWVEdB/1JVZhMLf5a7caw=",
14+
"_justification": "Secret used as a sample in test library"
15+
},
16+
{
17+
"hash": "JiUVlQAt6apvitt6Uy0wYdalRKzj85fDWT8qFpFgpoY=",
18+
"_justification": "Secret used as a sample in test library"
19+
},
20+
{
21+
"hash": "LJ2GmegghFcVzhg0rCOmNVxBzYbBxEsP1MrhtJ6hiT8=",
22+
"_justification": "Secret used as a sample in test library"
23+
},
24+
{
25+
"hash": "aFrn+1gsLqL40HnUNj5Rl+ZYnxDXify72bGdAf3Xexk=",
26+
"_justification": "Secret used as a sample in test library"
27+
},
28+
{
29+
"hash": "nmsaWxY/4tYovFLEYR36oWY7xh6lInTNbrh+YvIWT+g=",
30+
"_justification": "Secret used as a sample in test library"
31+
}
32+
]
33+
}

README.md

Lines changed: 77 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,81 @@
11
# azure-resource-manager-schemas
22

3-
This is the repo for template deployment schemas hosted at https://schema.management.azure.com/.
4-
5-
Welcome to contribute to template deployment schemas, please send pull request to improve the schemas. We will review the pull request and publish the latest schemas to https://schema.management.azure.com/schemas
6-
7-
## Hints:
8-
* When you add a new resource type in schema, please add it into [schemas\2014-04-01-preview\deploymentTemplate.json](schemas/2014-04-01-preview/deploymentTemplate.json), [schemas\2015-01-01\deploymentTemplate.json](schemas/2015-01-01/deploymentTemplate.json) and [schemas\2019-04-01\deploymentTemplate.json](schemas/2019-04-01/deploymentTemplate.json).
9-
* Please add or update [tests](tests/) for your change.
10-
* Please test your change with following two node.js scripts:
11-
1. [tools\validateJSON.js](tools/validateJSON.js) and [ResourceMetaSchema.json](tools/ResourceMetaSchema.json):
12-
The script uses the ResourceMetaSchema.json to do some basic checks against the new/updated schema file.
13-
**Usage:**
14-
Node validateJSON.js \<schema file path\> ResourceMetaSchema.json \<schema folder path\>
15-
**Sample:**
16-
Node validateJSON.js ..\schemas\2015-08-01\Microsoft.Compute.json ResourceMetaSchema.json ..\schemas\
17-
2. [tools\runSchemaTests.js](tools/runSchemaTests.js)
18-
The script uses all test JSON files under [tests](tests/) folder to test against the schema files.
19-
**Usage:**
20-
Node runSchemaTests.js [--dir _folder_] [--AssertSubErrors]
21-
&nbsp;&nbsp;&nbsp;&nbsp;***To run tests in single folder:***
22-
&nbsp;&nbsp;&nbsp;&nbsp;Node runSchemaTests.js --dir ..\tests\2018-08-01
23-
&nbsp;&nbsp;&nbsp;&nbsp;***To run tests in single folder and assert subErrors:***
24-
&nbsp;&nbsp;&nbsp;&nbsp;Node runSchemaTests.js --dir ..\tests\2018-08-01 --AssertSubErrors
3+
This is the repo for template deployment schemas hosted under `https://schema.management.azure.com/schemas`. Please see below for information on contributing and publishing updated schemas.
4+
5+
## Updating Schemas
6+
There are two processes for updating schemas:
7+
1. **Daily autogeneration**: Schemas are automatically generated from definitions in the [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) repo. This requires [onboarding](/generator/README.md#onboarding-teams-to-autogeneration-pipeline) on a per-provider basis.
8+
2. **Manually**: Schemas are manually authored and committed via PR.
9+
10+
### Has my team been onboarded for daily autogeneration?
11+
Please see [generator/autogenlist.ts](/generator/autogenlist.ts) for the list of teams which have been onboarded. `basePath` refers to the path in the [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) repo, and `namespace` is the Resource Provider namespace.
12+
13+
**If your team has been onboarded, we do not require any manual contributions to this repo and your schemas will automatically be kept up to date by the pipeline.**
14+
15+
## Authoring Schemas and submitting a PR
16+
**Please ensure you have read [Updating Schemas](#updating-schemas) before continuing with this step, and only continue if this applies to your team.**
17+
18+
### Authoring
19+
You can use the generator in this repo to automatically generate a schema from a swagger spec checked into the [azure-rest-api-specs](https://github.com/Azure/azure-rest-api-specs) repo.
20+
21+
#### Generating locally
22+
1. Fork this repo, and clone it locally.
23+
2. Run the following commands (replace the base path accordingly - valid paths can be disovered with `npm run list-basepaths`):
24+
```bash
25+
cd generator
26+
npm install
27+
npm run generate-single myprovider/resource-manager
28+
```
29+
4. Review the generator logs to ensure no errors, and review the changes generated.
30+
5. Ensure that you have reviewed the guidelines under [Submitting a PR](#submitting-a-pr).
31+
6. Generate a commit and push it to your fork.
32+
7. Submit a pull request to this repo. Please include the full command output in a PR comment.
33+
34+
Alternatively, you can hand-author your schema, but **please note** that this process is error-prone, and ARM will not be responsible for reviewing for accuracy when validating your PR.
35+
36+
### Submitting a PR
37+
* Ensure that any $refs to resource types that you are adding has been added to the following top-level template schema: [schemas/2019-04-01/deploymentTemplate.json](/schemas/2019-04-01/deploymentTemplate.json)
38+
* If your schema has been manually generated, please ensure you include appropriate tests in [tests](/tests/)
39+
* If adding a new resource type, please add examples to the templates in [tools/templateTests](/tools/templateTests/)
40+
* Ensure that the test suite passes (see [Tests](#tests))
41+
42+
> **NOTE**: We will no longer be taking any updates to the [2015-01-01](/schemas/2015-01-01/deploymentTemplate.json) or [2014-04-01-preview](/schemas/2014-04-01-preview/deploymentTemplate.json) root schemas. If you are authoring a template which references one of these schemas, please upgrade it to use the [2019-04-01](/schemas/2019-04-01/deploymentTemplate.json) root schema by setting the `$schema` property to `https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#"`.
43+
44+
### Runing Unit Tests
45+
Use the following commands to execute the test suite locally:
46+
```bash
47+
cd tools
48+
npm install
49+
npm test
50+
```
51+
52+
## Manual testing with a local schema server
53+
This repo contains a command to run a schema web server which will host files directly from your local repo. This can be useful if you want to validate schemas against a particular tool - for example if you want to verify VSCode autocompletion and syntax highlighting. By default this will listen on port 3000, but this can be modified by editing [tools/server.ts](/tools/server.ts).
54+
To start an instance you can use the following commands:
55+
```bash
56+
cd tools
57+
npm install
58+
npm run serve
59+
```
60+
61+
Once this is running, you can create a basic template with the following structure (replacing the sections between `<` and `>` as appropriate for your scenario):
62+
```json
63+
{
64+
"$schema": "http://<hostname>:<port>/schemas/2019-04-01/deploymentTemplate.json",
65+
"resources": [
66+
{
67+
"type": "<providerNamespace>/<resourceType>",
68+
"apiVersion": "<apiVersion>",
69+
"properties": {
70+
}
71+
}
72+
]
73+
}
74+
```
75+
**NOTE** Many client tools will cache responses from schema servers, so you may need to clear this cache if you are testing modifications, or alternatively, change the port between retries.
76+
77+
## RP Schemas Repo Issues Bot Notifications
78+
To get quickly notified on GitHub issues for your RP's schema, please update the [rp-label-to-contact.md](/rp-label-to-contact.md) by submitting a PR with the desired GitHub handle(s) and label for your RP.
2579

2680
---
27-
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
81+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

0 commit comments

Comments
 (0)