Skip to content

Commit

Permalink
Use regex to filter out unstable release versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Richard Cane committed Sep 20, 2019
1 parent 900a60d commit 97e6011
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions cmd/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ import (
"log"
"net/http"
"os"
"regexp"
"strings"
"time"

"github.com/spf13/cobra"
)
Expand All @@ -37,7 +39,8 @@ var (
)

type kubectlVersion struct {
TagName string `json:"tag_name"`
TagName string `json:"tag_name"`
PublishedAt time.Time `json:"published_at"`
}

var listCmd = &cobra.Command{
Expand All @@ -58,21 +61,11 @@ 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 {
// only show stable releases
filterStable := strings.NewReplacer(
"-rc.1", "",
"-beta.2", "",
"-beta.1", "",
"-alpha.3", "",
"-alpha.2", "",
"-alpha.1", "",
"-rc.2", "",
"-rc.3", "",
)
stable := filterStable.Replace(version.TagName)

fmt.Println(stable)
if !re.MatchString(version.TagName) {
fmt.Println(version.TagName)
}
}
},
}
Expand Down

0 comments on commit 97e6011

Please sign in to comment.