Skip to content

Commit 8f28199

Browse files
Merge pull request #52 from pluralsh/reinstall-on-host-change
Force reinstalls on k8s host changes
2 parents 4c32b78 + b8eb793 commit 8f28199

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

internal/resource/cluster.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,9 @@ func (r *clusterResource) Update(ctx context.Context, req resource.UpdateRequest
129129
return
130130
}
131131

132-
if !data.HelmRepoUrl.Equal(state.HelmRepoUrl) && data.HasKubeconfig() {
132+
reinstallable := !data.HelmRepoUrl.Equal(state.HelmRepoUrl) || !data.GetKubeconfig().Unchanged(state.GetKubeconfig())
133+
134+
if reinstallable && data.HasKubeconfig() {
133135
clusterWithToken, err := r.client.GetClusterWithToken(ctx, data.Id.ValueStringPointer(), nil)
134136
if err != nil {
135137
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Unable to fetch cluster deploy token, got error: %s", err))

internal/resource/cluster_model.go

+12
Original file line numberDiff line numberDiff line change
@@ -255,3 +255,15 @@ type KubeconfigExec struct {
255255
Env types.Map `tfsdk:"env"`
256256
APIVersion types.String `tfsdk:"api_version"`
257257
}
258+
259+
func (k *Kubeconfig) Unchanged(other *Kubeconfig) bool {
260+
if k == nil {
261+
return other == nil
262+
}
263+
264+
if other == nil {
265+
return false
266+
}
267+
268+
return k.Host == other.Host
269+
}

0 commit comments

Comments
 (0)