Skip to content

Commit bd5d755

Browse files
authored
Merge pull request #7795 from systeminit/fixes-to-extended-location
fix(clover): Ensure extendedLocation.name not set as required field
2 parents 90f84ce + 990471a commit bd5d755

File tree

3 files changed

+98
-64
lines changed

3 files changed

+98
-64
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { PropOverrideFn, SchemaOverrideFn } from "../types.ts";
2+
import { ExpandedPkgSpec } from "../../spec/pkgs.ts";
3+
import {
4+
fixNames,
5+
objectPropForOverride,
6+
propForOverride,
7+
} from "../generic/overrides.ts";
8+
9+
export const AZURE_PROP_OVERRIDES: Record<
10+
string,
11+
Record<string, PropOverrideFn | PropOverrideFn[]>
12+
> = {};
13+
14+
export const AZURE_SCHEMA_OVERRIDES = new Map<string, SchemaOverrideFn>([
15+
[
16+
"Microsoft.Web/serverfarms",
17+
(spec: ExpandedPkgSpec) => {
18+
const variant = spec.schemas[0].variants[0];
19+
const extendedLocationProp = objectPropForOverride(
20+
variant.domain,
21+
"extendedLocation",
22+
);
23+
24+
const nameProp = propForOverride(extendedLocationProp, "name");
25+
nameProp.joiValidation = undefined;
26+
nameProp.data.validationFormat = "{}";
27+
nameProp.metadata.required = false;
28+
},
29+
],
30+
[
31+
"Microsoft.Web/sites",
32+
(spec: ExpandedPkgSpec) => {
33+
const variant = spec.schemas[0].variants[0];
34+
35+
const extendedLocationProp = objectPropForOverride(
36+
variant.domain,
37+
"extendedLocation",
38+
);
39+
if (!extendedLocationProp) {
40+
throw new Error("Can't find extendedLocation prop");
41+
}
42+
43+
const nameProp = propForOverride(extendedLocationProp, "name");
44+
if (!nameProp) {
45+
throw new Error("Can't find name prop");
46+
}
47+
nameProp.joiValidation = undefined;
48+
nameProp.data.validationFormat = "{}";
49+
nameProp.metadata.required = false;
50+
},
51+
],
52+
[
53+
"Microsoft.Aad/domainServices/ouContainer",
54+
fixNames({
55+
categoryName: "Microsoft.AAD",
56+
schemaName: "Microsoft.AAD/domainServices/ouContainer",
57+
}),
58+
],
59+
[
60+
"microsoft.insights/guestDiagnosticSettings",
61+
fixNames({
62+
categoryName: "Microsoft.Insights",
63+
schemaName: "Microsoft.Insights/guestDiagnosticSettings",
64+
}),
65+
],
66+
[
67+
"microsoft.insights/components/linkedStorageAccounts",
68+
fixNames({
69+
categoryName: "Microsoft.Insights",
70+
schemaName: "Microsoft.Insights/components/linkedStorageAccounts",
71+
}),
72+
],
73+
[
74+
"microsoft.alertsManagement/smartDetectorAlertRules",
75+
fixNames({
76+
categoryName: "Microsoft.AlertsManagement",
77+
schemaName: "Microsoft.AlertsManagement/smartDetectorAlertRules",
78+
}),
79+
],
80+
[
81+
"Microsoft.DBForMySql/flexibleServers/keys",
82+
fixNames({
83+
categoryName: "Microsoft.DBforMySQL",
84+
schemaName: "Microsoft.DBforMySQL/flexibleServers/keys",
85+
}),
86+
],
87+
[
88+
"Microsoft.DBForPostgreSql/flexibleServers/keys",
89+
fixNames({
90+
categoryName: "Microsoft.DBforPostgreSQL",
91+
schemaName: "Microsoft.DBforPostgreSQL/flexibleServers/keys",
92+
}),
93+
],
94+
]);

