Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make gsk release validation for gs tf provider v2 clearer #408

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 1 addition & 13 deletions gridscale/resource_gridscale_k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,10 @@ func (rgk8sv *ResourceGridscaleK8sValidator) checkIfTemplateSupportsMultiNodePoo
k8sMultiNodePoolSupportRelease,
)
templateRelease, err := NewRelease(template.Properties.Release)

if err != nil {
return fmt.Errorf("%s error: %v", errorPrefix, err)
}
multiNodePoolSupportRelease, err := NewRelease(k8sMultiNodePoolSupportRelease)

if err != nil {
return fmt.Errorf("%s error: %v", errorPrefix, err)
}
err = templateRelease.CheckIfFeatureIsKnown(
&Feature{
Description: "multi node pool support",
Release: *multiNodePoolSupportRelease,
},
)
return err
return templateRelease.CheckIfK8SReleaseIsSupported()
}

// buildInputSchema models the k8s resource's input schema by ResourceGridscaleK8sModeler receiver.
Expand Down
12 changes: 12 additions & 0 deletions gridscale/resource_gridscale_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ type Feature struct {
Release
}

const supportedK8SRelease = "1.30"

// NewRelease creates a new Release instance.
func NewRelease(representation string) (*Release, error) {
version, err := goVersion.NewVersion(representation)
Expand All @@ -36,3 +38,13 @@ func (r *Release) CheckIfFeatureIsKnown(f *Feature) error {
}
return nil
}

// CheckIfK8SReleaseIsSupported checks if the Kubernetes release is supported by this gridscale terraform provider.
func (r *Release) CheckIfK8SReleaseIsSupported() error {
if r.LessThan(goVersion.Must(goVersion.NewVersion(supportedK8SRelease))) {
return &ReleaseFeatureIncompatibilityError{
Detail: fmt.Sprintf("this gridscale terraform provider version v2 supports only Kubernetes release >= %s, for Kubernetes release %s please use gridscale terraform provider version v1", supportedK8SRelease, r.String()),
}
}
return nil
}
Loading