Skip to content

Commit

Permalink
Fixed some linting and original tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
matglas committed May 31, 2022
1 parent eaa28a2 commit 53c0ea1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
8 changes: 5 additions & 3 deletions sign/impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ type impl interface {
NewRekorClient(string) (*client.Rekor, error)
}

func (*defaultImpl) VerifyFileInternal(ctx context.Context, ko sign.KeyOpts, outputSignature, outputCertificate, path string) error {
func (*defaultImpl) VerifyFileInternal(ctx context.Context, ko sign.KeyOpts, outputSignature, // nolint: gocritic
outputCertificate, path string,
) error {
return verify.VerifyBlobCmd(ctx, ko, outputCertificate, "", "", "", outputSignature, path, false)
}

Expand Down Expand Up @@ -175,6 +177,6 @@ func (*defaultImpl) PayloadBytes(blobRef string) (blobBytes []byte, err error) {
return blobBytes, nil
}

func (*defaultImpl) NewRekorClient(rekorUrl string) (*client.Rekor, error) {
return rekor.NewClient(rekorUrl)
func (*defaultImpl) NewRekorClient(rekorURL string) (*client.Rekor, error) {
return rekor.NewClient(rekorURL)
}
5 changes: 2 additions & 3 deletions sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,10 @@ func (s *Signer) IsImageSigned(imageRef string) (bool, error) {
// IsFileSigned takes an path reference and retrusn true if there is a signature
// available for it. It makes no signature verification, only checks to see if
// more then one signature is available.
func (s *Signer) IsFileSigned(ctx context.Context, ko sign.KeyOpts, path string) (bool, error) {

func (s *Signer) IsFileSigned(ctx context.Context, ko sign.KeyOpts, path string) (bool, error) { // nolint: gocritic
rClient, err := s.impl.NewRekorClient(ko.RekorURL)
if err != nil {
return false, fmt.Errorf("creating rekor client", err)
return false, fmt.Errorf("creating rekor client: %w", err)
}

blobBytes, err := s.impl.PayloadBytes(path)
Expand Down
4 changes: 2 additions & 2 deletions sign/sign_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func TestSignFile(t *testing.T) {
}{
{ // Success
prepare: func(mock *signfakes.FakeImpl) {
mock.VerifyFileInternalReturns(&sign.SignedObject{}, nil)
mock.VerifyFileInternalReturns(nil)
},
assert: func(obj *sign.SignedObject, err error) {
require.NotNil(t, obj)
Expand All @@ -222,7 +222,7 @@ func TestSignFile(t *testing.T) {
},
{ // Failure on Verify
prepare: func(mock *signfakes.FakeImpl) {
mock.VerifyFileInternalReturns(nil, errTest)
mock.VerifyFileInternalReturns(errTest)
},
assert: func(obj *sign.SignedObject, err error) {
require.NotNil(t, err)
Expand Down

0 comments on commit 53c0ea1

Please sign in to comment.