Skip to content

Commit 9c05e82

Browse files
authored
Merge pull request #319 from matprig/kube/fix/update-cluster-version
fix harshicorp go-version library usage && acceptance test
2 parents d7f9e6d + 2854aed commit 9c05e82

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

ovh/resource_cloud_project_kube.go

+5-2
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,8 @@ func resourceCloudProjectKubeUpdate(d *schema.ResourceData, meta interface{}) er
312312
oldValue := oldValueI.(string)
313313
newValue := newValueI.(string)
314314

315+
log.Printf("[DEBUG] cluster version change from %s to %s", oldValue, newValue)
316+
315317
oldVersion, err := version.NewVersion(oldValueI.(string))
316318
if err != nil {
317319
return fmt.Errorf("version %s does not match a semver", oldValue)
@@ -322,12 +324,13 @@ func resourceCloudProjectKubeUpdate(d *schema.ResourceData, meta interface{}) er
322324
}
323325

324326
oldVersionSegments := oldVersion.Segments()
325-
newVersionSegments := oldVersion.Segments()
327+
newVersionSegments := newVersion.Segments()
326328

327329
if oldVersionSegments[0] != 1 || newVersionSegments[0] != 1 {
328330
return fmt.Errorf("the only supported major version is 1")
329331
}
330-
if len(oldVersionSegments) != 2 || len(newVersionSegments) != 2 {
332+
if len(oldVersionSegments) < 2 || len(newVersionSegments) < 2 {
333+
log.Printf("[DEBUG] old version segments: %#v new version segments: %#v", oldVersionSegments, newVersionSegments)
331334
return fmt.Errorf("the version should only specify the major and minor versions (e.g. \\\"1.20\\\")")
332335
}
333336

ovh/resource_cloud_project_kube_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ func TestAccCloudProjectKubeUpdateVersion_basic(t *testing.T) {
446446
updatedName := acctest.RandomWithPrefix(test_prefix)
447447

448448
version1 := "1.22"
449-
version2 := "1.22"
449+
version2 := "1.23"
450450

451451
config := fmt.Sprintf(
452452
testAccCloudProjectKubeConfig,

0 commit comments

Comments
 (0)