Skip to content

Commit

Permalink
fix hashcorp go-version library usage && acceptance test
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieu prigent committed Sep 29, 2022
1 parent d7f9e6d commit 2854aed
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions ovh/resource_cloud_project_kube.go
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ func resourceCloudProjectKubeUpdate(d *schema.ResourceData, meta interface{}) er
oldValue := oldValueI.(string)
newValue := newValueI.(string)

log.Printf("[DEBUG] cluster version change from %s to %s", oldValue, newValue)

oldVersion, err := version.NewVersion(oldValueI.(string))
if err != nil {
return fmt.Errorf("version %s does not match a semver", oldValue)
Expand All @@ -322,12 +324,13 @@ func resourceCloudProjectKubeUpdate(d *schema.ResourceData, meta interface{}) er
}

oldVersionSegments := oldVersion.Segments()
newVersionSegments := oldVersion.Segments()
newVersionSegments := newVersion.Segments()

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

Expand Down
2 changes: 1 addition & 1 deletion ovh/resource_cloud_project_kube_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ func TestAccCloudProjectKubeUpdateVersion_basic(t *testing.T) {
updatedName := acctest.RandomWithPrefix(test_prefix)

version1 := "1.22"
version2 := "1.22"
version2 := "1.23"

config := fmt.Sprintf(
testAccCloudProjectKubeConfig,
Expand Down

0 comments on commit 2854aed

Please sign in to comment.