Skip to content

Commit

Permalink
Return error when using inactive k8s paas template v1 (#414)
Browse files Browse the repository at this point in the history
* upgrade gsclient-go v3.16.0

* print error when deprecated gsk version is set

* only consider active gsk templates when setting gsk release

* print correct list of active gsk versions
  • Loading branch information
nvthongswansea authored Jan 7, 2025
1 parent 3b1553b commit 50f797d
Show file tree
Hide file tree
Showing 110 changed files with 2,703 additions and 138 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module github.com/terraform-providers/terraform-provider-gridscale

require (
github.com/aws/aws-sdk-go v1.55.5
github.com/gridscale/gsclient-go/v3 v3.14.1
github.com/gridscale/gsclient-go/v3 v3.16.0
github.com/hashicorp/go-version v1.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.34.0
)
Expand Down Expand Up @@ -51,7 +51,7 @@ require (
golang.org/x/crypto v0.23.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/sys v0.29.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/tools v0.13.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gridscale/gsclient-go/v3 v3.14.1 h1:AJkrQuO4TZGxVkZouS1iZ8fZHRqlM97aGFWuGZnkHNE=
github.com/gridscale/gsclient-go/v3 v3.14.1/go.mod h1:0NjkxHexfHQBbmcN03WBF1G4JhZo3Msai50Zcygv+/8=
github.com/gridscale/gsclient-go/v3 v3.16.0 h1:NroV9q8QQn6KIwu4d7qXkvf3Z5YCKtR3rEcYeL9W6+4=
github.com/gridscale/gsclient-go/v3 v3.16.0/go.mod h1:B/xAA91QRonCLb+ScJix4ODj6wHWaDpPwvFHQD2KqsM=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
Expand Down Expand Up @@ -185,8 +185,8 @@ golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.29.0 h1:TPYlXGxvx1MGTn2GiZDhnjPA9wZzZeGKHHmKhHYvgaU=
golang.org/x/sys v0.29.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.20.0 h1:VnkxpohqXaOBYJtBmEppKUG6mXpi+4O6purfc2+sMhw=
Expand Down
11 changes: 9 additions & 2 deletions gridscale/resource_gridscale_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,14 +450,18 @@ func deriveK8sTemplateFromGSKVersion(client *gsclient.Client, version string) (*
}

var derived bool
var isActive bool
var versions []string
var template gsclient.PaaSTemplate

for _, paasTemplate := range paasTemplates {
if paasTemplate.Properties.Flavour == k8sTemplateFlavourName {
versions = append(versions, template.Properties.Version)
if paasTemplate.Properties.Active {
versions = append(versions, template.Properties.Version)
}

if paasTemplate.Properties.Version == version {
isActive = paasTemplate.Properties.Active
derived = true
template = paasTemplate
break
Expand All @@ -468,6 +472,9 @@ func deriveK8sTemplateFromGSKVersion(client *gsclient.Client, version string) (*
if !derived {
return nil, fmt.Errorf("%v is an invalid gridscale Kubernetes (GSK) version. Valid GSK versions are: %v", version, strings.Join(versions, ", "))
}
if !isActive {
return nil, fmt.Errorf("%v is a deprecated gridscale Kubernetes (GSK) version. Valid GSK versions are: %v", version, strings.Join(versions, ", "))
}
return &template, nil
}

Expand Down Expand Up @@ -501,7 +508,7 @@ func deriveK8sTemplateFromRelease(client *gsclient.Client, release, currenTempla
var template gsclient.PaaSTemplate

for _, paasTemplate := range paasTemplates {
if paasTemplate.Properties.Flavour == k8sTemplateFlavourName {
if paasTemplate.Properties.Flavour == k8sTemplateFlavourName && paasTemplate.Properties.Active {
releases = append(releases, paasTemplate.Properties.Release)

if paasTemplate.Properties.Release == release {
Expand Down
17 changes: 17 additions & 0 deletions vendor/github.com/gridscale/gsclient-go/v3/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/gridscale/gsclient-go/v3/config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions vendor/github.com/gridscale/gsclient-go/v3/paas.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 5 additions & 2 deletions vendor/github.com/gridscale/gsclient-go/v3/request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions vendor/github.com/gridscale/gsclient-go/v3/server.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/github.com/gridscale/gsclient-go/v3/usage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/golang.org/x/sys/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions vendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions vendor/golang.org/x/sys/cpu/cpu.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions vendor/golang.org/x/sys/cpu/cpu_arm64.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions vendor/golang.org/x/sys/cpu/cpu_darwin_x86.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/golang.org/x/sys/cpu/cpu_gc_x86.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 0 additions & 6 deletions vendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 50f797d

Please sign in to comment.