Skip to content

Commit

Permalink
Revert defaultTags schema change
Browse files Browse the repository at this point in the history
- Allow the provider to parse both the old and new schemas for compatability.
  • Loading branch information
danielrbradley committed Mar 8, 2024
1 parent 564817d commit 1512b95
Show file tree
Hide file tree
Showing 19 changed files with 398 additions and 60 deletions.
4 changes: 3 additions & 1 deletion examples/examples_py_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ func TestDefaultTagsPython(t *testing.T) {
Dir: filepath.Join(getCwd(t), "default-tags-py"),
Config: map[string]string{
"aws-native:defaultTags": `{
"defaultTag": "defaultTagValue"
"tags": {
"defaultTag": "defaultTagValue"
}
}`,
},
ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) {
Expand Down
51 changes: 39 additions & 12 deletions provider/cmd/cf2pulumi/schema-full.json
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,7 @@
"description": "Configuration for retrieving temporary credentials from the STS service."
},
"defaultTags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"$ref": "#/types/aws-native:config:DefaultTags",
"description": "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys."
},
"endpoints": {
Expand Down Expand Up @@ -23250,6 +23247,24 @@
},
"type": "object"
},
"aws-native:config:DefaultTags": {
"description": "The configuration with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
"properties": {
"tags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "A group of tags to set across all resources.",
"language": {
"python": {
"mapCase": false
}
}
}
},
"type": "object"
},
"aws-native:config:Endpoints": {
"description": "The configuration for for customizing service endpoints.",
"properties": {
Expand Down Expand Up @@ -56638,6 +56653,24 @@
},
"type": "object"
},
"aws-native:index:ProviderDefaultTags": {
"description": "The configuration with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
"properties": {
"tags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "A group of tags to set across all resources.",
"language": {
"python": {
"mapCase": false
}
}
}
},
"type": "object"
},
"aws-native:index:ProviderEndpoint": {
"description": "The configuration for for customizing service endpoints.",
"properties": {
Expand Down Expand Up @@ -153770,10 +153803,7 @@
"description": "Configuration for retrieving temporary credentials from the STS service."
},
"defaultTags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"$ref": "#/types/aws-native:index:ProviderDefaultTags",
"description": "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys."
},
"endpoints": {
Expand Down Expand Up @@ -153862,10 +153892,7 @@
"description": "Configuration for retrieving temporary credentials from the STS service."
},
"defaultTags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"$ref": "#/types/aws-native:index:ProviderDefaultTags",
"description": "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys."
},
"endpoints": {
Expand Down
51 changes: 39 additions & 12 deletions provider/cmd/pulumi-resource-aws-native/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,7 @@
"description": "Configuration for retrieving temporary credentials from the STS service."
},
"defaultTags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"$ref": "#/types/aws-native:config:DefaultTags",
"description": "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys."
},
"endpoints": {
Expand Down Expand Up @@ -18050,6 +18047,24 @@
},
"type": "object"
},
"aws-native:config:DefaultTags": {
"description": "The configuration with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
"properties": {
"tags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "A group of tags to set across all resources.",
"language": {
"python": {
"mapCase": false
}
}
}
},
"type": "object"
},
"aws-native:config:Endpoints": {
"description": "The configuration for for customizing service endpoints.",
"properties": {
Expand Down Expand Up @@ -45093,6 +45108,24 @@
},
"type": "object"
},
"aws-native:index:ProviderDefaultTags": {
"description": "The configuration with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
"properties": {
"tags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"description": "A group of tags to set across all resources.",
"language": {
"python": {
"mapCase": false
}
}
}
},
"type": "object"
},
"aws-native:index:ProviderEndpoint": {
"description": "The configuration for for customizing service endpoints.",
"properties": {
Expand Down Expand Up @@ -132914,10 +132947,7 @@
"description": "Configuration for retrieving temporary credentials from the STS service."
},
"defaultTags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"$ref": "#/types/aws-native:index:ProviderDefaultTags",
"description": "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys."
},
"endpoints": {
Expand Down Expand Up @@ -133006,10 +133036,7 @@
"description": "Configuration for retrieving temporary credentials from the STS service."
},
"defaultTags": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"$ref": "#/types/aws-native:index:ProviderDefaultTags",
"description": "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys."
},
"endpoints": {
Expand Down
15 changes: 12 additions & 3 deletions provider/pkg/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,12 +461,21 @@ func (p *cfnProvider) Configure(ctx context.Context, req *pulumirpc.ConfigureReq
}

if defaultTagsJson, ok := vars["aws-native:config:defaultTags"]; ok {
var defaultTags map[string]string
type DefaultTags struct {
Tags map[string]string `json:"tags"`
}
var defaultTags DefaultTags
err := json.Unmarshal([]byte(defaultTagsJson), &defaultTags)
if err != nil {
return nil, fmt.Errorf("failed to unmarshal 'skipCredentialsValidation' config: %w", err)
p.defaultTags = defaultTags.Tags
} else {
// As a fallback, we also try to unmarshal the default tags as a simple map[string]string
// as this was originally supported when implementing defaultTags.
fallbackErr := json.Unmarshal([]byte(defaultTagsJson), &p.defaultTags)
if fallbackErr != nil {
return nil, fmt.Errorf("failed to unmarshal 'defaultTags' config: %w", err)
}
}
p.defaultTags = defaultTags
} else {
p.defaultTags = nil
}
Expand Down
31 changes: 24 additions & 7 deletions provider/pkg/schema/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,21 @@ var assumeRole = pschema.ComplexTypeSpec{
},
}

