Skip to content

Commit

Permalink
Fix update k8s resource always trigger upgrade v1 (#412)
Browse files Browse the repository at this point in the history
* Revert "Fix cannot retry upgrade gsk when previous upgrade fails v1 (#410)"

This reverts commit a9def41.

* set the correct gsk version/release at resource read
  • Loading branch information
nvthongswansea authored Jan 7, 2025
1 parent bf63d5b commit 3b1553b
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions gridscale/resource_gridscale_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,18 +374,30 @@ func deriveK8sTemplateFromResourceData(client *gsclient.Client, d *schema.Resour
releaseInterface, isReleaseSet := d.GetOk("release")
release := releaseInterface.(string)

if isVersionSet {
derivationTypesRequested += 1
derivationType = "version"
}
if !d.IsNewResource() { // case if update of resource is requested
if isVersionSet && d.HasChange("version") {
derivationTypesRequested += 1
derivationType = "version"
}

if isReleaseSet {
derivationTypesRequested += 1
derivationType = "release"
}
if isReleaseSet && d.HasChange("release") {
derivationTypesRequested += 1
derivationType = "release"
}
} else { // case if creation of resource is requested
if isVersionSet {
derivationTypesRequested += 1
derivationType = "version"
}

if derivationTypesRequested == 0 {
return nil, errors.New("either \"release\" or \"gsk_version\" has to be defined")
if isReleaseSet {
derivationTypesRequested += 1
derivationType = "release"
}

if derivationTypesRequested == 0 {
return nil, errors.New("either \"release\" or \"gsk_version\" has to be defined")
}
}

if derivationTypesRequested > 1 {
Expand Down

0 comments on commit 3b1553b

Please sign in to comment.