Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stackit/internal/services/ske/cluster/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
27 changes: 27 additions & 0 deletions stackit/internal/services/ske/utils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
}
Loading