Skip to content

Commit

Permalink
Tidy up import function (#1506)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrhouston authored Oct 23, 2024
1 parent 895ce22 commit 43749a8
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions helm-framework/helm/resource_helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -2022,13 +2022,6 @@ func (r *HelmRelease) ImportState(ctx context.Context, req resource.ImportStateR
return
}

resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("namespace"), namespace)...)
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), name)...)

if resp.Diagnostics.HasError() {
return
}

meta := r.meta
if meta == nil {
resp.Diagnostics.AddError(
Expand Down Expand Up @@ -2057,15 +2050,9 @@ func (r *HelmRelease) ImportState(ctx context.Context, req resource.ImportStateR
}

var state HelmReleaseModel

// Set additional attributes (name, description, chart)
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("name"), release.Name)...)
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("description"), release.Info.Description)...)
resp.Diagnostics.Append(resp.State.SetAttribute(ctx, path.Root("chart"), release.Chart.Metadata.Name)...)

if resp.Diagnostics.HasError() {
return
}
state.Name = types.StringValue(release.Name)
state.Description = types.StringValue(release.Info.Description)
state.Chart = types.StringValue(release.Chart.Metadata.Name)

// Set default attributes
for key, value := range defaultAttributes {
Expand Down

0 comments on commit 43749a8

Please sign in to comment.