Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated common-types version to v6 #735

Merged
merged 3 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions packages/rulesets/generated/spectral/az-arm.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ const mutabilityWithReadOnly = (prop, _opts, ctx) => {
};

const LATEST_VERSION_BY_COMMON_TYPES_FILENAME = new Map([
["types.json", "v5"],
["managedidentity.json", "v5"],
["privatelinks.json", "v5"],
["types.json", "v6"],
["managedidentity.json", "v6"],
["privatelinks.json", "v6"],
["customermanagedkeys.json", "v5"],
["managedidentitywithdelegation.json", "v5"],
["networksecurityperimeter.json", "v5"],
Expand Down Expand Up @@ -2585,7 +2585,12 @@ const reservedResourceNamesModelAsEnum = (pathItem, _opts, ctx) => {
return errors;
};

const EXCEPTION_LIST = ["resourceGroupName", "privateEndpointConnectionName", "managementGroupName"];
const EXCEPTION_LIST = [
"resourceGroupName",
"privateEndpointConnectionName",
"managementGroupName",
"networkSecurityPerimeterConfigurationName",
];
const resourceNameRestriction = (paths, _opts, ctx) => {
if (paths === null || typeof paths !== "object") {
return [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Check conformance to Azure parameter naming conventions:

//system-defined parameters => needs to be excluded from validation
const EXCEPTION_LIST = ["resourceGroupName", "privateEndpointConnectionName", "managementGroupName"]
const EXCEPTION_LIST = [
"resourceGroupName",
"privateEndpointConnectionName",
"managementGroupName",
"networkSecurityPerimeterConfigurationName",
]
export const resourceNameRestriction = (paths: any, _opts: any, ctx: any) => {
if (paths === null || typeof paths !== "object") {
return []
Expand Down
6 changes: 3 additions & 3 deletions packages/rulesets/src/spectral/functions/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import _ from "lodash"

export const LATEST_VERSION_BY_COMMON_TYPES_FILENAME = new Map([
["types.json", "v5"],
["managedidentity.json", "v5"],
["privatelinks.json", "v5"],
["types.json", "v6"],
["managedidentity.json", "v6"],
["privatelinks.json", "v6"],
["customermanagedkeys.json", "v5"],
["managedidentitywithdelegation.json", "v5"],
["networksecurityperimeter.json", "v5"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ test("LatestVersionOfCommonTypesMustBeUsed should find errors for obsolete versi
expect(results[0].path.join(".")).toBe("paths./foo.get.parameters.0.$ref")
expect(results[0].message).toContain("Use the latest version v5 of customermanagedkeys.json.")
expect(results[1].path.join(".")).toBe("paths./foo.get.parameters.1.$ref")
expect(results[1].message).toContain("Use the latest version v5 of managedidentity.json.")
expect(results[1].message).toContain("Use the latest version v6 of managedidentity.json.")
expect(results[2].path.join(".")).toBe("paths./foo.get.responses.200.$ref")
expect(results[2].message).toContain("Use the latest version v5 of types.json.")
expect(results[2].message).toContain("Use the latest version v6 of types.json.")
})
})

Expand All @@ -73,20 +73,20 @@ test("LatestVersionOfCommonTypesMustBeUsed should find no errors", async () => {
parameters: [
{
$ref: `../../../../../common-types/resource-management/${LATEST_VERSION_BY_COMMON_TYPES_FILENAME.get(
"customermanagedkeys.json"
"customermanagedkeys.json",
)}/customermanagedkeys.json#/parameters/ApiVersionParameter`,
},
{
$ref: `../../../../../common-types/resource-management/${LATEST_VERSION_BY_COMMON_TYPES_FILENAME.get(
"managedidentity.json"
"managedidentity.json",
)}/managedidentity.json#/parameters/ApiVersionParameter`,
},
],
responses: {
200: {
description: "Success",
$ref: `../../../../../common-types/resource-management/${LATEST_VERSION_BY_COMMON_TYPES_FILENAME.get(
"types.json"
"types.json",
)}/types.json#/parameters/ApiVersionParameter`,
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ test("ResourceNameRestriction should find errors on path level", () => {
return linter.run(oasDoc).then((results) => {
expect(results.length).toBe(1)
expect(results[0].path.join(".")).toBe(
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}"
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}",
)
expect(results[0].message).toContain("The resource name parameter 'fooName' should be defined with a 'pattern' restriction.")
})
Expand Down Expand Up @@ -61,7 +61,7 @@ test("ResourceNameRestriction should find errors on operation level", () => {
return linter.run(oasDoc).then((results) => {
expect(results.length).toBe(1)
expect(results[0].path.join(".")).toBe(
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}"
"paths./subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}",
)
expect(results[0].message).toContain("The resource name parameter 'fooName' should be defined with a 'pattern' restriction.")
})
Expand Down Expand Up @@ -138,6 +138,31 @@ test("ResourceNameRestriction should find no errors for system-defined variables
responses: {},
},
},
"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/My.NS/foo/{fooName}/networkSecurityPerimeterConfiguration/{networkSecurityPerimeterConfigurationName}":
{
parameters: [
{
name: "fooName",
in: "path",
required: true,
type: "string",
pattern: "[a-zA-Z_0-9]+",
"x-ms-parameter-location": "method",
},
{
name: "networkSecurityPerimeterConfigurationName",
in: "path",
required: true,
type: "string",
description: "The name of the network security perimeter configuration associated with the Azure resource.",
"x-ms-parameter-location": "method",
},
],
get: {
parameters: [],
responses: {},
},
},
},
}
return linter.run(oasDoc).then((results) => {
Expand Down