Skip to content

Commit

Permalink
Merge pull request #222 from SovereignCloudStack/ani/issues/221
Browse files Browse the repository at this point in the history
🌱 Use semver version in cluster stack status
  • Loading branch information
janiskemper committed Jun 24, 2024
2 parents 0a1dca1 + 1561117 commit 1073f7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/controller/clusterstack_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions pkg/clusterstack/clusterstack.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

0 comments on commit 1073f7d

Please sign in to comment.