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

version: Detect special running Cilium versions #651

Merged
merged 1 commit into from
Dec 9, 2021
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
8 changes: 8 additions & 0 deletions internal/k8s/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,14 @@ func (c *Client) GetRunningCiliumVersion(ctx context.Context, namespace string)
if digest := strings.Index(v, "@"); digest > 0 {
v = v[:digest]
}
// Add any part in the pod image separated by a '-` to the version,
// e.g., "quay.io/cilium/cilium-ci:1234" -> "-ci:1234"
base := strings.Split(version[0], "/")
last := base[len(base)-1]
dash := strings.Index(last, "-")
if dash >= 0 {
v = last[dash:] + ":" + v
}
return v, nil
}
return "", errors.New("unable to obtain cilium version: no cilium pods found")
Expand Down
4 changes: 4 additions & 0 deletions internal/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ func BuildImagePath(userImage, defaultImage, userVersion, defaultVersion string)
if userImage == "" {
switch {
case userVersion == "":
// ':' in defaultVersion?
if strings.Contains(defaultVersion, ":") {
return defaultImage + defaultVersion
}
return defaultImage + ":" + defaultVersion
case strings.Contains(userVersion, ":"):
// userVersion already contains the colon. Useful for ":latest",
Expand Down