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

honor Talos version string when creating clusters #353

Merged
merged 1 commit into from
Oct 21, 2024
Merged
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
12 changes: 6 additions & 6 deletions civo/kubernetes/resource_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ func customizeDiffKubernetesCluster(ctx context.Context, d *schema.ResourceDiff,
if kubeVersion, ok := d.GetOk("kubernetes_version"); ok {
version := kubeVersion.(string)
var k3sVersionRegex = regexp.MustCompile(`^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)-k3s\d$`)
var talosVersionRegex = regexp.MustCompile(`^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`)
var talosVersionRegex = regexp.MustCompile(`^talos-v(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$`)

clusterType := "k3s" // Default
attr, ok := d.GetOk("cluster_type")
Expand All @@ -543,9 +543,9 @@ func customizeDiffKubernetesCluster(ctx context.Context, d *schema.ResourceDiff,
if kv.ClusterType == clusterType {
switch kv.Type {
case "stable":
stableVersions = append(stableVersions, kv.Version)
stableVersions = append(stableVersions, kv.Label)
case "development":
developmentVersions = append(developmentVersions, kv.Version)
developmentVersions = append(developmentVersions, kv.Label)
}
}
}
Expand All @@ -564,9 +564,9 @@ func customizeDiffKubernetesCluster(ctx context.Context, d *schema.ResourceDiff,
isValidVersion = talosVersionRegex.MatchString(version)
if !isValidVersion {
return fmt.Errorf("invalid Kubernetes version format: '%s' for cluster type '%s'.\n\n"+
"Please ensure your version matches the expected format, e.g., 'X.Y.Z'.\n\n"+
"Available versions for '%s':\n- Stable: %v",
version, clusterType, clusterType, stableVersions)
"Please ensure your version matches the expected format, e.g., 'talos-vX.Y.Z'.\n\n"+
"Available versions for '%s':\n- Stable: %v\n- Development: %v",
version, clusterType, clusterType, stableVersions, developmentVersions)
}
}
}
Expand Down
Loading