diff --git a/helm-framework/helm/resource_helm_release.go b/helm-framework/helm/resource_helm_release.go index 670928594..74ba3ec01 100644 --- a/helm-framework/helm/resource_helm_release.go +++ b/helm-framework/helm/resource_helm_release.go @@ -41,10 +41,9 @@ import ( ) var ( - _ resource.Resource = &HelmRelease{} - _ resource.ResourceWithUpgradeState = &HelmRelease{} - _ resource.ResourceWithModifyPlan = &HelmRelease{} - _ resource.ResourceWithImportState = &HelmRelease{} + _ resource.Resource = &HelmRelease{} + _ resource.ResourceWithModifyPlan = &HelmRelease{} + _ resource.ResourceWithImportState = &HelmRelease{} ) type HelmRelease struct { @@ -590,7 +589,6 @@ func (r *HelmRelease) Schema(ctx context.Context, req resource.SchemaRequest, re }, }, }, - // Indicating schema has undergone changes Version: 1, } } @@ -614,35 +612,6 @@ func (r *HelmRelease) Configure(ctx context.Context, req resource.ConfigureReque r.meta = meta } -// maps version 0 state to the upgrade function. -// If terraform detects data with version 0, we call upgrade to upgrade the state to the current schema version "1" -func (r *HelmRelease) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader { - return map[int64]resource.StateUpgrader{ - 0: { - StateUpgrader: stateUpgradeV0toV1, - }, - } -} - -func stateUpgradeV0toV1(ctx context.Context, req resource.UpgradeStateRequest, resp *resource.UpgradeStateResponse) { - var priorState map[string]interface{} - diags := req.State.Get(ctx, &priorState) - resp.Diagnostics.Append(diags...) - if resp.Diagnostics.HasError() { - return - } - - if priorState["pass_credentials"] == nil { - priorState["pass_credentials"] = false - } - if priorState["wait_for_jobs"] == nil { - priorState["wait_for_jobs"] = false - } - - diags = resp.State.Set(ctx, priorState) - resp.Diagnostics.Append(diags...) -} - const sensitiveContentValue = "(sensitive value)" func cloakSetValue(values map[string]interface{}, valuePath string) { @@ -1664,19 +1633,6 @@ func checkChartDependencies(ctx context.Context, model *HelmReleaseModel, c *cha return false, diags } -func (r *HelmRelease) StateUpgrade(ctx context.Context, version int, state map[string]interface{}, meta interface{}) (map[string]interface{}, diag.Diagnostics) { - var diags diag.Diagnostics - - if state["pass_credentials"] == nil { - state["pass_credentials"] = false - } - if state["wait_for_jobs"] == nil { - state["wait_for_jobs"] = false - } - - return state, diags -} - func (r *HelmRelease) ModifyPlan(ctx context.Context, req resource.ModifyPlanRequest, resp *resource.ModifyPlanResponse) { if req.Plan.Raw.IsNull() { // resource is being destroyed diff --git a/helm-framework/helm/resource_helm_release_test.go b/helm-framework/helm/resource_helm_release_test.go index 8eb50525e..491605cf1 100644 --- a/helm-framework/helm/resource_helm_release_test.go +++ b/helm-framework/helm/resource_helm_release_test.go @@ -2098,31 +2098,6 @@ func removeSubcharts(chartName string) error { return os.RemoveAll(chartsPath) } -// func TestResourceExampleInstanceStateUpgradeV0(t *testing.T) { -// expected := map[string]any{ -// "wait_for_jobs": false, -// "pass_credentials": false, -// } -// states := []map[string]any{ -// { -// "wait_for_jobs": nil, -// "pass_credentials": nil, -// }, -// {}, -// } - -// for _, state := range states { -// actual, err := stateUpgradeV0toV1(context.Background(), state, nil) -// if err != nil { -// t.Fatalf("error migrating state: %s", err) -// } - -// if !reflect.DeepEqual(expected, actual) { -// t.Fatalf("\n\nexpected:\n\n%#v\n\ngot:\n\n%#v\n\n", expected, actual) -// } -// } -// } - func testAccHelmReleaseSetListValues(resource, ns, name string) string { return fmt.Sprintf(` resource "helm_release" "%s" {