From 8d35a8294227cc41406682a1b34428877bf6b1c0 Mon Sep 17 00:00:00 2001 From: Erhan Cagirici Date: Fri, 9 Feb 2024 17:57:00 +0300 Subject: [PATCH 1/2] fix Secret/secretmanager.aws custom diff logic when replica config is empty Signed-off-by: Erhan Cagirici --- config/secretsmanager/config.go | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/config/secretsmanager/config.go b/config/secretsmanager/config.go index 0c0ddb7e63..702090ffcc 100644 --- a/config/secretsmanager/config.go +++ b/config/secretsmanager/config.go @@ -35,13 +35,25 @@ func Configure(p *config.Provider) { //nolint:gocyclo return diff, nil } + resData, err := schema.InternalMap(r.TerraformResource.SchemaMap()).Data(state, diff) + if err != nil { + return nil, errors.New("could not construct resource data") + } + + // do not customize diff if replica field has no change + if !resData.HasChange("replica") { + return diff, nil + } currentReplicaSet, ok := r.TerraformResource.Data(state).Get("replica").(*schema.Set) if !ok { return nil, errors.New("could not read \"replica\" from state") } + nisReplica, ok := config.Get("replica") if !ok { - return nil, errors.New("could not read replica block from config") + // config is empty for replica, no need for custom diff logic + // this is already handled correctly with the built-in diff logic + return diff, nil } desiredReplicaList := nisReplica.([]interface{}) // this is the hash implementation of *schema.Set, which is unexported From 3df0d8de85c8beb87fcec918013f96c9fd088c97 Mon Sep 17 00:00:00 2001 From: Matt Bush Date: Wed, 14 Feb 2024 18:24:34 -0800 Subject: [PATCH 2/2] Add examples with update parameter for secretsmanager secret --- examples/secretsmanager/v1beta1/secret-withreplica.yaml | 2 ++ examples/secretsmanager/v1beta1/secret.yaml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/examples/secretsmanager/v1beta1/secret-withreplica.yaml b/examples/secretsmanager/v1beta1/secret-withreplica.yaml index 9b529c6d26..1742e3163c 100644 --- a/examples/secretsmanager/v1beta1/secret-withreplica.yaml +++ b/examples/secretsmanager/v1beta1/secret-withreplica.yaml @@ -4,11 +4,13 @@ metadata: name: example-withreplica annotations: meta.upbound.io/example-id: secretsmanager/v1beta1/secret + uptest.upbound.io/update-parameter: '{"tags":{"updated-by":"crossplane"}}' labels: testing.upbound.io/example-name: secretsmanager spec: forProvider: name: example-withreplica-${Rand.RFC1123Subdomain} + recoveryWindowInDays: 0 region: us-west-1 replica: - region: us-west-2 diff --git a/examples/secretsmanager/v1beta1/secret.yaml b/examples/secretsmanager/v1beta1/secret.yaml index 655dc856f2..380c30735d 100644 --- a/examples/secretsmanager/v1beta1/secret.yaml +++ b/examples/secretsmanager/v1beta1/secret.yaml @@ -4,9 +4,11 @@ metadata: name: example annotations: meta.upbound.io/example-id: secretsmanager/v1beta1/secret + uptest.upbound.io/update-parameter: '{"tags":{"updated-by":"crossplane"}}' labels: testing.upbound.io/example-name: secretsmanager spec: forProvider: name: example-${Rand.RFC1123Subdomain} region: us-west-1 + recoveryWindowInDays: 0