Skip to content

Commit

Permalink
List supported k8s versions in eksctl version (#2126)
Browse files Browse the repository at this point in the history
List Supported K8s Versions in `eksctl version`

This change was made to list the EKS Server Supported Versions. Added the functionality for eksctl version command to show the EKS server supported versions in a new line.

Issue #2040
  • Loading branch information
smrutiranjantripathy authored May 12, 2020
1 parent 9ba4485 commit 0a04736
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/eksctl/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func versionCmd(_ *cmdutils.FlagGrouping) *cobra.Command {
case "":
fmt.Printf("%s\n", version.GetVersion())
case "json":
fmt.Printf("%#v\n", version.GetVersionInfo())
fmt.Printf("%s\n", version.String())
default:
return fmt.Errorf("unknown output: %s", output)
}
Expand Down
10 changes: 7 additions & 3 deletions pkg/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,18 @@ import (
"encoding/json"
"fmt"
"strings"

"github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
)

//go:generate go run ./release_generate.go

// Info holds version information
type Info struct {
Version string
PreReleaseID string
Metadata BuildMetadata
Version string
PreReleaseID string
Metadata BuildMetadata
EKSServerSupportedVersions []string
}

// BuildMetadata contains the semver build metadata:
Expand All @@ -31,6 +34,7 @@ func GetVersionInfo() Info {
GitCommit: gitCommit,
BuildDate: buildDate,
},
EKSServerSupportedVersions: v1alpha5.SupportedVersions(),
}
}

Expand Down
18 changes: 12 additions & 6 deletions pkg/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package version
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/weaveworks/eksctl/pkg/apis/eksctl.io/v1alpha5"
)

var _ = Describe("release tests", func() {
Expand All @@ -19,9 +20,10 @@ var _ = Describe("release tests", func() {

Expect(v).To(Equal("0.5.0"))
Expect(info).To(Equal(Info{
Version: "0.5.0",
PreReleaseID: "",
Metadata: BuildMetadata{},
Version: "0.5.0",
PreReleaseID: "",
Metadata: BuildMetadata{},
EKSServerSupportedVersions: v1alpha5.SupportedVersions(),
}))
})

Expand All @@ -42,6 +44,7 @@ var _ = Describe("release tests", func() {
GitCommit: "abc123",
BuildDate: "today",
},
EKSServerSupportedVersions: v1alpha5.SupportedVersions(),
}))
})

Expand All @@ -61,6 +64,7 @@ var _ = Describe("release tests", func() {
GitCommit: "abc123",
BuildDate: "today",
},
EKSServerSupportedVersions: v1alpha5.SupportedVersions(),
}))
})

Expand All @@ -80,6 +84,7 @@ var _ = Describe("release tests", func() {
GitCommit: "abc1234",
BuildDate: "2020-01-15T14:03:46Z",
},
EKSServerSupportedVersions: v1alpha5.SupportedVersions(),
}))
})

Expand All @@ -91,9 +96,10 @@ var _ = Describe("release tests", func() {

Expect(v).To(Equal("0.5.0-dev"))
Expect(info).To(Equal(Info{
Version: "0.5.0",
PreReleaseID: "dev",
Metadata: BuildMetadata{},
Version: "0.5.0",
PreReleaseID: "dev",
Metadata: BuildMetadata{},
EKSServerSupportedVersions: v1alpha5.SupportedVersions(),
}))
})

Expand Down

0 comments on commit 0a04736

Please sign in to comment.