From b8880d052f6a74ab001aa3b1ab39a3dd69a7a392 Mon Sep 17 00:00:00 2001 From: Bianca Del Carretto Date: Thu, 16 May 2024 12:38:25 +0200 Subject: [PATCH] fix: set secret refs always if no value is specified --- internal/provider/resource_definition_resource.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/internal/provider/resource_definition_resource.go b/internal/provider/resource_definition_resource.go index ae4d226..94b2c90 100644 --- a/internal/provider/resource_definition_resource.go +++ b/internal/provider/resource_definition_resource.go @@ -4,6 +4,7 @@ import ( "context" "encoding/json" "fmt" + "strings" "time" "github.com/hashicorp/terraform-plugin-framework-timeouts/resource/timeouts" @@ -255,15 +256,17 @@ func parseResourceDefinitionResponse(ctx context.Context, driverInputSchema map[ data.DriverInputs.ValuesString = types.StringValue(string(b)) } - if data.DriverInputs != nil && data.DriverInputs.SecretRefs.IsUnknown() { + if data.DriverInputs != nil { if driverInputs.SecretRefs == nil { data.DriverInputs.SecretRefs = types.StringNull() } else { - b, err := json.Marshal(driverInputs.SecretRefs) - if err != nil { - diags.AddError(HUM_API_ERR, fmt.Sprintf("Failed to marshal secret_refs: %s", err.Error())) + if !strings.Contains(data.DriverInputs.SecretRefs.ValueString(), `{"value":"`) { + b, err := json.Marshal(driverInputs.SecretRefs) + if err != nil { + diags.AddError(HUM_API_ERR, fmt.Sprintf("Failed to marshal secret_refs: %s", err.Error())) + } + data.DriverInputs.SecretRefs = types.StringValue(string(b)) } - data.DriverInputs.SecretRefs = types.StringValue(string(b)) } } return diags