Skip to content

Commit 42545ad

Browse files
committed
merge latest
2 parents b518f55 + ab4b25d commit 42545ad

File tree

174 files changed

+183496
-8763
lines changed

Some content is hidden

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

174 files changed

+183496
-8763
lines changed

.sdkauto/generateScript.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
PARAMS=$(cat $1 | jq '{localPath: .specFolder, readmeFiles: .relatedReadmeMdFiles, $outputPath}' -c --arg outputPath $2)
6+
7+
echo $PARAMS
8+
9+
pushd generator
10+
11+
npm run generate-all $PARAMS

.sdkauto/initScript.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
npm install -g npm
6+
7+
pushd generator
8+
9+
npm install
10+
11+
popd

.vscode/launch.json

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,20 @@
3434
"name": "Generate all",
3535
"runtimeArgs": ["-r", "ts-node/register"],
3636
"cwd": "${workspaceFolder}/generator",
37-
"args": ["${workspaceFolder}/generator/cmd/generateall.ts"]
37+
"args": [
38+
"${workspaceFolder}/generator/cmd/generateall.ts"
39+
]
40+
},
41+
{
42+
"type": "node",
43+
"request": "launch",
44+
"name": "Generate all - local",
45+
"runtimeArgs": ["-r", "ts-node/register"],
46+
"cwd": "${workspaceFolder}/generator",
47+
"args": [
48+
"${workspaceFolder}/generator/cmd/generateall.ts",
49+
"{\"localPath\":\"../azure-rest-api-specs\",\"readmeFiles\":[\"specification/signalr/resource-manager/readme.md\",\"specification/appplatform/resource-manager/readme.md\"],\"outputPath\":\"../generateOutput.json\"}"
50+
]
3851
}
3952
],
4053
"inputs": [
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
pr: none
2+
trigger: none
3+
4+
schedules:
5+
- cron: "0 6 * * 5"
6+
branches:
7+
include:
8+
- master
9+
displayName: Weekly report of onboarded RPs
10+
11+
jobs:
12+
- job: Generate
13+
timeoutInMinutes: 180
14+
15+
pool:
16+
vmImage: 'ubuntu-latest'
17+
18+
steps:
19+
- checkout: self
20+
clean: true
21+
22+
- task: DownloadSecureFile@1
23+
name: schemasDeployKey
24+
inputs:
25+
secureFile: schemas_rsa
26+
displayName: "Download GitHub Deploy Key"
27+
28+
- task: NodeTool@0
29+
inputs:
30+
versionSpec: '14.x'
31+
32+
- script: |
33+
set -Eeuxo pipefail
34+
mkdir ~/.ssh && mv $(schemasDeployKey.secureFilePath) ~/.ssh/schemas_rsa
35+
chmod 700 ~/.ssh
36+
chmod 600 ~/.ssh/schemas_rsa
37+
git config user.name "Autogenerator Pipeline"
38+
git config user.email "azure-resource-manager-schemas@noreply.github.com"
39+
git config core.sshCommand "ssh -i ~/.ssh/schemas_rsa -F /dev/null"
40+
git remote set-url origin git@github.com:Azure/azure-resource-manager-schemas.git
41+
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
42+
git fetch
43+
displayName: Configure git
44+
45+
- script: |
46+
set -Eeuxo pipefail
47+
git checkout $(Build.SourceBranchName)
48+
displayName: Checkout repo
49+
50+
- script: |
51+
set -Eeuxo pipefail
52+
cd generator
53+
npm install
54+
displayName: 'Install packages'
55+
56+
- script: |
57+
set -Eeuxo pipefail
58+
cd generator
59+
npm run generate-onboarded-report
60+
displayName: 'Generate report'
61+
62+
- script: |
63+
set -Eeuxo pipefail
64+
git add --all onboarded-report
65+
if ! git diff-index --quiet HEAD --; then
66+
git commit -m "Generated report"
67+
git push origin $(Build.SourceBranchName)
68+
fi
69+
displayName: Commit report

generator/README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,8 @@ View the Pipeline Configuration [here](/azure-pipelines-autogen.yml).
3434
#### Onboarding teams to autogeneration pipeline
3535

3636
1. Run `npm run list-basepaths` to discover the specs repo path containing the swagger definitions.
37-
2. Run `npm run generate-single {basePath}` to generate schemas for them. Save the console output to file.
38-
3. Remove all references to the provider namespace from [schemas/2019-04-01/deploymentTemplate.json](/schemas/2019-04-01/deploymentTemplate.json).
39-
4. If there are any modifications to [schemas/common/autogeneratedResources.json](/schemas/common/autogeneratedResources.json), you may need to make corresponding changes to [schemas/2014-04-01-preview/deploymentTemplate.json](/schemas/2014-04-01-preview/deploymentTemplate.json) and [schemas/2015-01-01/deploymentTemplate.json](/schemas/2015-01-01/deploymentTemplate.json).
40-
5. Add the {basePath} to the autogenlist array in [autogenlist.ts](./autogenlist.ts).
41-
6. Commit all the changed files, and submit a PR to this repo with title "Onboarding {provider} for autogeneration". Include the full output saved in step 2 as a comment.
42-
7. Ensure all CI tests pass, and ask the team to review the PR (including tool output) to ensure that all expected resources have been detected and generated as expected.
37+
1. Run `npm run generate-single {basePath}` to generate schemas for them. Save the console output to file.
38+
1. Remove all references to the provider namespace from [schemas/2019-04-01/deploymentTemplate.json](/schemas/2019-04-01/deploymentTemplate.json).
39+
1. Add the {basePath} to the autogenlist array in [autogenlist.ts](./autogenlist.ts).
40+
1. Commit all the changed files, and submit a PR to this repo with title "Onboarding {provider} for autogeneration". Include the full output saved in step 2 as a comment.
41+
1. Ensure all CI tests pass, and ask the team to review the PR (including tool output) to ensure that all expected resources have been detected and generated as expected.

generator/autogenlist.ts

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import { ScopeType, AutogenlistConfig } from './models';
1+
import { ScopeType, AutoGenConfig } from './models';
2+
import { postProcessor as insightsApplicationPostProcessor } from './processors/Microsoft.Insights.Application';
23
import { postProcessor as resourcesPostProcessor } from './processors/Microsoft.Resources';
34
import { postProcessor as machineLearningPostProcessor } from './processors/Microsoft.MachineLearning';
5+
import { postProcessor as machineLearningServicesPostProcessor } from './processors/Microsoft.MachineLearningServices';
46
import { postProcessor as storageProcessor } from './processors/Microsoft.Storage';
57
import { lowerCaseEquals } from './utils';
68

79
// Run "npm run list-basepaths" to discover all the valid readme files to add to this list
8-
const autogenlist: AutogenlistConfig[] = [
10+
const autoGenList: AutoGenConfig[] = [
911
{
1012
basePath: 'addons/resource-manager',
1113
namespace: 'Microsoft.Addons',
@@ -264,10 +266,10 @@ const autogenlist: AutogenlistConfig[] = [
264266
basePath: 'EnterpriseKnowledgeGraph/resource-manager',
265267
namespace: 'Microsoft.EnterpriseKnowledgeGraph',
266268
},
267-
{
269+
/*{ NOTE(jcotillo): Temporally removing this RP - latest swagger contains an unsupported type by the schema generator tool
268270
basePath: 'domainservices/resource-manager',
269271
namespace: 'Microsoft.AAD',
270-
},
272+
},*/
271273
{
272274
basePath: 'eventhub/resource-manager',
273275
namespace: 'Microsoft.EventHub',
@@ -332,6 +334,11 @@ const autogenlist: AutogenlistConfig[] = [
332334
namespace: 'Microsoft.MachineLearning',
333335
postProcessor: machineLearningPostProcessor,
334336
},
337+
{
338+
basePath: 'machinelearningservices/resource-manager',
339+
namespace: 'Microsoft.MachineLearningServices',
340+
postProcessor: machineLearningServicesPostProcessor,
341+
},
335342
{
336343
basePath: 'machinelearningcompute/resource-manager',
337344
namespace: 'Microsoft.MachineLearningCompute',
@@ -378,10 +385,6 @@ const autogenlist: AutogenlistConfig[] = [
378385
basePath: 'marketplace/resource-manager',
379386
namespace: 'Microsoft.Marketplace',
380387
},
381-
{
382-
basePath: 'machinelearningservices/resource-manager',
383-
namespace: 'Microsoft.MachineLearningServices',
384-
},
385388
{
386389
basePath: 'mysql/resource-manager',
387390
namespace: 'Microsoft.DBforMySQL',
@@ -697,6 +700,23 @@ const autogenlist: AutogenlistConfig[] = [
697700
{
698701
basePath: 'keyvault/resource-manager',
699702
namespace: 'Microsoft.KeyVault',
703+
readmeTag: {
704+
'2016-10-01': [
705+
'Microsoft.KeyVault/stable/2016-10-01/keyvault.json',
706+
'Microsoft.KeyVault/stable/2016-10-01/providers.json',
707+
'Microsoft.KeyVault/stable/2016-10-01/secrets.json',
708+
],
709+
'2018-02-14': [
710+
'Microsoft.KeyVault/stable/2018-02-14/keyvault.json',
711+
'Microsoft.KeyVault/stable/2018-02-14/providers.json',
712+
'Microsoft.KeyVault/stable/2018-02-14/secrets.json',
713+
],
714+
'2018-02-14-preview': [
715+
'Microsoft.KeyVault/preview/2018-02-14-preview/keyvault.json',
716+
'Microsoft.KeyVault/preview/2018-02-14-preview/providers.json',
717+
'Microsoft.KeyVault/preview/2018-02-14-preview/secrets.json',
718+
],
719+
}
700720
},
701721
{
702722
basePath: 'hybridkubernetes/resource-manager',
@@ -732,6 +752,7 @@ const autogenlist: AutogenlistConfig[] = [
732752
basePath: 'applicationinsights/resource-manager',
733753
namespace: 'Microsoft.Insights',
734754
suffix: 'Application',
755+
postProcessor: insightsApplicationPostProcessor,
735756
},
736757
{
737758
basePath: 'quantum/resource-manager',
@@ -749,10 +770,10 @@ const autogenlist: AutogenlistConfig[] = [
749770
}
750771
];
751772

752-
export function getAutogenlist(): AutogenlistConfig[] {
753-
return autogenlist;
773+
export function getAutoGenList(): AutoGenConfig[] {
774+
return autoGenList;
754775
}
755776

756-
export function findAutogenEntries(basePath: string): AutogenlistConfig[] {
757-
return autogenlist.filter(w => lowerCaseEquals(w.basePath, basePath));
777+
export function findAutogenEntries(basePath: string): AutoGenConfig[] {
778+
return autoGenList.filter(w => lowerCaseEquals(w.basePath, basePath));
758779
}

generator/cmd/findbasepath.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ executeSynchronous(async () => {
1515
// format basePath.
1616
basePath = `${basePath}/resource-manager`;
1717

18-
const autogenEntries = findAutogenEntries(basePath);
18+
const autoGenEntries = findAutogenEntries(basePath);
1919

20-
if (autogenEntries.length === 0) {
20+
if (autoGenEntries.length === 0) {
2121
// not onboarded in autogeneration
2222
console.log("false");
2323
return;

generator/cmd/generateall.ts

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
11
import * as constants from '../constants';
2-
import { cloneAndGenerateBasePaths, validateAndReturnReadmePath } from '../specs';
3-
import { SchemaConfiguration, generateSchemas, clearAutogeneratedSchemaRefs, saveAutogeneratedSchemaRefs } from '../generate';
4-
import { getAutogenlist } from '../autogenlist';
2+
import { cloneAndGenerateBasePaths, getPackageString, resolveAbsolutePath, validateAndReturnReadmePath } from '../specs';
3+
import { SchemaConfiguration, generateSchemas, clearAutoGeneratedSchemaRefs, saveAutoGeneratedSchemaRefs } from '../generate';
4+
import { getAutoGenList } from '../autogenlist';
55
import chalk from 'chalk';
6-
import { flatten, chunk } from 'lodash';
7-
import { executeSynchronous, chunker } from '../utils';
6+
import { flatten } from 'lodash';
7+
import { executeSynchronous, chunker, writeJsonFile } from '../utils';
8+
import { Package } from '../models';
89

910
interface GenerateAllParams {
1011
batchCount?: number,
1112
batchIndex?: number,
13+
localPath?: string,
14+
readmeFiles?: string[],
15+
outputPath?: string,
1216
}
1317

1418
function parseParams(): GenerateAllParams {
@@ -22,34 +26,67 @@ function parseParams(): GenerateAllParams {
2226
executeSynchronous(async () => {
2327
const params = parseParams();
2428

25-
let filteredAutogenlist = getAutogenlist();
29+
let filteredAutoGenList = getAutoGenList();
2630
if (params.batchCount !== undefined && params.batchIndex !== undefined) {
27-
filteredAutogenlist = chunker(filteredAutogenlist, params.batchCount)[params.batchIndex];
31+
filteredAutoGenList = chunker(filteredAutoGenList, params.batchCount)[params.batchIndex];
2832
}
2933

30-
await cloneAndGenerateBasePaths(constants.specsRepoPath, constants.specsRepoUri, constants.specsRepoCommitHash);
34+
let localPath = params.localPath;
35+
if (!localPath) {
36+
localPath = constants.specsRepoPath;
37+
await cloneAndGenerateBasePaths(localPath, constants.specsRepoUri, constants.specsRepoCommitHash);
38+
} else {
39+
localPath = await resolveAbsolutePath(localPath);
40+
}
41+
42+
if (!!params.readmeFiles) {
43+
filteredAutoGenList = filteredAutoGenList.filter(c => {
44+
let r = params.readmeFiles?.find(f => f.startsWith('specification/' + c.basePath));
45+
if (!!r) {
46+
c.readmeFile = r;
47+
return true;
48+
}
49+
return false;
50+
}
51+
);
52+
}
3153

32-
await clearAutogeneratedSchemaRefs(filteredAutogenlist);
54+
await clearAutoGeneratedSchemaRefs(filteredAutoGenList);
3355

3456
const schemaConfigs: SchemaConfiguration[] = [];
3557
const errors = [];
36-
for (const autogenlistConfig of filteredAutogenlist) {
58+
const packages: Package[] = [];
59+
for (const autoGenConfig of filteredAutoGenList) {
60+
let pkg = {
61+
path: ['schemas']
62+
} as Package;
3763
try {
38-
const readme = await validateAndReturnReadmePath(autogenlistConfig.basePath);
64+
const readme = await validateAndReturnReadmePath(localPath, autoGenConfig.readmeFile || autoGenConfig.basePath);
65+
pkg.packageName = getPackageString(readme);
3966

40-
const newConfigs = await generateSchemas(readme, autogenlistConfig);
67+
const newConfigs = await generateSchemas(readme, autoGenConfig);
4168
schemaConfigs.push(...newConfigs);
69+
pkg.result = 'succeeded';
4270
} catch(error) {
43-
console.log(chalk.red(`Caught exception processing autogenlist entry ${autogenlistConfig.basePath}.`));
71+
pkg.packageName = autoGenConfig.basePath;
72+
pkg.result = 'failed';
73+
console.log(chalk.red(`Caught exception processing autogenlist entry ${autoGenConfig.basePath}.`));
4474
console.log(chalk.red(error));
4575

4676
errors.push(error);
4777
}
78+
packages.push(pkg);
4879
}
4980

50-
await saveAutogeneratedSchemaRefs(flatten(schemaConfigs));
81+
await saveAutoGeneratedSchemaRefs(flatten(schemaConfigs));
5182

52-
if (errors.length > 0) {
53-
throw new Error(`Autogeneration failed with ${errors.length} errors. See logs for detailed information.`);
83+
if (!!params.outputPath) {
84+
const outputPath = await resolveAbsolutePath(params.outputPath);
85+
await writeJsonFile(outputPath, { packages });
86+
} else {
87+
if (errors.length > 0) {
88+
throw new Error(`Autogeneration failed with ${errors.length} errors. See logs for detailed information.`);
89+
}
5490
}
91+
5592
});

0 commit comments

Comments
 (0)