From 3fad811fee43f3505d5fed1e8cb7b021249e45eb Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 14 Feb 2024 17:57:41 +0300 Subject: [PATCH 1/3] Function type config.ConfigurationInjector now returns an error Signed-off-by: Alper Rifat Ulucinar --- config/cloudformation/config.go | 3 ++- config/ec2/config.go | 6 ++++-- config/s3/config.go | 6 ++++-- config/secretsmanager/config.go | 3 ++- go.mod | 2 ++ go.sum | 4 ++-- 6 files changed, 16 insertions(+), 8 deletions(-) diff --git a/config/cloudformation/config.go b/config/cloudformation/config.go index 9970b57f42..55042fd1c9 100644 --- a/config/cloudformation/config.go +++ b/config/cloudformation/config.go @@ -9,8 +9,9 @@ import "github.com/crossplane/upjet/pkg/config" // Configure adds configurations for the cloudformation group. func Configure(p *config.Provider) { p.AddResourceConfigurator("aws_cloudformation_stack_set_instance", func(r *config.Resource) { - r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) { + r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) error { params["region"] = jsonMap["region"] + return nil } }) } diff --git a/config/ec2/config.go b/config/ec2/config.go index 0af097df7e..668c28423c 100644 --- a/config/ec2/config.go +++ b/config/ec2/config.go @@ -216,11 +216,12 @@ func Configure(p *config.Provider) { "source_security_group_id", }, } - r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) { + r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) error { // TODO: Has better be implemented via defaulting. if _, ok := jsonMap["self"]; !ok { params["self"] = false } + return nil } }) @@ -423,12 +424,13 @@ func Configure(p *config.Provider) { r.References["source_ami_id"] = config.Reference{ Type: "AMI", } - r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) { + r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) error { params["ebs_block_device"] = []any{} // TODO: Has better be implemented via defaulting. if _, ok := jsonMap["encrypted"]; !ok { params["encrypted"] = false } + return nil } r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, _ *terraform.InstanceState, _ *terraform.ResourceConfig) (*terraform.InstanceDiff, error) { if diff != nil && diff.Attributes != nil { diff --git a/config/s3/config.go b/config/s3/config.go index 3178c495cb..5803803e0a 100644 --- a/config/s3/config.go +++ b/config/s3/config.go @@ -42,7 +42,7 @@ func Configure(p *config.Provider) { "logging", "object_lock_configuration", "policy", "replication_configuration", "request_payer", "server_side_encryption_configuration", "versioning", "website", "arn") r.MetaResource.ExternalName = registry.RandRFC1123Subdomain - r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) { + r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) error { params["region"] = jsonMap["region"] // TODO: added to prevent extra reconciliations due to // late-initialization or drift. Has better be implemented @@ -50,6 +50,7 @@ func Configure(p *config.Provider) { if _, ok := jsonMap["forceDestroy"]; !ok { params["force_destroy"] = false } + return nil } }) @@ -73,11 +74,12 @@ func Configure(p *config.Provider) { r.LateInitializer = config.LateInitializer{ IgnoredFields: []string{"etag", "kms_key_id"}, } - r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) { + r.TerraformConfigurationInjector = func(jsonMap map[string]any, params map[string]any) error { // TODO: Has better be implemented via defaulting. if _, ok := jsonMap["acl"]; !ok { params["acl"] = "private" } + return nil } }) diff --git a/config/secretsmanager/config.go b/config/secretsmanager/config.go index 0c0ddb7e63..d4c69eb9f2 100644 --- a/config/secretsmanager/config.go +++ b/config/secretsmanager/config.go @@ -19,8 +19,9 @@ func Configure(p *config.Provider) { //nolint:gocyclo // aws_secretsmanager_secret_policy. config.MoveToStatus(r.TerraformResource, "policy") // TODO: we had better do this for all resources... - r.TerraformConfigurationInjector = func(_ map[string]any, params map[string]any) { + r.TerraformConfigurationInjector = func(_ map[string]any, params map[string]any) error { params["name_prefix"] = "" + return nil } r.TerraformCustomDiff = func(diff *terraform.InstanceDiff, state *terraform.InstanceState, config *terraform.ResourceConfig) (*terraform.InstanceDiff, error) { // skip diff customization on create diff --git a/go.mod b/go.mod index cc07551a42..008c135e56 100644 --- a/go.mod +++ b/go.mod @@ -276,3 +276,5 @@ replace golang.org/x/exp => golang.org/x/exp v0.0.0-20231006140011-7918f672742d replace github.com/hashicorp/terraform-provider-aws => github.com/upbound/terraform-provider-aws v0.0.0-20240129145938-c69f68a59916 replace github.com/hashicorp/terraform-plugin-log => github.com/gdavison/terraform-plugin-log v0.0.0-20230928191232-6c653d8ef8fb + +replace github.com/crossplane/upjet => github.com/ulucinar/upbound-upjet v0.0.0-20240214143445-13e9fc05f724 diff --git a/go.sum b/go.sum index 042416b374..155d138d11 100644 --- a/go.sum +++ b/go.sum @@ -267,8 +267,6 @@ github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a2f5/go.mod h1:pgt7PaTvvOQz3jILyxbCaeleU9MrAqKaNoPJavhGBgM= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 h1:HigXs5tEQxWz0fcj8hzbU2UAZgEM7wPe0XRFOsrtF8Y= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79/go.mod h1:+e4OaFlOcmr0JvINHl/yvEYBrZawzTgj6pQumOH1SS0= -github.com/crossplane/upjet v1.1.0 h1:jfdag6qaF1/5mvlDT/8LdTc/vq1Iq0ASnmk3yV86I9U= -github.com/crossplane/upjet v1.1.0/go.mod h1:0bHLtnejZ9bDeyXuBb9MSOQLvKo3+aoTeUBO8N0dGSA= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw= @@ -556,6 +554,8 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tmccombs/hcl2json v0.3.3 h1:+DLNYqpWE0CsOQiEZu+OZm5ZBImake3wtITYxQ8uLFQ= github.com/tmccombs/hcl2json v0.3.3/go.mod h1:Y2chtz2x9bAeRTvSibVRVgbLJhLJXKlUeIvjeVdnm4w= +github.com/ulucinar/upbound-upjet v0.0.0-20240214143445-13e9fc05f724 h1:qyX60TlNmvOZFIScwBpDWn8yJ/3+gXs/xJA3E9ukz5Q= +github.com/ulucinar/upbound-upjet v0.0.0-20240214143445-13e9fc05f724/go.mod h1:0bHLtnejZ9bDeyXuBb9MSOQLvKo3+aoTeUBO8N0dGSA= github.com/upbound/terraform-provider-aws v0.0.0-20240129145938-c69f68a59916 h1:W3WAB6utkebXviDpnym5bWaQtqASXeudJ7bu7v9CJA4= github.com/upbound/terraform-provider-aws v0.0.0-20240129145938-c69f68a59916/go.mod h1:Kb86v3lyFUggXmDTi53PPHLENdWUdD8t3IfjS7rFd+0= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= From d6a0a3127b04b0df3c03ec9410cf2878041c5bd3 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 14 Feb 2024 20:20:39 +0300 Subject: [PATCH 2/3] Bump uptest to v0.11.0 - Disable the import test for examples/s3/v1beta1/object.yaml Please see: https://github.com/upbound/provider-aws/issues/978 Signed-off-by: Alper Rifat Ulucinar --- Makefile | 2 +- examples/s3/v1beta1/object.yaml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 81164f0928..bb9bc1ae5b 100644 --- a/Makefile +++ b/Makefile @@ -65,7 +65,7 @@ export SUBPACKAGES := $(SUBPACKAGES) KIND_VERSION = v0.21.0 UP_VERSION = v0.20.0 UP_CHANNEL = stable -UPTEST_VERSION = v0.8.0 +UPTEST_VERSION = v0.11.0 KUSTOMIZE_VERSION = v5.3.0 YQ_VERSION = v4.40.5 diff --git a/examples/s3/v1beta1/object.yaml b/examples/s3/v1beta1/object.yaml index c8ba9e0cf8..ceb18387b2 100644 --- a/examples/s3/v1beta1/object.yaml +++ b/examples/s3/v1beta1/object.yaml @@ -3,6 +3,7 @@ kind: Object metadata: annotations: meta.upbound.io/example-id: s3/v1beta1/object + uptest.upbound.io/disable-import: "true" labels: testing.upbound.io/example-name: object name: example-object From f627d53dbfd5ceec23c5f6191f90d34f3a7e8dc0 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Wed, 14 Feb 2024 20:43:42 +0300 Subject: [PATCH 3/3] Bump upjet to commit 780c97fac125 - Consumes the config.ConfigurationInjector signature change Signed-off-by: Alper Rifat Ulucinar --- go.mod | 4 +--- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 008c135e56..88e40fede9 100644 --- a/go.mod +++ b/go.mod @@ -12,7 +12,7 @@ require ( github.com/aws/smithy-go v1.19.0 github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a2f5 github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 - github.com/crossplane/upjet v1.1.0 + github.com/crossplane/upjet v1.2.0-rc.0.0.20240214173902-780c97fac125 github.com/go-ini/ini v1.46.0 github.com/google/go-cmp v0.6.0 github.com/hashicorp/terraform-json v0.18.0 @@ -276,5 +276,3 @@ replace golang.org/x/exp => golang.org/x/exp v0.0.0-20231006140011-7918f672742d replace github.com/hashicorp/terraform-provider-aws => github.com/upbound/terraform-provider-aws v0.0.0-20240129145938-c69f68a59916 replace github.com/hashicorp/terraform-plugin-log => github.com/gdavison/terraform-plugin-log v0.0.0-20230928191232-6c653d8ef8fb - -replace github.com/crossplane/upjet => github.com/ulucinar/upbound-upjet v0.0.0-20240214143445-13e9fc05f724 diff --git a/go.sum b/go.sum index 155d138d11..c603a8b42b 100644 --- a/go.sum +++ b/go.sum @@ -267,6 +267,8 @@ github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a github.com/crossplane/crossplane-runtime v1.15.0-rc.0.0.20231215091746-d23a82b3a2f5/go.mod h1:pgt7PaTvvOQz3jILyxbCaeleU9MrAqKaNoPJavhGBgM= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79 h1:HigXs5tEQxWz0fcj8hzbU2UAZgEM7wPe0XRFOsrtF8Y= github.com/crossplane/crossplane-tools v0.0.0-20230925130601-628280f8bf79/go.mod h1:+e4OaFlOcmr0JvINHl/yvEYBrZawzTgj6pQumOH1SS0= +github.com/crossplane/upjet v1.2.0-rc.0.0.20240214173902-780c97fac125 h1:2ueKn/H9L4LW6tkt0C5+5Ryf4hX0mxiIIucaF/Xr668= +github.com/crossplane/upjet v1.2.0-rc.0.0.20240214173902-780c97fac125/go.mod h1:0bHLtnejZ9bDeyXuBb9MSOQLvKo3+aoTeUBO8N0dGSA= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= github.com/dave/jennifer v1.4.1 h1:XyqG6cn5RQsTj3qlWQTKlRGAyrTcsk1kUmWdZBzRjDw= @@ -554,8 +556,6 @@ github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcU github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/tmccombs/hcl2json v0.3.3 h1:+DLNYqpWE0CsOQiEZu+OZm5ZBImake3wtITYxQ8uLFQ= github.com/tmccombs/hcl2json v0.3.3/go.mod h1:Y2chtz2x9bAeRTvSibVRVgbLJhLJXKlUeIvjeVdnm4w= -github.com/ulucinar/upbound-upjet v0.0.0-20240214143445-13e9fc05f724 h1:qyX60TlNmvOZFIScwBpDWn8yJ/3+gXs/xJA3E9ukz5Q= -github.com/ulucinar/upbound-upjet v0.0.0-20240214143445-13e9fc05f724/go.mod h1:0bHLtnejZ9bDeyXuBb9MSOQLvKo3+aoTeUBO8N0dGSA= github.com/upbound/terraform-provider-aws v0.0.0-20240129145938-c69f68a59916 h1:W3WAB6utkebXviDpnym5bWaQtqASXeudJ7bu7v9CJA4= github.com/upbound/terraform-provider-aws v0.0.0-20240129145938-c69f68a59916/go.mod h1:Kb86v3lyFUggXmDTi53PPHLENdWUdD8t3IfjS7rFd+0= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=