From 156111739c375d95db8b8df4ceac2506f572edb4 Mon Sep 17 00:00:00 2001 From: Aniruddha Basak Date: Mon, 24 Jun 2024 09:49:23 +0200 Subject: [PATCH] Use semver version in cluster stack status - clusterstack.status.latestRelease & clusterstack.status.usableVersion use semver ("." notation) Signed-off-by: Aniruddha Basak --- internal/controller/clusterstack_controller.go | 6 +++--- pkg/clusterstack/clusterstack.go | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/controller/clusterstack_controller.go b/internal/controller/clusterstack_controller.go index 8e01967d1..6a83fab53 100644 --- a/internal/controller/clusterstack_controller.go +++ b/internal/controller/clusterstack_controller.go @@ -517,7 +517,7 @@ func getLatestReadyClusterStackRelease(clusterStackReleases []*csov1alpha1.Clust return nil, "", fmt.Errorf("failed to get clusterstack from ClusterStackRelease.Name %q: %w", csr.Name, err) } clusterStackObjects = append(clusterStackObjects, cs) - mapKubernetesVersions[cs.String()] = csr.Status.KubernetesVersion + mapKubernetesVersions[cs.StringWithDot()] = csr.Status.KubernetesVersion } } @@ -530,7 +530,7 @@ func getLatestReadyClusterStackRelease(clusterStackReleases []*csov1alpha1.Clust sort.Sort((clusterStackObjects)) // return the latest one - cs := clusterStackObjects[len(clusterStackObjects)-1].String() + cs := clusterStackObjects[len(clusterStackObjects)-1].StringWithDot() latest = &cs k8sversion = mapKubernetesVersions[*latest] return latest, k8sversion, nil @@ -606,7 +606,7 @@ func getUsableClusterStackReleaseVersions(clusterStackReleases []*csov1alpha1.Cl return nil, fmt.Errorf("failed to construct version from ClusterStackRelease.Name %q: %w", csr.Name, err) } - usableVersions = append(usableVersions, v.String()) + usableVersions = append(usableVersions, v.StringWithDot()) } } return usableVersions, nil diff --git a/pkg/clusterstack/clusterstack.go b/pkg/clusterstack/clusterstack.go index 37cead134..47f5b99e9 100644 --- a/pkg/clusterstack/clusterstack.go +++ b/pkg/clusterstack/clusterstack.go @@ -198,7 +198,14 @@ func (cs *ClusterStack) Validate() error { return nil } +// String returns cluster stack with "-" notation. func (cs *ClusterStack) String() string { // release tag: myprovider-myclusterstack-1-26-v1 return strings.Join([]string{cs.Provider, cs.Name, cs.KubernetesVersion.String(), cs.Version.String()}, Separator) } + +// StringWithDot returns cluster stack with semver "." notation. +func (cs *ClusterStack) StringWithDot() string { + // release tag: myprovider-myclusterstack-1-26-v0-sha.hd237u2 + return strings.Join([]string{cs.Provider, cs.Name, cs.KubernetesVersion.String(), cs.Version.StringWithDot()}, Separator) +}