Skip to content

Commit

Permalink
Merge pull request #52 from pluralsh/reinstall-on-host-change
Browse files Browse the repository at this point in the history
Force reinstalls on k8s host changes
  • Loading branch information
michaeljguarino authored Aug 15, 2024
2 parents 4c32b78 + b8eb793 commit 8f28199
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion internal/resource/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ func (r *clusterResource) Update(ctx context.Context, req resource.UpdateRequest
return
}

if !data.HelmRepoUrl.Equal(state.HelmRepoUrl) && data.HasKubeconfig() {
reinstallable := !data.HelmRepoUrl.Equal(state.HelmRepoUrl) || !data.GetKubeconfig().Unchanged(state.GetKubeconfig())

if reinstallable && data.HasKubeconfig() {
clusterWithToken, err := r.client.GetClusterWithToken(ctx, data.Id.ValueStringPointer(), nil)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to fetch cluster deploy token, got error: %s", err))
Expand Down
12 changes: 12 additions & 0 deletions internal/resource/cluster_model.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,3 +255,15 @@ type KubeconfigExec struct {
Env types.Map `tfsdk:"env"`
APIVersion types.String `tfsdk:"api_version"`
}

func (k *Kubeconfig) Unchanged(other *Kubeconfig) bool {
if k == nil {
return other == nil
}

if other == nil {
return false
}

return k.Host == other.Host
}

0 comments on commit 8f28199

Please sign in to comment.