Skip to content

Commit

Permalink
feat: add gofmt, goimports check
Browse files Browse the repository at this point in the history
Signed-off-by: Batuhan Apaydın <batuhan.apaydin@trendyol.com>
  • Loading branch information
developer-guy committed Nov 13, 2021
1 parent e4a099e commit 25c5fe4
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 26 deletions.
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ else
GOBIN=$(shell go env GOBIN)
endif

GOFILES ?= $(shell find . -type f -name '*.go' -not -path "./vendor/*")

# Set version variables for LDFLAGS
PROJECT_ID ?= projectsigstore
RUNTIME_IMAGE ?= gcr.io/distroless/static
Expand Down Expand Up @@ -55,6 +57,28 @@ export KO_DOCKER_REPO=$(KO_PREFIX)
.PHONY: all lint test clean cosign cross
all: cosign

log-%:
@grep -h -E '^$*:.*?## .*$$' $(MAKEFILE_LIST) | \
awk \
'BEGIN { \
FS = ":.*?## " \
}; \
{ \
printf "\033[36m==> %s\033[0m\n", $$2 \
}'

.PHONY: checkfmt
checkfmt: SHELL := /usr/bin/env bash
checkfmt: ## Check formatting of all go files
@ $(MAKE) --no-print-directory log-$@
$(shell test -z "$(shell gofmt -l $(GOFILES) | tee /dev/stderr)")
$(shell test -z "$(shell goimports -l $(GOFILES) | tee /dev/stderr)")

.PHONY: fmt
fmt: ## Format all go files
@ $(MAKE) --no-print-directory log-$@
goimports -w $(GOFILES)

cosign: $(SRCS)
CGO_ENABLED=0 go build -trimpath -ldflags "$(LDFLAGS)" -o $@ ./cmd/cosign

Expand Down
1 change: 0 additions & 1 deletion pkg/cosign/remote/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ type dd struct {

type ro struct {
predicateURI string
replace bool
}

var _ mutate.DupeDetector = (*dd)(nil)
Expand Down
22 changes: 6 additions & 16 deletions pkg/oci/mutate/mutate.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,11 @@ func (si *signedImage) Attestations() (oci.Signatures, error) {
}
}
if si.so.ro != nil {
if replace, err := si.so.ro.Replace(base, si.att); err != nil {
replace, err := si.so.ro.Replace(base, si.att)
if err != nil {
return nil, err
} else {
return AppendSignatures(replace)
}
return AppendSignatures(replace)
}
return AppendSignatures(base, si.att)
}
Expand Down Expand Up @@ -289,21 +289,11 @@ func (sii *signedImageIndex) Attestations() (oci.Signatures, error) {
}
}
if sii.so.ro != nil {
if replace, err := sii.so.ro.Replace(base, sii.att); err != nil {
replace, err := sii.so.ro.Replace(base, sii.att)
if err != nil {
return nil, err
} else {
//sigs, err := base.Get()
//if err != nil {
// return nil, err
//}
//
//if len(sigs) == 0 {
// return AppendSignatures(replace,sii.att)
//}else{
// return ReplaceSignatures(replace)
//}
return ReplaceSignatures(replace)
}
return ReplaceSignatures(replace)
}
return AppendSignatures(base, sii.att)
}
Expand Down
8 changes: 0 additions & 8 deletions pkg/oci/mutate/signatures.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,6 @@ func ReplaceSignatures(base oci.Signatures) (oci.Signatures, error) {
}, nil
}

//func SetSignatures(base oci.Signatures, sigs ...oci.Signature) oci.Signatures {
// return &sigAppender{
// Image: img,
// base: base,
// sigs: sigs,
// }
//}

type sigAppender struct {
v1.Image
base oci.Signatures
Expand Down
2 changes: 1 addition & 1 deletion test/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func TestAttestVerify(t *testing.T) {
// Now attest the image
ko := sign.KeyOpts{KeyRef: privKeyPath, PassFunc: passFunc}
must(attest.AttestCmd(ctx, ko, options.RegistryOptions{}, imgName, "", false, slsaAttestationPath, false,
"custom", time.Duration(30*time.Second)), t)
"custom", ftime.Duration(30*time.Second)), t)

// Use cue to verify attestation
policyPath := filepath.Join(td, "policy.cue")
Expand Down

0 comments on commit 25c5fe4

Please sign in to comment.