-
Notifications
You must be signed in to change notification settings - Fork 53
Custom resource schema modifications #3571
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
f2718d6
Move types visitor to avoid import cycle when using from custom resou…
danielrbradley 27317a4
New custom resource schema & metadata interface
danielrbradley 3a6f92d
Implement dashboard customisations
danielrbradley 844e7e6
Add dashboard snapshot test
danielrbradley 586e10d
Deprecate old schema properties
danielrbradley cf7dbb6
Switch vnet test to JSON matchers
danielrbradley 10d7d04
Fix test helper typo
danielrbradley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
1,386 changes: 1,386 additions & 0 deletions
1,386
provider/pkg/gen/__snapshots__/gen_dashboard_test.snap
Large diffs are not rendered by default.
Oops, something went wrong.
415,261 changes: 87,132 additions & 328,129 deletions
415,261
provider/pkg/gen/__snapshots__/gen_vnet_test.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package gen | ||
|
|
||
| import ( | ||
| "os" | ||
| "path" | ||
| "testing" | ||
|
|
||
| "github.com/gkampitakis/go-snaps/snaps" | ||
| "github.com/pulumi/pulumi-azure-native/v2/provider/pkg/openapi" | ||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestPortalDashboardGen(t *testing.T) { | ||
| wd, err := os.Getwd() | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| // We take a snapshot of the schema as we're focusing on testing how we parse and modify the spec | ||
| // To update the specifications run in the repo root: | ||
| // rm -rf provider/pkg/gen/test-data/dashboard/azure-rest-api-specs/specification/portal/resource-manager/Microsoft.Portal/preview/2020-09-01-preview/ | ||
| // rm -rf provider/pkg/gen/test-data/dashboard/azure-rest-api-specs/specification/common-types/resource-management/v5/ | ||
| // cp -r azure-rest-api-specs/specification/portal/resource-manager/Microsoft.Portal/preview/2020-09-01-preview/ provider/pkg/gen/test-data/dashboard/azure-rest-api-specs/specification/portal/resource-manager/Microsoft.Portal/preview/2020-09-01-preview/ | ||
| // cp -r azure-rest-api-specs/specification/common-types/resource-management/v5/ provider/pkg/gen/test-data/dashboard/azure-rest-api-specs/specification/common-types/resource-management/v5/ | ||
| // rm -rf provider/pkg/gen/test-data/dashboard/azure-rest-api-specs/specification/portal/resource-manager/Microsoft.Portal/preview/2020-09-01-preview/examples/ | ||
| rootDir := path.Join(wd, "test-data", "dashboard") | ||
|
|
||
| providers, _, err := openapi.ReadAzureProviders(path.Join(rootDir, "azure-rest-api-specs"), "Portal", "2020-09-01-preview") | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
| providers = openapi.ApplyProvidersTransformations(providers, map[string]map[string]string{ | ||
| "Portal": { | ||
| "Dashboard": "2020-09-01-preview", | ||
| }, | ||
| }, map[string]map[string]string{}, map[string][]string{}, map[string][]string{}) | ||
| generationResult, err := PulumiSchema(rootDir, providers, versioningStub{}) | ||
| if err != nil { | ||
| t.Fatal(err) | ||
| } | ||
|
|
||
| // Ensure the dashboard resource is present in schema and metadata | ||
| // and snapshot the generation result so we can see the impact of future refactors. | ||
| assert.NotNil(t, generationResult.Schema.Resources["azure-native:portal:Dashboard"]) | ||
| snaps.MatchJSON(t, generationResult.Schema.Resources["azure-native:portal:Dashboard"]) | ||
|
|
||
| assert.NotNil(t, generationResult.Metadata.Resources["azure-native:portal:Dashboard"]) | ||
| snaps.MatchJSON(t, generationResult.Metadata.Resources["azure-native:portal:Dashboard"]) | ||
|
|
||
| snaps.MatchJSON(t, generationResult.Schema.Types) | ||
| snaps.MatchJSON(t, generationResult.Metadata.Types) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
68 changes: 68 additions & 0 deletions
68
...rest-api-specs/specification/common-types/resource-management/v5/customermanagedkeys.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| { | ||
| "swagger": "2.0", | ||
| "info": { | ||
| "version": "5.0", | ||
| "title": "Common types" | ||
| }, | ||
| "paths": {}, | ||
| "definitions": { | ||
| "encryption": { | ||
| "type": "object", | ||
| "description": "All encryption configuration for a resource.", | ||
| "properties": { | ||
| "infrastructureEncryption": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "enabled", | ||
| "disabled" | ||
| ], | ||
| "x-ms-enum": { | ||
| "name": "InfrastructureEncryption", | ||
| "modelAsString": true | ||
| }, | ||
| "description": "(Optional) Discouraged to include in resource definition. Only needed where it is possible to disable platform (AKA infrastructure) encryption. Azure SQL TDE is an example of this. Values are enabled and disabled." | ||
| }, | ||
| "customerManagedKeyEncryption": { | ||
| "type": "object", | ||
| "description": "All Customer-managed key encryption properties for the resource.", | ||
| "properties": { | ||
| "keyEncryptionKeyIdentity": { | ||
| "type": "object", | ||
| "description": "All identity configuration for Customer-managed key settings defining which identity should be used to auth to Key Vault.", | ||
| "properties": { | ||
| "identityType": { | ||
| "type": "string", | ||
| "enum": [ | ||
| "systemAssignedIdentity", | ||
| "userAssignedIdentity", | ||
| "delegatedResourceIdentity" | ||
| ], | ||
| "description": "The type of identity to use. Values can be systemAssignedIdentity, userAssignedIdentity, or delegatedResourceIdentity." | ||
| }, | ||
| "userAssignedIdentityResourceId": { | ||
| "type": "string", | ||
| "format": "arm-id", | ||
| "description": "User assigned identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity." | ||
| }, | ||
| "federatedClientId": { | ||
| "type": "string", | ||
| "format": "uuid", | ||
| "description": "application client identity to use for accessing key encryption key Url in a different tenant. Ex: f83c6b1b-4d34-47e4-bb34-9d83df58b540" | ||
| }, | ||
| "delegatedIdentityClientId": { | ||
| "type": "string", | ||
| "format": "uuid", | ||
| "description": "delegated identity to use for accessing key encryption key Url. Ex: /subscriptions/fa5fc227-a624-475e-b696-cdd604c735bc/resourceGroups/<resource group>/providers/Microsoft.ManagedIdentity/userAssignedIdentities/myId. Mutually exclusive with identityType systemAssignedIdentity and userAssignedIdentity - internal use only." | ||
| } | ||
| } | ||
| }, | ||
| "keyEncryptionKeyUrl": { | ||
| "type": "string", | ||
| "description": "key encryption key Url, versioned or unversioned. Ex: https://contosovault.vault.azure.net/keys/contosokek/562a4bb76b524a1493a6afe8e536ee78 or https://contosovault.vault.azure.net/keys/contosokek." | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
114 changes: 114 additions & 0 deletions
114
...ure-rest-api-specs/specification/common-types/resource-management/v5/managedidentity.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,114 @@ | ||
| { | ||
| "swagger": "2.0", | ||
| "info": { | ||
| "version": "5.0", | ||
| "title": "Common types" | ||
| }, | ||
| "paths": {}, | ||
| "definitions": { | ||
| "UserAssignedIdentities": { | ||
| "title": "User-Assigned Identities", | ||
| "description": "The set of user assigned identities associated with the resource. The userAssignedIdentities dictionary keys will be ARM resource ids in the form: '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/{identityName}. The dictionary values can be empty objects ({}) in requests.", | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "$ref": "#/definitions/UserAssignedIdentity", | ||
| "x-nullable": true | ||
| } | ||
| }, | ||
| "UserAssignedIdentity": { | ||
| "type": "object", | ||
| "description": "User assigned identity properties", | ||
| "properties": { | ||
| "principalId": { | ||
| "description": "The principal ID of the assigned identity.", | ||
| "format": "uuid", | ||
| "type": "string", | ||
| "readOnly": true | ||
| }, | ||
| "clientId": { | ||
| "description": "The client ID of the assigned identity.", | ||
| "format": "uuid", | ||
| "type": "string", | ||
| "readOnly": true | ||
| } | ||
| } | ||
| }, | ||
| "ManagedServiceIdentityType": { | ||
| "description": "Type of managed service identity (where both SystemAssigned and UserAssigned types are allowed).", | ||
| "enum": [ | ||
| "None", | ||
| "SystemAssigned", | ||
| "UserAssigned", | ||
| "SystemAssigned,UserAssigned" | ||
| ], | ||
| "type": "string", | ||
| "x-ms-enum": { | ||
| "name": "ManagedServiceIdentityType", | ||
| "modelAsString": true | ||
| } | ||
| }, | ||
| "ManagedServiceIdentity": { | ||
| "description": "Managed service identity (system assigned and/or user assigned identities)", | ||
| "type": "object", | ||
| "properties": { | ||
| "principalId": { | ||
| "readOnly": true, | ||
| "format": "uuid", | ||
| "type": "string", | ||
| "description": "The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity." | ||
| }, | ||
| "tenantId": { | ||
| "readOnly": true, | ||
| "format": "uuid", | ||
| "type": "string", | ||
| "description": "The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity." | ||
| }, | ||
| "type": { | ||
| "$ref": "#/definitions/ManagedServiceIdentityType" | ||
| }, | ||
| "userAssignedIdentities": { | ||
| "$ref": "#/definitions/UserAssignedIdentities" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "type" | ||
| ] | ||
| }, | ||
| "SystemAssignedServiceIdentityType": { | ||
| "description": "Type of managed service identity (either system assigned, or none).", | ||
| "enum": [ | ||
| "None", | ||
| "SystemAssigned" | ||
| ], | ||
| "type": "string", | ||
| "x-ms-enum": { | ||
| "name": "SystemAssignedServiceIdentityType", | ||
| "modelAsString": true | ||
| } | ||
| }, | ||
| "SystemAssignedServiceIdentity": { | ||
| "description": "Managed service identity (either system assigned, or none)", | ||
| "type": "object", | ||
| "properties": { | ||
| "principalId": { | ||
| "readOnly": true, | ||
| "format": "uuid", | ||
| "type": "string", | ||
| "description": "The service principal ID of the system assigned identity. This property will only be provided for a system assigned identity." | ||
| }, | ||
| "tenantId": { | ||
| "readOnly": true, | ||
| "format": "uuid", | ||
| "type": "string", | ||
| "description": "The tenant ID of the system assigned identity. This property will only be provided for a system assigned identity." | ||
| }, | ||
| "type": { | ||
| "$ref": "#/definitions/SystemAssignedServiceIdentityType" | ||
| } | ||
| }, | ||
| "required": [ | ||
| "type" | ||
| ] | ||
| } | ||
| } | ||
| } |
54 changes: 54 additions & 0 deletions
54
...pecs/specification/common-types/resource-management/v5/managedidentitywithdelegation.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,54 @@ | ||
| { | ||
| "swagger": "2.0", | ||
| "info": { | ||
| "version": "5.0", | ||
| "title": "Common types" | ||
| }, | ||
| "paths": {}, | ||
| "definitions": { | ||
| "ManagedServiceIdentityWithDelegation": { | ||
| "description": "Managed service identity (system assigned and/or user assigned identities and/or delegated identities) - internal use only.", | ||
| "type": "object", | ||
| "allOf": [ | ||
| { | ||
| "$ref": "managedidentity.json#/definitions/ManagedServiceIdentity" | ||
| } | ||
| ], | ||
| "properties": { | ||
| "delegatedResources": { | ||
| "$ref": "#/definitions/DelegatedResources" | ||
| } | ||
| } | ||
| }, | ||
| "DelegatedResources": { | ||
| "description": "The set of delegated resources. The delegated resources dictionary keys will be source resource internal ids - internal use only.", | ||
| "type": "object", | ||
| "additionalProperties": { | ||
| "$ref": "#/definitions/DelegatedResource" | ||
| } | ||
| }, | ||
| "DelegatedResource": { | ||
| "type": "object", | ||
| "description": "Delegated resource properties - internal use only.", | ||
| "properties": { | ||
| "resourceId": { | ||
| "description": "The ARM resource id of the delegated resource - internal use only.", | ||
| "type": "string" | ||
| }, | ||
| "tenantId": { | ||
| "description": "The tenant id of the delegated resource - internal use only.", | ||
| "format": "uuid", | ||
| "type": "string" | ||
| }, | ||
| "referralResource": { | ||
| "description": "The delegation id of the referral delegation (optional) - internal use only.", | ||
| "type": "string" | ||
| }, | ||
| "location": { | ||
| "description": "The source resource location - internal use only.", | ||
| "type": "string" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
38 changes: 38 additions & 0 deletions
38
...ashboard/azure-rest-api-specs/specification/common-types/resource-management/v5/mobo.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "swagger": "2.0", | ||
| "info": { | ||
| "version": "5.0", | ||
| "title": "Common types" | ||
| }, | ||
| "paths": {}, | ||
| "definitions": { | ||
| "ManagedOnBehalfOfConfiguration": { | ||
| "type": "object", | ||
| "description": "Managed-On-Behalf-Of configuration properties. This configuration exists for the resources where a resource provider manages those resources on behalf of the resource owner.", | ||
| "properties": { | ||
| "moboBrokerResources": { | ||
| "type": "array", | ||
| "description": "Managed-On-Behalf-Of broker resources", | ||
| "items": { | ||
| "$ref": "#/definitions/MoboBrokerResource" | ||
| }, | ||
| "x-ms-identifiers": [ | ||
| "id" | ||
| ] | ||
| } | ||
| }, | ||
| "readOnly": true | ||
| }, | ||
| "MoboBrokerResource": { | ||
| "type": "object", | ||
| "description": "Managed-On-Behalf-Of broker resource. This resource is created by the Resource Provider to manage some resources on behalf of the user.", | ||
| "properties": { | ||
| "id": { | ||
| "type": "string", | ||
| "format": "arm-id", | ||
| "description": "Resource identifier of a Managed-On-Behalf-Of broker resource" | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.