Skip to content

Commit

Permalink
chore: enable whitespace check on golangci-lint and organize imports (s…
Browse files Browse the repository at this point in the history
…igstore#687)

Signed-off-by: Carlos Panato <ctadeu@gmail.com>
  • Loading branch information
cpanato authored Sep 16, 2021
1 parent 69de545 commit 905c794
Show file tree
Hide file tree
Showing 39 changed files with 40 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ jobs:
echo "${{ github.repository }} is out of style. Please run ${{ matrix.tool }} ${{ matrix.options }}."
exit 1
fi
echo "${{ github.repository }} is formatted correctly."
echo "${{ github.repository }} is formatted correctly."
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ linters:
- tparallel
- unconvert
- unparam
- whitespace
output:
uniq-by-line: false
issues:
Expand Down
6 changes: 2 additions & 4 deletions cmd/cosign/cli/attest.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ import (
"github.com/in-toto/in-toto-golang/in_toto"
"github.com/peterbourgon/ff/v3/ffcli"
"github.com/pkg/errors"
"github.com/sigstore/cosign/pkg/cosign/attestation"
"github.com/sigstore/cosign/pkg/types"

"github.com/sigstore/cosign/pkg/cosign"
"github.com/sigstore/cosign/pkg/cosign/attestation"
cremote "github.com/sigstore/cosign/pkg/cosign/remote"

"github.com/sigstore/cosign/pkg/types"
rekorClient "github.com/sigstore/rekor/pkg/client"
"github.com/sigstore/sigstore/pkg/signature/dsse"
"github.com/sigstore/sigstore/pkg/signature/options"
Expand Down Expand Up @@ -120,7 +119,6 @@ var predicateTypeMap = map[string]string{

func AttestCmd(ctx context.Context, ko KeyOpts, imageRef string, certPath string,
upload bool, predicatePath string, force bool, predicateType string) error {

// A key file or token is required unless we're in experimental mode!
if EnableExperimental() {
if nOf(ko.KeyRef, ko.Sk) > 1 {
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/clean.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/peterbourgon/ff/v3/ffcli"

"github.com/sigstore/cosign/pkg/cosign"
)

Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/peterbourgon/ff/v3/ffcli"

"github.com/sigstore/cosign/pkg/cosign"
)

Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/dockerfile/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/peterbourgon/ff/v3/ffcli"
"github.com/pkg/errors"

"github.com/sigstore/cosign/cmd/cosign/cli"
)

Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/download/sbom.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/peterbourgon/ff/v3/ffcli"

"github.com/sigstore/cosign/cmd/cosign/cli"
"github.com/sigstore/cosign/pkg/cosign"
)
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/download/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

"github.com/google/go-containerregistry/pkg/name"
"github.com/peterbourgon/ff/v3/ffcli"

"github.com/sigstore/cosign/cmd/cosign/cli"
"github.com/sigstore/cosign/pkg/cosign"
)
Expand Down
2 changes: 1 addition & 1 deletion cmd/cosign/cli/fulcio/fulcio.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ func NewSigner(ctx context.Context, idToken, oidcIssuer, oidcClientID string, fC
Chain: Resp.ChainPEM,
SCT: Resp.SCT,
}
return f, nil

return f, nil
}

