Skip to content

Commit

Permalink
[wip]
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
  • Loading branch information
wagoodman committed Jun 23, 2023
1 parent baf4d29 commit d82015c
Show file tree
Hide file tree
Showing 12 changed files with 28 additions and 39 deletions.
6 changes: 3 additions & 3 deletions cmd/quill/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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))
Expand Down
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/describe.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"fmt"
"strings"

Expand Down Expand Up @@ -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
Expand All @@ -63,6 +62,6 @@ func Describe(app clio.Application) *cobra.Command {
bus.Report(buf.String())

return nil
}),
},
}, opts)
}
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/embedded_certificates.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"fmt"
"io"
"strings"
Expand All @@ -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
Expand All @@ -36,7 +35,7 @@ func EmbeddedCerts(app clio.Application) *cobra.Command {
bus.Report(buf.String())

return nil
}),
},
})
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/extract_certificates.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"encoding/pem"
"strings"

Expand Down Expand Up @@ -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)
Expand All @@ -53,7 +52,7 @@ func ExtractCertificates(app clio.Application) *cobra.Command {
bus.Notify("Try running 'openssl x509 -text -in <path-to-file-with-output>.pem' to view the certificate details")

return nil
}),
},
}, opts)
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/notarize.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -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
Expand All @@ -59,7 +58,7 @@ func Notarize(app clio.Application) *cobra.Command {
}
_, err := notarize(opts.Path, opts.Notary, opts.Status)
return err
}),
},
}, opts)
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/p12_attach_chain.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"crypto/rand"
"crypto/x509"
"fmt"
Expand Down Expand Up @@ -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)
Expand All @@ -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)
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/p12_describe.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"crypto/x509"
"fmt"
"reflect"
Expand Down Expand Up @@ -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)
Expand All @@ -48,7 +47,7 @@ func P12Describe(app clio.Application) *cobra.Command {
bus.Report(description)

return nil
}),
},
}, opts)
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/sign.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"fmt"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -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)
}

Expand Down
5 changes: 2 additions & 3 deletions cmd/quill/cli/commands/sign_and_notarize.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"fmt"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -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)
Expand All @@ -67,6 +66,6 @@ func SignAndNotarize(app clio.Application) *cobra.Command {
}

return nil
}),
},
}, opts)
}
4 changes: 2 additions & 2 deletions cmd/quill/cli/commands/submission_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -64,6 +64,6 @@ func SubmissionList(app clio.Application) *cobra.Command {
bus.Report(t.Render())

return nil
}),
},
}, opts)
}
8 changes: 3 additions & 5 deletions cmd/quill/cli/commands/submission_logs.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package commands

import (
"context"

"github.com/spf13/cobra"

"github.com/anchore/clio"
Expand Down Expand Up @@ -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)
Expand All @@ -56,14 +54,14 @@ 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
}

bus.Report(content)

return nil
}),
},
}, opts)
}
9 changes: 4 additions & 5 deletions cmd/quill/cli/commands/submission_status.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package commands

import (
"context"
"time"

"github.com/spf13/cobra"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -81,6 +80,6 @@ func SubmissionStatus(app clio.Application) *cobra.Command {
bus.Report(string(status))

return nil
}),
},
}, opts)
}

0 comments on commit d82015c

Please sign in to comment.