diff --git a/stackit/internal/services/ske/cluster/resource.go b/stackit/internal/services/ske/cluster/resource.go index f6dca5910..3d4e9a594 100644 --- a/stackit/internal/services/ske/cluster/resource.go +++ b/stackit/internal/services/ske/cluster/resource.go @@ -551,7 +551,7 @@ func (r *clusterResource) Schema(_ context.Context, _ resource.SchemaRequest, re Description: "Full OS image version used. For example, if 3815.2 was set in `os_version_min`, this value may result to 3815.2.2. " + SKEUpdateDoc, Computed: true, PlanModifiers: []planmodifier.String{ - stringplanmodifierUtils.UseStateForUnknownIf(stringplanmodifierUtils.StringUnchanged(path.Root("os_version_min")), "sets `UseStateForUnknown` only if `os_version_min` has not changed"), + stringplanmodifierUtils.UseStateForUnknownIf(skeUtils.HasOsVersionMinChanged, "sets `UseStateForUnknown` only if `os_version_min` has not changed"), //nolint:staticcheck // temporary fix for issue with StringUnchanged }, }, "volume_type": schema.StringAttribute{ diff --git a/stackit/internal/services/ske/utils/util.go b/stackit/internal/services/ske/utils/util.go index ef4581caa..6b4aca343 100644 --- a/stackit/internal/services/ske/utils/util.go +++ b/stackit/internal/services/ske/utils/util.go @@ -5,11 +5,14 @@ import ( "fmt" "github.com/hashicorp/terraform-plugin-framework/diag" + "github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier" + "github.com/hashicorp/terraform-plugin-framework/types" "github.com/stackitcloud/stackit-sdk-go/core/config" ske "github.com/stackitcloud/stackit-sdk-go/services/ske/v2api" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" + "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils/planmodifiers/stringplanmodifier" ) func ConfigureClient(ctx context.Context, providerData *core.ProviderData, diags *diag.Diagnostics) *ske.APIClient { @@ -42,3 +45,27 @@ func IsEmptyExtension(extension *ske.Extension) bool { } return false } + +// Deprecated: HasOsVersionMinChanged +func HasOsVersionMinChanged(ctx context.Context, request planmodifier.StringRequest, response *stringplanmodifier.UseStateForUnknownFuncResponse) { // nolint:gocritic // function signature required by Terraform + dependencyPath := request.Path.ParentPath().AtName("os_version_min") + + var minVersionPlan types.String + diags := request.Plan.GetAttribute(ctx, dependencyPath, &minVersionPlan) + response.Diagnostics.Append(diags...) + if response.Diagnostics.HasError() { + return + } + + var minVersionState types.String + diags = request.State.GetAttribute(ctx, dependencyPath, &minVersionState) + response.Diagnostics.Append(diags...) + if response.Diagnostics.HasError() { + return + } + + if minVersionState == minVersionPlan { + response.UseStateForUnknown = true + return + } +}