func (f *Signer) PublicKey(opts ...signature.PublicKeyOption) (crypto.PublicKey, error) {
Expand Down
2 changes: 1 addition & 1 deletion cmd/cosign/cli/fulcio/fulcioverifier/fulcioverifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
ctx509 "github.com/google/certificate-transparency-go/x509"
"github.com/google/certificate-transparency-go/x509util"
"github.com/pkg/errors"

"github.com/sigstore/cosign/cmd/cosign/cli/fulcio"
"github.com/sigstore/cosign/pkg/cosign"
fulcioClient "github.com/sigstore/fulcio/pkg/generated/client"
Expand Down Expand Up @@ -69,5 +70,4 @@ func NewSigner(ctx context.Context, idToken, oidcIssuer, oidcClientID string, fC
fmt.Fprintln(os.Stderr, "Successfully verified SCT...")

return fs, nil

}
1 change: 1 addition & 0 deletions cmd/cosign/cli/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"

"github.com/pkg/errors"

"github.com/sigstore/cosign/pkg/cosign"
"github.com/sigstore/cosign/pkg/cosign/kubernetes"
"github.com/sigstore/sigstore/pkg/cryptoutils"
Expand Down
1 change: 0 additions & 1 deletion cmd/cosign/cli/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,5 @@ func TestPublicKeyFromFileRef(t *testing.T) {

if _, err := publicKeyFromKeyRef(ctx, testFile); err != nil {
t.Fatalf("publicKeyFromKeyRef returned error: %v", err)

}
}
1 change: 1 addition & 0 deletions cmd/cosign/cli/pivcli/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (

"github.com/go-piv/piv-go/piv"
"github.com/manifoldco/promptui"

"github.com/sigstore/cosign/pkg/cosign/pivkey"
)

Expand Down
1 change: 0 additions & 1 deletion cmd/cosign/cli/public_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ EXAMPLES
cosign public-key -key hashivault://[KEY]`,
FlagSet: flagset,
Exec: func(ctx context.Context, args []string) error {

if !oneOf(*key, *sk) {
return &KeyParseError{}
}
Expand Down
6 changes: 1 addition & 5 deletions cmd/cosign/cli/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ import (
cremote "github.com/sigstore/cosign/pkg/cosign/remote"
providers "github.com/sigstore/cosign/pkg/providers/all"
fulcioClient "github.com/sigstore/fulcio/pkg/client"
"github.com/sigstore/rekor/pkg/generated/models"

rekorClient "github.com/sigstore/rekor/pkg/client"
"github.com/sigstore/rekor/pkg/generated/models"
"github.com/sigstore/sigstore/pkg/cryptoutils"
"github.com/sigstore/sigstore/pkg/signature"
"github.com/sigstore/sigstore/pkg/signature/options"
Expand Down Expand Up @@ -235,7 +234,6 @@ func getTransitiveImages(rootIndex *remote.Descriptor, repo name.Repository, opt
return nil, errors.Wrap(err, "getting recursive image index")
}
indexDescs = append(indexDescs, indexDesc)

}
childImg := repo.Digest(manifest.Digest.String())
imgs = append(imgs, childImg)
Expand All @@ -247,7 +245,6 @@ func getTransitiveImages(rootIndex *remote.Descriptor, repo name.Repository, opt

func SignCmd(ctx context.Context, ko KeyOpts, annotations map[string]interface{},
imgs []string, certPath string, upload bool, payloadPath string, force bool, recursive bool, attachment string) error {

if EnableExperimental() {
if nOf(ko.KeyRef, ko.Sk) > 1 {
return &KeyParseError{}
Expand All @@ -262,7 +259,6 @@ func SignCmd(ctx context.Context, ko KeyOpts, annotations map[string]interface{}

toSign := make([]name.Digest, 0, len(imgs))
for _, inputImg := range imgs {

// A key file or token is required unless we're in experimental mode!
ref, err := getAttachedImageRef(ctx, inputImg, attachment)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/cosign/cli/sign_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ import (
"os"
"path/filepath"

"github.com/sigstore/sigstore/pkg/signature/options"

"github.com/peterbourgon/ff/v3/ffcli"
"github.com/pkg/errors"

"github.com/sigstore/cosign/pkg/cosign"
rekorClient "github.com/sigstore/rekor/pkg/client"
"github.com/sigstore/sigstore/pkg/signature/options"
)

func SignBlob() *ffcli.Command {
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/upload/blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (

"github.com/google/go-containerregistry/pkg/name"
"github.com/peterbourgon/ff/v3/ffcli"

"github.com/sigstore/cosign/cmd/cosign/cli"
cremote "github.com/sigstore/cosign/pkg/cosign/remote"
)
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/upload/wasm.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

"github.com/google/go-containerregistry/pkg/name"
"github.com/peterbourgon/ff/v3/ffcli"

"github.com/sigstore/cosign/cmd/cosign/cli"
cremote "github.com/sigstore/cosign/pkg/cosign/remote"
"github.com/sigstore/cosign/pkg/types"
Expand Down
1 change: 1 addition & 0 deletions cmd/cosign/cli/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/pkg/errors"

"github.com/sigstore/cosign/pkg/cosign"
"github.com/sigstore/sigstore/pkg/signature"
"github.com/sigstore/sigstore/pkg/signature/kms"
Expand Down
1 change: 0 additions & 1 deletion cmd/cosign/cli/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ func PrintVerificationHeader(imgRef string, co *cosign.CheckOpts) {

// PrintVerification logs details about the verification to stdout
func PrintVerification(imgRef string, verified []cosign.SignedPayload, output string) {

switch output {
case "text":
for _, vp := range verified {
Expand Down
1 change: 0 additions & 1 deletion cmd/cosign/cli/verify_attestation.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ func (c *VerifyAttestationCommand) Exec(ctx context.Context, args []string) (err
if EnableExperimental() {
co.RekorURL = c.RekorURL
co.RootCerts = fulcio.GetRoots()

}
keyRef := c.KeyRef

Expand Down
1 change: 0 additions & 1 deletion cmd/cosign/cli/verify_blob.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import (
"github.com/sigstore/cosign/pkg/cosign"
"github.com/sigstore/cosign/pkg/cosign/pivkey"
rekorClient "github.com/sigstore/rekor/pkg/client"

"github.com/sigstore/sigstore/pkg/cryptoutils"
"github.com/sigstore/sigstore/pkg/signature"
"github.com/sigstore/sigstore/pkg/signature/options"
Expand Down
5 changes: 2 additions & 3 deletions cmd/cosign/cli/verify_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,12 @@ import (
"path/filepath"
"strings"

"github.com/peterbourgon/ff/v3/ffcli"
"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
batchv1 "k8s.io/api/batch/v1"
"k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"

"github.com/peterbourgon/ff/v3/ffcli"
"github.com/pkg/errors"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
"k8s.io/apimachinery/pkg/util/yaml"
Expand Down
1 change: 1 addition & 0 deletions cmd/sget/cli/sget.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/google/go-containerregistry/pkg/authn"
"github.com/google/go-containerregistry/pkg/name"
"github.com/google/go-containerregistry/pkg/v1/remote"

"github.com/sigstore/cosign/cmd/cosign/cli"
"github.com/sigstore/cosign/cmd/cosign/cli/fulcio"
"github.com/sigstore/cosign/pkg/cosign"
Expand Down
1 change: 1 addition & 0 deletions cmd/sget/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"os"

"github.com/peterbourgon/ff/v3/ffcli"

"github.com/sigstore/cosign/cmd/sget/cli"
)

Expand Down
1 change: 0 additions & 1 deletion copasetic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import (
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/remote"

"github.com/open-policy-agent/opa/ast"
"github.com/open-policy-agent/opa/cmd"
"github.com/open-policy-agent/opa/rego"
Expand Down
1 change: 1 addition & 0 deletions internal/oci/empty/empty.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/google/go-containerregistry/pkg/v1/empty"
"github.com/google/go-containerregistry/pkg/v1/mutate"
"github.com/google/go-containerregistry/pkg/v1/types"

"github.com/sigstore/cosign/internal/oci"
)

Expand Down
1 change: 1 addition & 0 deletions internal/oci/empty/empty_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"testing"

"github.com/google/go-containerregistry/pkg/v1/types"

"github.com/sigstore/cosign/internal/oci"
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/cosign/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ import (
v1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/remote"
"github.com/pkg/errors"
cremote "github.com/sigstore/cosign/pkg/cosign/remote"
"github.com/sigstore/sigstore/pkg/cryptoutils"
"golang.org/x/sync/errgroup"
"golang.org/x/sync/semaphore"

cremote "github.com/sigstore/cosign/pkg/cosign/remote"
"github.com/sigstore/sigstore/pkg/cryptoutils"
)

type SignedPayload struct {
Expand Down Expand Up @@ -116,7 +117,6 @@ func FetchSignaturesForImageDigest(ctx context.Context, signedImageDigest v1.Has
r, err := l.Compressed()
if err != nil {
return err

}
payload, err := ioutil.ReadAll(r)
if err != nil {
Expand Down Expand Up @@ -160,6 +160,6 @@ func FetchSignaturesForImageDigest(ctx context.Context, signedImageDigest v1.Has
if err := g.Wait(); err != nil {
return nil, err
}
return signatures, nil

return signatures, nil
}
1 change: 0 additions & 1 deletion pkg/cosign/kubernetes/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

// Initialize all known client auth plugins
_ "k8s.io/client-go/plugin/pkg/client/auth"

"k8s.io/client-go/rest"
"k8s.io/client-go/tools/clientcmd"
)
Expand Down
3 changes: 2 additions & 1 deletion pkg/cosign/kubernetes/secret.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ import (
"strings"

"github.com/pkg/errors"
"github.com/sigstore/cosign/pkg/cosign"
v1 "k8s.io/api/core/v1"
k8serrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/sigstore/cosign/pkg/cosign"
)

const KeyReference = "k8s://"
Expand Down
3 changes: 2 additions & 1 deletion pkg/cosign/kubernetes/secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
"reflect"
"testing"

"github.com/sigstore/cosign/pkg/cosign"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/sigstore/cosign/pkg/cosign"
)

func TestSecret(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/cosign/kubernetes/webhook/validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,12 @@ import (
"fmt"

"github.com/google/go-containerregistry/pkg/name"
"knative.dev/pkg/apis"
"knative.dev/pkg/logging"

"github.com/sigstore/cosign/cmd/cosign/cli/fulcio/fulcioroots"
"github.com/sigstore/cosign/pkg/cosign"
"github.com/sigstore/sigstore/pkg/signature"
"knative.dev/pkg/apis"
"knative.dev/pkg/logging"
)

func valid(ctx context.Context, img string, keys []*ecdsa.PublicKey) bool {
Expand Down
4 changes: 2 additions & 2 deletions pkg/cosign/pivkey/pivkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ import (
"io/ioutil"
"os"

"github.com/go-piv/piv-go/piv"
"github.com/pkg/errors"
"golang.org/x/term"

"github.com/go-piv/piv-go/piv"
"github.com/sigstore/sigstore/pkg/signature"
"golang.org/x/term"
)

var (
Expand Down
1 change: 1 addition & 0 deletions pkg/cosign/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/google/go-containerregistry/pkg/v1/remote/transport"
"github.com/google/go-containerregistry/pkg/v1/types"
"github.com/pkg/errors"

"github.com/sigstore/cosign/internal/oci/empty"
ctypes "github.com/sigstore/cosign/pkg/types"
"github.com/sigstore/sigstore/pkg/signature"
Expand Down
1 change: 0 additions & 1 deletion pkg/cosign/tuf/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"sync"

"github.com/pkg/errors"

"github.com/theupdateframework/go-tuf"
"github.com/theupdateframework/go-tuf/client"
tuf_leveldbstore "github.com/theupdateframework/go-tuf/client/leveldbstore"
Expand Down
Loading

0 comments on commit 905c794

Please sign in to comment.