bin/clover/src/pipelines/azure/pipeline.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { ExpandedPkgSpec } from "../../spec/pkgs.ts";
22
import { PipelineOptions } from "../types.ts";
3+
import { AZURE_PROVIDER_CONFIG } from "./provider.ts";
34
import { generateDefaultFuncsFromConfig } from "../generic/index.ts";
45
import { getExistingSpecs } from "../../specUpdates.ts";
56
import { generateIntrinsicFuncs } from "../generic/generateIntrinsicFuncs.ts";
@@ -20,20 +21,18 @@ import { removeUnneededAssets } from "./pipeline-steps/removeUnneededAssets.ts";
2021
export async function generateAzureSpecs(
2122
options: PipelineOptions,
2223
): Promise<ExpandedPkgSpec[]> {
23-
const azureConfig = (await import("./provider.ts")).AZURE_PROVIDER_CONFIG;
24-
2524
const existingSpecs = await getExistingSpecs(options);
2625
let specs = await getLatestAzureSpecs(options);
2726

2827
// Apply pipeline steps
2928
specs = removeUnneededAssets(specs);
3029
specs = addDefaultProps(specs);
31-
specs = generateDefaultFuncsFromConfig(specs, azureConfig);
30+
specs = generateDefaultFuncsFromConfig(specs, AZURE_PROVIDER_CONFIG);
3231
specs = generateIntrinsicFuncs(specs);
3332
specs = createSuggestionsForIds(specs);
3433

3534
// Apply provider-specific overrides
36-
specs = applyAssetOverrides(specs, azureConfig);
35+
specs = applyAssetOverrides(specs, AZURE_PROVIDER_CONFIG);
3736

3837
specs = reorderProps(specs);
3938
specs = generateAssetFuncs(specs);

bin/clover/src/pipelines/azure/provider.ts

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
import assert from "node:assert";
21
import {
32
FetchSchemaOptions,
4-
PropOverrideFn,
53
PROVIDER_REGISTRY,
64
ProviderConfig,
7-
SchemaOverrideFn,
85
SuperSchema,
96
} from "../types.ts";
107
import { ExpandedPropSpecFor } from "../../spec/props.ts";
@@ -21,7 +18,7 @@ import {
2118
initAzureRestApiSpecsRepo,
2219
} from "./schema.ts";
2320
import { JSONSchema } from "../draft_07.ts";
24-
import { fixNames, suggest } from "../generic/overrides.ts";
21+
import { AZURE_PROP_OVERRIDES, AZURE_SCHEMA_OVERRIDES } from "./overrides.ts";
2522

2623
async function azureFetchSchema(options: FetchSchemaOptions) {
2724
const specsRepo = initAzureRestApiSpecsRepo(options);
@@ -65,62 +62,6 @@ function azureIsChildRequired(
6562
return schema.requiredProperties.has(childName);
6663
}
6764

68-
// NOTE(nick,jkeiser): here is an example of what overrides look like...
69-
const AZURE_PROP_OVERRIDES: Record<
70-
string,
71-
Record<string, PropOverrideFn | PropOverrideFn[]>
72-
> = {
73-
// "Microsoft.Network/loadBalancers": {
74-
// "properties/frontendIPConfigurations/frontendIPConfigurationsItem/properties/publicIPAddress/id": suggest("Microsoft.Network/publicIPAddresses", "id"),
75-
// }
76-
};
77-
78-
const AZURE_SCHEMA_OVERRIDES: ProviderConfig["overrides"]["schemaOverrides"] =
79-
new Map([
80-
[
81-
"Microsoft.Aad/domainServices/ouContainer",
82-
fixNames({
83-
categoryName: "Microsoft.AAD",
84-
schemaName: "Microsoft.AAD/domainServices/ouContainer",
85-
}),
86-
],
87-
[
88-
"microsoft.insights/guestDiagnosticSettings",
89-
fixNames({
90-
categoryName: "Microsoft.Insights",
91-
schemaName: "Microsoft.Insights/guestDiagnosticSettings",
92-
}),
93-
],
94-
[
95-
"microsoft.insights/components/linkedStorageAccounts",
96-
fixNames({
97-
categoryName: "Microsoft.Insights",
98-
schemaName: "Microsoft.Insights/components/linkedStorageAccounts",
99-
}),
100-
],
101-
[
102-
"microsoft.alertsManagement/smartDetectorAlertRules",
103-
fixNames({
104-
categoryName: "Microsoft.AlertsManagement",
105-
schemaName: "Microsoft.AlertsManagement/smartDetectorAlertRules",
106-
}),
107-
],
108-
[
109-
"Microsoft.DBForMySql/flexibleServers/keys",
110-
fixNames({
111-
categoryName: "Microsoft.DBforMySQL",
112-
schemaName: "Microsoft.DBforMySQL/flexibleServers/keys",
113-
}),
114-
],
115-
[
116-
"Microsoft.DBForPostgreSql/flexibleServers/keys",
117-
fixNames({
118-
categoryName: "Microsoft.DBforPostgreSQL",
119-
schemaName: "Microsoft.DBforPostgreSQL/flexibleServers/keys",
120-
})
121-
],
122-
]);
123-
12465
export const AZURE_PROVIDER_CONFIG: ProviderConfig = {
12566
name: "azure",
12667
isStable: true,

0 commit comments

Comments
 (0)