Skip to content

Commit

Permalink
Add kubectl-neat version command (#67)
Browse files Browse the repository at this point in the history
  • Loading branch information
amirschw authored Jun 5, 2021
1 parent 1f1078b commit f975c89
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ builds:
goarch:
- amd64
- arm64
ldflags:
- -s -w -X github.com/itaysk/kubectl-neat/cmd.Version={{ .Version }}
archives:
- name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
checksum:
Expand Down
15 changes: 15 additions & 0 deletions cmd/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func init() {
rootCmd.SetErr(os.Stderr)
rootCmd.MarkFlagFilename("file")
rootCmd.AddCommand(getCmd)
rootCmd.AddCommand(versionCmd)
}

// Execute is the entry point for the command package
Expand Down Expand Up @@ -127,6 +128,20 @@ kubectl neat get -- svc -n default myservice --output json`,
},
}

// populated by goreleaser
var (
Version = "v0.0.0+unknown"
)

var versionCmd = &cobra.Command{
Use: "version",
Short: "Print kubectl-neat version",
Long: "Print the version of kubectl-neat",
Run: func(cmd *cobra.Command, args []string) {
fmt.Printf("kubectl-neat version: %s\n", Version)
},
}

func isJSON(s []byte) bool {
return bytes.HasPrefix(bytes.TrimLeftFunc(s, unicode.IsSpace), []byte{'{'})
}
Expand Down

0 comments on commit f975c89

Please sign in to comment.