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
3 changes: 3 additions & 0 deletions .changelog/1633.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
`helm_release`: Add `UpgradeState` logic to support migration from SDKv2 to Plugin Framework
```
23 changes: 17 additions & 6 deletions helm/resource_helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ import (
)

var (
_ resource.Resource = &HelmRelease{}
_ resource.ResourceWithModifyPlan = &HelmRelease{}
_ resource.ResourceWithImportState = &HelmRelease{}
_ resource.ResourceWithIdentity = &HelmRelease{}
_ resource.Resource = &HelmRelease{}
_ resource.ResourceWithModifyPlan = &HelmRelease{}
_ resource.ResourceWithImportState = &HelmRelease{}
_ resource.ResourceWithIdentity = &HelmRelease{}
_ resource.ResourceWithUpgradeState = &HelmRelease{}
)

type HelmRelease struct {
Expand Down Expand Up @@ -149,6 +150,7 @@ type releaseMetaData struct {
Values types.String `tfsdk:"values"`
FirstDeployed types.Int64 `tfsdk:"first_deployed"`
LastDeployed types.Int64 `tfsdk:"last_deployed"`
Notes types.String `tfsdk:"notes"`
}
type setResourceModel struct {
Name types.String `tfsdk:"name"`
Expand Down Expand Up @@ -257,6 +259,9 @@ func (r *HelmRelease) Metadata(ctx context.Context, req resource.MetadataRequest
resp.TypeName = req.ProviderTypeName + "_release"
}

func (r *HelmRelease) UpgradeState(ctx context.Context) map[int64]resource.StateUpgrader {
return r.buildUpgradeStateMap(ctx)
}
func (r *HelmRelease) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Description: "Schema to define attributes that are available in the resource",
Expand Down Expand Up @@ -381,6 +386,10 @@ func (r *HelmRelease) Schema(ctx context.Context, req resource.SchemaRequest, re
Computed: true,
Description: "Namespace is the kubernetes namespace of the release",
},
"notes": schema.StringAttribute{
Computed: true,
Description: "Notes is the description of the deployed release, rendered from templates.",
},
"revision": schema.Int64Attribute{
Computed: true,
Description: "Version is an int32 which represents the version of the release",
Expand Down Expand Up @@ -625,13 +634,13 @@ func (r *HelmRelease) Schema(ctx context.Context, req resource.SchemaRequest, re
},
},
},
Version: 1,
Version: 2,
}
}

func (r *HelmRelease) IdentitySchema(ctx context.Context, req resource.IdentitySchemaRequest, resp *resource.IdentitySchemaResponse) {
resp.IdentitySchema = identityschema.Schema{
Version: 1,
Version: 0,
Attributes: map[string]identityschema.Attribute{
"namespace": identityschema.StringAttribute{
// use "default" if not specified
Expand Down Expand Up @@ -1558,6 +1567,7 @@ func setReleaseAttributes(ctx context.Context, state *HelmReleaseModel, identity
"values": valuesstr,
"first_deployed": types.Int64Value(r.Info.FirstDeployed.Unix()),
"last_deployed": types.Int64Value(r.Info.LastDeployed.Unix()),
"notes": types.StringValue(r.Info.Notes),
}

// Convert the list of ObjectValues to a ListValue
Expand Down Expand Up @@ -1589,6 +1599,7 @@ func metadataAttrTypes() map[string]attr.Type {
"values": types.StringType,
"first_deployed": types.Int64Type,
"last_deployed": types.Int64Type,
"notes": types.StringType,
}
}

Expand Down
Loading
Loading