Skip to content

Commit e00f486

Browse files
Improve distro inference (#721)
Sometimes the heuristics find ambiguous cluster types, this should help ensure the ambiguity is resolved
1 parent 35ad8ea commit e00f486

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

dockerfiles/harness/ansible.Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ RUN apk add --no-cache \
5656
# install plural cli
5757
ARG TARGETARCH
5858
RUN VERSION=$(curl -sL https://api.github.com/repos/pluralsh/plural-cli/releases/latest | jq -r '.tag_name' | tr -d v) && \
59-
curl -L https://github.com/pluralsh/plural-cli/releases/latest/download/plural-cli_${VERSION}_Linux_${TARGETARCH}.tar.gz \
59+
curl -L https://github.com/pluralsh/plural-cli/releases/download/v${VERSION}/plural-cli_${VERSION}_Linux_${TARGETARCH}.tar.gz \
6060
| tar zx && \
6161
mv plural /usr/local/bin/plural && \
6262
chmod +x /usr/local/bin/plural

pkg/ping/distro.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,29 @@ import (
66
console "github.com/pluralsh/console/go/client"
77
)
88

9+
var (
10+
distroPriorities = map[console.ClusterDistro]int{
11+
console.ClusterDistroEks: 1,
12+
console.ClusterDistroAks: 2,
13+
console.ClusterDistroGke: 3,
14+
console.ClusterDistroRke: 4,
15+
console.ClusterDistroK3s: 5,
16+
console.ClusterDistroOpenshift: 6,
17+
console.ClusterDistroGeneric: 7,
18+
}
19+
)
20+
921
func findDistro(vals []string) console.ClusterDistro {
22+
currentDistro := console.ClusterDistroGeneric
1023
for _, v := range vals {
1124
if dist, ok := distro(v); ok {
12-
return dist
25+
if distroPriorities[dist] <= distroPriorities[currentDistro] {
26+
currentDistro = dist
27+
}
1328
}
1429
}
1530

16-
return console.ClusterDistroGeneric
31+
return currentDistro
1732
}
1833

1934
func distro(val string) (console.ClusterDistro, bool) {

0 commit comments

Comments
 (0)