TritonDataCenter / triton-kubernetes

Kubernetes on Triton
Mozilla Public License 2.0
183 stars 44 forks source link

Append '-rancher1-1' to k8 version option #103

Closed niravpatel27 closed 6 years ago

niravpatel27 commented 6 years ago

@nimajalali

nimajalali commented 6 years ago

I'm not sure what Rancher has in store for naming these in the future.

We've had situations where we need to use a display name while leveraging a different value for the underlying terraform config. Example here

Thoughts on leveraging something like this instead?

var kubernetesVersions = []struct {
    DisplayName string
    Name        string
}{
    {"v1.8.10", "v1.8.10-rancher1-1"},
    {"v1.9.5", "v1.9.5-rancher1-1"},
    {"v1.10.0", "v1.10.0-rancher1-1"},
}

prompt := promptui.Select{
    Label: "Kubernetes Version",
    Items: kubernetesVersions,
    Templates: &promptui.SelectTemplates{
        Label:    "{{ . }}?",
        Active:   fmt.Sprintf(`%s {{ .DisplayName | underline }}`, promptui.IconSelect),
        Inactive: `  {{ .DisplayName }}`,
        Selected: fmt.Sprintf(`{{ "%s" | green }} {{ "Kubernetes Version:" | bold}} {{ .DisplayName }}`, promptui.IconGood),
    },
}

i, _, err := prompt.Run()
if err != nil {
    return baseClusterTerraformConfig{}, err
}

cfg.KubernetesVersion = kubernetesVersions[i].Name
niravpatel27 commented 6 years ago

@nimajalali Good point. I have made changes.

nimajalali commented 6 years ago

:+1: looks good to me