Skip to content

Commit

Permalink
Add versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
gkze committed May 10, 2020
1 parent dfac5e0 commit 00e0b0d
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
8 changes: 4 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ brews:
github:
name: homebrew-gkze
owner: gkze
homepage: "https://github.com/gkze/roles"
test: "system \"#{bin}/role -v\""
homepage: "https://github.com/gkze/awssume"
test: "system \"#{bin}/awssume -v\""
builds:
- binary: role
- binary: awssume
env:
- GO111MODULE=on
- CGO_ENABLED=0
goarch:
- amd64
ldflags:
- -X main.Version={{ .Version }}
main: "./cmd/role/role.go"
main: "./cmd/awssume/awssume.go"
changelog:
filters:
exclude:
Expand Down
1 change: 1 addition & 0 deletions VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.0.0
20 changes: 17 additions & 3 deletions cmd/awssume/awssume.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ import (
// errCurrentUser is returned when the current used cannot be determined
const errCurrentUser string = "error determining current user: %w"

// errTooFewArguments is returned when there are not enough arguments passed
var errTooFewArguments error = errors.New("not enough arguments provided")
var (
// errTooFewArguments is returned when there are not enough arguments passed
errTooFewArguments error = errors.New("not enough arguments provided")

// Version is dynamically injected at build time
Version string
)

func main() {
rootCmd := cobra.Command{
Expand All @@ -33,6 +38,15 @@ func main() {
},
}

versionCmd := &cobra.Command{
Use: "version",
Short: "Display awssume version",
RunE: func(cmd *cobra.Command, args []string) error {
fmt.Printf("awssume version %s\n", Version)
return nil
},
}

listCmd := &cobra.Command{
Use: "list",
Aliases: []string{"l", "ls"},
Expand Down Expand Up @@ -198,7 +212,7 @@ func main() {
"The duration of the STS Session when the Role is assumed",
)

rootCmd.AddCommand(listCmd, convertCmd, addCmd, execCmd)
rootCmd.AddCommand(versionCmd, listCmd, convertCmd, addCmd, execCmd)

if err := rootCmd.Execute(); err != nil {
fmt.Println(err)
Expand Down

0 comments on commit 00e0b0d

Please sign in to comment.