Skip to content

Commit

Permalink
honor Talos version string when creating clusters
Browse files Browse the repository at this point in the history
  • Loading branch information
Praveen005 committed Oct 17, 2024
1 parent ebd1997 commit 596c1c4
Showing 1 changed file with 6 additions and 6 deletions.
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

0 comments on commit 596c1c4

Please sign in to comment.