Skip to content

Commit

Permalink
Add Cobra-based CLI handlers
Browse files Browse the repository at this point in the history
Signed-off-by: Noah Stride <[email protected]>
  • Loading branch information
strideynet committed Oct 16, 2024
1 parent 90b4b92 commit f3af76a
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 2 deletions.
52 changes: 50 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,55 @@
package main

import "fmt"
import (
"fmt"
"os"
"time"

"github.com/spf13/cobra"
)

var (
version = "dev"
)

func main() {
fmt.Println("Hello, World!")
rootCmd := &cobra.Command{
Use: "aws-spiffe-workload-helper",
Short: "TODO", // TODO(strideynet): Helpful, short description.
Long: `TODO`, // TODO(strideynet): Helpful, long description.
Version: version,
}

var (
roleARN string
region string
profileARN string
sessionDuration time.Duration
trustAnchorARN string
roleSessionName string
)
x509CredentialProcessCmd := &cobra.Command{
Use: "x509-credential-process",
Short: "TODO", // TODO(strideynet): Helpful, short description.
Long: `TODO`, // TODO(strideynet): Helpful, long description.
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("Hello, World!")
},
}
rootCmd.AddCommand(x509CredentialProcessCmd)
// TODO(strideynet): Review flag help strings.
x509CredentialProcessCmd.Flags().StringVar(&roleARN, "role-arn", "", "TODO. Required.")
x509CredentialProcessCmd.MarkFlagRequired("role-arn")

Check failure on line 42 in cmd/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `x509CredentialProcessCmd.MarkFlagRequired` is not checked (errcheck)
x509CredentialProcessCmd.Flags().StringVar(&region, "region", "", "TODO")
x509CredentialProcessCmd.Flags().StringVar(&profileARN, "profile-arn", "", "TODO. Required.")
x509CredentialProcessCmd.MarkFlagRequired("profile-arn")

Check failure on line 45 in cmd/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `x509CredentialProcessCmd.MarkFlagRequired` is not checked (errcheck)
x509CredentialProcessCmd.Flags().DurationVar(&sessionDuration, "session-duration", 0, "TODO")
x509CredentialProcessCmd.Flags().StringVar(&trustAnchorARN, "trust-anchor-arn", "", "TODO. Required.")
x509CredentialProcessCmd.MarkFlagRequired("trust-anchor-arn")

Check failure on line 48 in cmd/main.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `x509CredentialProcessCmd.MarkFlagRequired` is not checked (errcheck)
x509CredentialProcessCmd.Flags().StringVar(&roleSessionName, "role-session-name", "", "TODO")

if err := rootCmd.Execute(); err != nil {
fmt.Println(err.Error())
os.Exit(1)
}
}
6 changes: 6 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
module github.com/spiffe/aws-spiffe-workload-helper

go 1.22.5

require (
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/spf13/cobra v1.8.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
)
10 changes: 10 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/spf13/cobra v1.8.1 h1:e5/vxKd/rZsfSJMUX1agtjeTDf+qv1/JdBF8gg5k9ZM=
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

0 comments on commit f3af76a

Please sign in to comment.