@@ -2,6 +2,7 @@ package container
22
33import (
44 "context"
5+ "strings"
56
67 "github.com/alexedwards/argon2id"
78 "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -76,7 +77,25 @@ func ResourceNamespace() *schema.Resource {
7677 },
7778 ValidateDiagFunc : validation .MapKeyLenBetween (0 , 100 ),
7879 DiffSuppressFunc : func (k , oldValue , newValue string , d * schema.ResourceData ) bool {
79- match , _ := argon2id .ComparePasswordAndHash (oldValue , newValue )
80+ secretKey := strings .TrimPrefix (k , "secret_environment_variables." )
81+ if secretKey == "" || secretKey == "%" {
82+ return false
83+ }
84+
85+ match , _ := argon2id .ComparePasswordAndHash (newValue , oldValue )
86+
87+ // If values match, we can store the correct value in state
88+ // This has impact when we import a namespace with secrets, check container_test.TestAccNamespace_ImportWithSecrets
89+ if match {
90+ secrets := expandContainerSecrets (d .Get ("secret_environment_variables" ))
91+ for _ , secret := range secrets {
92+ if secret .Key == secretKey {
93+ secret .Value = scw .StringPtr (newValue )
94+ }
95+ }
96+ _ = d .Set ("secret_environment_variables" , flattenContainerSecretEnvironmentVariables (secrets ))
97+ }
98+
8099 return match
81100 },
82101 },
0 commit comments