var defaultTags = pschema.ComplexTypeSpec{
ObjectTypeSpec: pschema.ObjectTypeSpec{
Description: "The configuration with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
Properties: map[string]pschema.PropertySpec{
"tags": {
Description: "A group of tags to set across all resources.",
TypeSpec: pschema.TypeSpec{
Type: "object",
AdditionalProperties: &pschema.TypeSpec{Type: "string"}},
},
},
Type: "object",
},
}

var endpoints = pschema.ComplexTypeSpec{
ObjectTypeSpec: pschema.ObjectTypeSpec{
Description: "The configuration for for customizing service endpoints.",
Expand Down Expand Up @@ -156,11 +171,13 @@ var region = pschema.ComplexTypeSpec{

// typeOverlays augment the types defined by the schema.
var typeOverlays = map[string]pschema.ComplexTypeSpec{
"aws-native:config:AssumeRole": assumeRole,
"aws-native:index:ProviderAssumeRole": configToProvider(assumeRole),
"aws-native:config:Endpoints": endpoints,
"aws-native:index:ProviderEndpoint": configToProvider(endpoints),
"aws-native:config:IgnoreTags": ignoreTags,
"aws-native:index:ProviderIgnoreTags": configToProvider(ignoreTags),
"aws-native:index/Region:Region": region,
"aws-native:config:AssumeRole": assumeRole,
"aws-native:index:ProviderAssumeRole": configToProvider(assumeRole),
"aws-native:config:DefaultTags": defaultTags,
"aws-native:index:ProviderDefaultTags": configToProvider(defaultTags),
"aws-native:config:Endpoints": endpoints,
"aws-native:index:ProviderEndpoint": configToProvider(endpoints),
"aws-native:config:IgnoreTags": ignoreTags,
"aws-native:index:ProviderIgnoreTags": configToProvider(ignoreTags),
"aws-native:index/Region:Region": region,
}
6 changes: 3 additions & 3 deletions provider/pkg/schema/gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func GatherPackage(supportedResourceTypes []string, jsonSchemas []jsschema.Schem
},
"defaultTags": {
Description: "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
TypeSpec: pschema.TypeSpec{Type: "object", AdditionalProperties: &pschema.TypeSpec{Type: "string"}},
TypeSpec: pschema.TypeSpec{Ref: "#/types/aws-native:config:DefaultTags"},
},
"endpoints": {
Description: "Configuration block for customizing service endpoints.",
Expand Down Expand Up @@ -177,7 +177,7 @@ func GatherPackage(supportedResourceTypes []string, jsonSchemas []jsschema.Schem
},
"defaultTags": {
Description: "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
TypeSpec: pschema.TypeSpec{Type: "object", AdditionalProperties: &pschema.TypeSpec{Type: "string"}},
TypeSpec: pschema.TypeSpec{Ref: "#/types/aws-native:index:ProviderDefaultTags"},
},
"endpoints": {
Description: "Configuration block for customizing service endpoints.",
Expand Down Expand Up @@ -260,7 +260,7 @@ func GatherPackage(supportedResourceTypes []string, jsonSchemas []jsschema.Schem
},
"defaultTags": {
Description: "Configuration block with resource tag settings to apply across all resources handled by this provider. This is designed to replace redundant per-resource `tags` configurations. Provider tags can be overridden with new values, but not excluded from specific resources. To override provider tag values, use the `tags` argument within a resource to configure new tag values for matching keys.",
TypeSpec: pschema.TypeSpec{Type: "object", AdditionalProperties: &pschema.TypeSpec{Type: "string"}},
TypeSpec: pschema.TypeSpec{Ref: "#/types/aws-native:index:ProviderDefaultTags"},
},
"endpoints": {
Description: "Configuration block for customizing service endpoints.",
Expand Down
12 changes: 10 additions & 2 deletions sdk/dotnet/Config/Config.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 35 additions & 0 deletions sdk/dotnet/Inputs/ProviderDefaultTagsArgs.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1512b95

Please sign in to comment.