Skip to content

Commit

Permalink
Linter fixes and docgen
Browse files Browse the repository at this point in the history
Signed-off-by: Zach Steindler <[email protected]>
  • Loading branch information
steiza committed Sep 11, 2024
1 parent 2552371 commit ea1c77f
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 11 deletions.
4 changes: 2 additions & 2 deletions cmd/cosign/cli/trustedroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func trustedRootCreate() *cobra.Command {
Use: "create",
Short: "Create a Sigstore protobuf trusted root",
Long: "Create a Sigstore protobuf trusted root by supplying verification material",
RunE: func(cmd *cobra.Command, args []string) error {
trCreateCmd := &trustedroot.TrustedRootCreateCmd{
RunE: func(cmd *cobra.Command, _ []string) error {
trCreateCmd := &trustedroot.CreateCmd{
CAIntermediates: o.CAIntermediates,
CARoots: o.CARoots,
CertChain: o.CertChain,
Expand Down
13 changes: 6 additions & 7 deletions cmd/cosign/cli/trustedroot/trustedroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"github.com/sigstore/cosign/v2/internal/ui"
)

type TrustedRootCreateCmd struct {
type CreateCmd struct {
CAIntermediates string
CARoots string
CertChain string
Expand All @@ -41,7 +41,7 @@ type TrustedRootCreateCmd struct {
TSACertChainPath string
}

func (c *TrustedRootCreateCmd) Exec(ctx context.Context) error {
func (c *CreateCmd) Exec(ctx context.Context) error {
var fulcioCertAuthorities []root.CertificateAuthority
var timestampAuthorities []root.CertificateAuthority
rekorTransparencyLogs := make(map[string]*root.TransparencyLog)
Expand All @@ -52,7 +52,6 @@ func (c *TrustedRootCreateCmd) Exec(ctx context.Context) error {
return err
}
fulcioCertAuthorities = append(fulcioCertAuthorities, *fulcioAuthority)

} else if c.CARoots != "" {
roots, err := parseCerts(c.CARoots)
if err != nil {
Expand Down Expand Up @@ -108,10 +107,10 @@ func (c *TrustedRootCreateCmd) Exec(ctx context.Context) error {

rekorTransparencyLog := root.TransparencyLog{
BaseURL: c.RekorURL,
HashFunc: crypto.Hash(crypto.SHA256),
HashFunc: crypto.SHA256,
ID: keyHash[:],
PublicKey: pub,
SignatureHashFunc: crypto.Hash(crypto.SHA256),
SignatureHashFunc: crypto.SHA256,
}

rekorTransparencyLogs[keyID] = &rekorTransparencyLog
Expand Down Expand Up @@ -140,7 +139,7 @@ func (c *TrustedRootCreateCmd) Exec(ctx context.Context) error {
}

if c.Out != "" {
err = os.WriteFile(c.Out, trBytes, 0640)
err = os.WriteFile(c.Out, trBytes, 0600)
if err != nil {
return err
}
Expand Down Expand Up @@ -187,7 +186,7 @@ func parseCerts(path string) ([]*x509.Certificate, error) {
}

if len(certs) == 0 {
return nil, fmt.Errorf("No certificates in file %s", path)
return nil, fmt.Errorf("no certificates in file %s", path)
}

return certs, nil
Expand Down
4 changes: 2 additions & 2 deletions cmd/cosign/cli/trustedroot/trustedroot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"github.com/sigstore/sigstore-go/pkg/root"
)

func TestTrustedRootCreate(t *testing.T) {
func TestCreateCmd(t *testing.T) {
ctx := context.Background()

// Make some certificate chains
Expand All @@ -43,7 +43,7 @@ func TestTrustedRootCreate(t *testing.T) {

outPath := filepath.Join(td, "trustedroot.json")

trustedrootCreate := TrustedRootCreateCmd{
trustedrootCreate := CreateCmd{
CertChain: fulcioChainPath,
Out: outPath,
TSACertChainPath: tsaChainPath,
Expand Down
1 change: 1 addition & 0 deletions doc/cosign.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions doc/cosign_trusted-root.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

36 changes: 36 additions & 0 deletions doc/cosign_trusted-root_create.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ea1c77f

Please sign in to comment.