diff --git a/cmd/quill/cli/cli.go b/cmd/quill/cli/cli.go index a026dc7..2b2b919 100644 --- a/cmd/quill/cli/cli.go +++ b/cmd/quill/cli/cli.go @@ -38,9 +38,9 @@ func New(id clio.Identification) *cobra.Command { }, ) - app := clio.New(*clioCfg) + root := &cobra.Command{} - root := app.SetupCommand(&cobra.Command{}) + app := clio.New(*clioCfg, root) submission := commands.Submission(app) submission.AddCommand(commands.SubmissionList(app)) @@ -54,7 +54,7 @@ func New(id clio.Identification) *cobra.Command { p12.AddCommand(commands.P12AttachChain(app)) p12.AddCommand(commands.P12Describe(app)) - root.AddCommand(clio.VersionCommand(app)) + root.AddCommand(clio.VersionCommand(id)) root.AddCommand(commands.Sign(app)) root.AddCommand(commands.Notarize(app)) root.AddCommand(commands.SignAndNotarize(app)) diff --git a/cmd/quill/cli/commands/describe.go b/cmd/quill/cli/commands/describe.go index 64bf5a9..dce8b27 100644 --- a/cmd/quill/cli/commands/describe.go +++ b/cmd/quill/cli/commands/describe.go @@ -1,7 +1,6 @@ package commands import ( - "context" "fmt" "strings" @@ -42,7 +41,7 @@ func Describe(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() var err error @@ -63,6 +62,6 @@ func Describe(app clio.Application) *cobra.Command { bus.Report(buf.String()) return nil - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/embedded_certificates.go b/cmd/quill/cli/commands/embedded_certificates.go index 2960dcb..356777b 100644 --- a/cmd/quill/cli/commands/embedded_certificates.go +++ b/cmd/quill/cli/commands/embedded_certificates.go @@ -1,7 +1,6 @@ package commands import ( - "context" "fmt" "io" "strings" @@ -21,7 +20,7 @@ func EmbeddedCerts(app clio.Application) *cobra.Command { Use: "embedded-certificates", Short: "show the certificates embedded into quill (typically the Apple root and intermediate certs)", Args: cobra.NoArgs, - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() var err error @@ -36,7 +35,7 @@ func EmbeddedCerts(app clio.Application) *cobra.Command { bus.Report(buf.String()) return nil - }), + }, }) } diff --git a/cmd/quill/cli/commands/extract_certificates.go b/cmd/quill/cli/commands/extract_certificates.go index 3347b28..cea7906 100644 --- a/cmd/quill/cli/commands/extract_certificates.go +++ b/cmd/quill/cli/commands/extract_certificates.go @@ -1,7 +1,6 @@ package commands import ( - "context" "encoding/pem" "strings" @@ -41,7 +40,7 @@ func ExtractCertificates(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() certs, err := extractCertificates(opts.Path, opts.Leaf) @@ -53,7 +52,7 @@ func ExtractCertificates(app clio.Application) *cobra.Command { bus.Notify("Try running 'openssl x509 -text -in .pem' to view the certificate details") return nil - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/notarize.go b/cmd/quill/cli/commands/notarize.go index 415d9e0..55b73b3 100644 --- a/cmd/quill/cli/commands/notarize.go +++ b/cmd/quill/cli/commands/notarize.go @@ -1,7 +1,6 @@ package commands import ( - "context" "time" "github.com/spf13/cobra" @@ -48,7 +47,7 @@ func Notarize(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() // TODO: verify path is a signed darwin binary @@ -59,7 +58,7 @@ func Notarize(app clio.Application) *cobra.Command { } _, err := notarize(opts.Path, opts.Notary, opts.Status) return err - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/p12_attach_chain.go b/cmd/quill/cli/commands/p12_attach_chain.go index 7d1fec1..dc0851d 100644 --- a/cmd/quill/cli/commands/p12_attach_chain.go +++ b/cmd/quill/cli/commands/p12_attach_chain.go @@ -1,7 +1,6 @@ package commands import ( - "context" "crypto/rand" "crypto/x509" "fmt" @@ -54,7 +53,7 @@ func P12AttachChain(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() newFilename, err := writeP12WithChain(opts.Path, opts.P12.Password, opts.Keychain.Path, true) @@ -71,7 +70,7 @@ func P12AttachChain(app clio.Application) *cobra.Command { bus.Notify(fmt.Sprintf("Wrote new p12 file with certificate chain to %q", newFilename)) return nil - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/p12_describe.go b/cmd/quill/cli/commands/p12_describe.go index d1c5542..cd00b00 100644 --- a/cmd/quill/cli/commands/p12_describe.go +++ b/cmd/quill/cli/commands/p12_describe.go @@ -1,7 +1,6 @@ package commands import ( - "context" "crypto/x509" "fmt" "reflect" @@ -37,7 +36,7 @@ func P12Describe(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() description, err := describeP12(opts.Path, opts.Password) @@ -48,7 +47,7 @@ func P12Describe(app clio.Application) *cobra.Command { bus.Report(description) return nil - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/sign.go b/cmd/quill/cli/commands/sign.go index 7e10e45..3f7f0b7 100644 --- a/cmd/quill/cli/commands/sign.go +++ b/cmd/quill/cli/commands/sign.go @@ -1,7 +1,6 @@ package commands import ( - "context" "fmt" "github.com/spf13/cobra" @@ -38,11 +37,11 @@ func Sign(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() return sign(opts.Path, opts.Signing) - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/sign_and_notarize.go b/cmd/quill/cli/commands/sign_and_notarize.go index 3270501..822ab20 100644 --- a/cmd/quill/cli/commands/sign_and_notarize.go +++ b/cmd/quill/cli/commands/sign_and_notarize.go @@ -1,7 +1,6 @@ package commands import ( - "context" "fmt" "github.com/spf13/cobra" @@ -48,7 +47,7 @@ func SignAndNotarize(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() err := sign(opts.Path, opts.Signing) @@ -67,6 +66,6 @@ func SignAndNotarize(app clio.Application) *cobra.Command { } return nil - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/submission_list.go b/cmd/quill/cli/commands/submission_list.go index aff01fe..439d2e2 100644 --- a/cmd/quill/cli/commands/submission_list.go +++ b/cmd/quill/cli/commands/submission_list.go @@ -25,7 +25,7 @@ func SubmissionList(app clio.Application) *cobra.Command { Use: "list", Short: "list previous submissions to Apple's Notary service", Args: cobra.NoArgs, - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() log.Info("fetching previous submissions") @@ -64,6 +64,6 @@ func SubmissionList(app clio.Application) *cobra.Command { bus.Report(t.Render()) return nil - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/submission_logs.go b/cmd/quill/cli/commands/submission_logs.go index 3dae98a..cbc06c5 100644 --- a/cmd/quill/cli/commands/submission_logs.go +++ b/cmd/quill/cli/commands/submission_logs.go @@ -1,8 +1,6 @@ package commands import ( - "context" - "github.com/spf13/cobra" "github.com/anchore/clio" @@ -36,7 +34,7 @@ func SubmissionLogs(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() log.Infof("fetching submission logs for %q", opts.ID) @@ -56,7 +54,7 @@ func SubmissionLogs(app clio.Application) *cobra.Command { sub := notary.ExistingSubmission(a, opts.ID) - content, err := sub.Logs(ctx) + content, err := sub.Logs(cmd.Context()) if err != nil { return err } @@ -64,6 +62,6 @@ func SubmissionLogs(app clio.Application) *cobra.Command { bus.Report(content) return nil - }), + }, }, opts) } diff --git a/cmd/quill/cli/commands/submission_status.go b/cmd/quill/cli/commands/submission_status.go index bb15dbd..0b52549 100644 --- a/cmd/quill/cli/commands/submission_status.go +++ b/cmd/quill/cli/commands/submission_status.go @@ -1,7 +1,6 @@ package commands import ( - "context" "time" "github.com/spf13/cobra" @@ -42,7 +41,7 @@ func SubmissionStatus(app clio.Application) *cobra.Command { return nil }, ), - RunE: app.Run(func(ctx context.Context) error { + RunE: func(cmd *cobra.Command, args []string) error { defer bus.Exit() log.Infof("checking submission status for %q", opts.ID) @@ -70,9 +69,9 @@ func SubmissionStatus(app clio.Application) *cobra.Command { var status notary.SubmissionStatus if opts.Wait { - status, err = notary.PollStatus(ctx, sub, cfg.StatusConfig) + status, err = notary.PollStatus(cmd.Context(), sub, cfg.StatusConfig) } else { - status, err = sub.Status(ctx) + status, err = sub.Status(cmd.Context()) } if err != nil { return err @@ -81,6 +80,6 @@ func SubmissionStatus(app clio.Application) *cobra.Command { bus.Report(string(status)) return nil - }), + }, }, opts) }