Skip to content

Commit

Permalink
rename TagName in version struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Cane committed Sep 20, 2019
1 parent fada3df commit c6731fb
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"regexp"
"sort"
"strings"
"time"

"github.com/hashicorp/go-version"
"github.com/spf13/cobra"
Expand All @@ -41,8 +40,7 @@ var (
)

type kubectlVersion struct {
TagName version.Version
PublishedAt time.Time `json:"published_at"`
Version version.Version
}

func (kc *kubectlVersion) UnmarshalJSON(b []byte) error {
Expand All @@ -61,7 +59,7 @@ func (kc *kubectlVersion) UnmarshalJSON(b []byte) error {
if err != nil {
log.Fatal(err)
}
kc.TagName = *version
kc.Version = *version
return nil
}

Expand All @@ -85,8 +83,8 @@ var listCmd = &cobra.Command{

re := regexp.MustCompile(`-rc.1|-beta.2|-beta.1|-alpha.3|-alpha.2|-alpha.1|-rc.2|-rc.3`)
for _, version := range versions {
if !re.MatchString(version.TagName.String()) {
fmt.Println(version.TagName.Original())
if !re.MatchString(version.Version.String()) {
fmt.Println(version.Version.Original())
}
}
},
Expand Down Expand Up @@ -116,7 +114,7 @@ func fetchLocalVersions() []kubectlVersion {
if err != nil {
log.Fatal(err)
}
list = append(list, kubectlVersion{TagName: *name})
list = append(list, kubectlVersion{Version: *name})
}

return list
Expand All @@ -142,7 +140,7 @@ func fetchRemoteVersions() []kubectlVersion {
}

sort.Slice(list, func(i, j int) bool {
return list[i].TagName.GreaterThan(&list[j].TagName)
return list[i].Version.GreaterThan(&list[j].Version)
})

return list
Expand Down

0 comments on commit c6731fb

Please sign in to comment.