Skip to content

Commit e889f5a

Browse files
fix: golang linting issues
1 parent 12c0c68 commit e889f5a

File tree

5 files changed

+24
-7
lines changed

5 files changed

+24
-7
lines changed

cmd/artifacts/cosign/verifier.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"github.com/fatih/color"
66
"github.com/google/go-containerregistry/pkg/name"
7+
artifactUtils "github.com/intelops/compage/cmd/artifacts/utils"
78
"github.com/sigstore/cosign/v2/cmd/cosign/cli/fulcio"
89
"github.com/sigstore/cosign/v2/cmd/cosign/cli/options"
910
"github.com/sigstore/cosign/v2/cmd/cosign/cli/rekor"
@@ -15,7 +16,7 @@ import (
1516
)
1617

1718
func VerifyArtifact(ctx context.Context, key string) error {
18-
artifactURL := ctx.Value("artifactURL").(string)
19+
artifactURL := ctx.Value(artifactUtils.ContextKeyArtifactURL).(string)
1920
ref, err := name.ParseReference(artifactURL)
2021
if err != nil {
2122
log.Errorf("parsing reference: %v", err)
File renamed without changes.

cmd/artifacts/oci-registry/pull.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"encoding/json"
66
"errors"
77
"fmt"
8+
artifactUtils "github.com/intelops/compage/cmd/artifacts/utils"
89
spec "github.com/opencontainers/image-spec/specs-go/v1"
910
log "github.com/sirupsen/logrus"
1011
"oras.land/oras-go/v2"
@@ -32,7 +33,7 @@ func GetOCIArtifactURLAndPathByLanguage(language, version string) (string, strin
3233

3334
// Pull pulls an OCI image from a registry.
3435
func Pull(requestCtx context.Context, disableTLS bool) (template *string, err error) {
35-
ociName := requestCtx.Value("artifactURL").(string)
36+
ociName := requestCtx.Value(artifactUtils.ContextKeyArtifactURL).(string)
3637
ref, err := registry.ParseReference(ociName)
3738
if err != nil {
3839
log.Errorf("parse reference: %v", err)
@@ -77,7 +78,7 @@ func Pull(requestCtx context.Context, disableTLS bool) (template *string, err er
7778
}
7879

7980
// Create the template root directory
80-
templateRootDir := requestCtx.Value("artifactPath").(string)
81+
templateRootDir := requestCtx.Value(artifactUtils.ContextKeyArtifactPath).(string)
8182

8283
fs, err := file.New(templateRootDir)
8384
if err != nil {

cmd/artifacts/puller.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"github.com/intelops/compage/cmd/artifacts/cosign"
77
"github.com/intelops/compage/cmd/artifacts/git"
88
"github.com/intelops/compage/cmd/artifacts/oci-registry"
9+
artifactUtils "github.com/intelops/compage/cmd/artifacts/utils"
910
"github.com/intelops/compage/internal/utils"
1011
log "github.com/sirupsen/logrus"
1112
)
@@ -28,10 +29,10 @@ func PullOCIArtifact(language, version string) error {
2829
}
2930

3031
ctx := context.Background()
31-
ctx = context.WithValue(ctx, "artifactURL", artifactURL)
32-
ctx = context.WithValue(ctx, "artifactPath", artifactPath)
33-
ctx = context.WithValue(ctx, "repositoryURL", repositoryURL)
34-
ctx = context.WithValue(ctx, "repositoryPath", repositoryPath)
32+
ctx = context.WithValue(ctx, artifactUtils.ContextKeyArtifactURL, artifactURL)
33+
ctx = context.WithValue(ctx, artifactUtils.ContextKeyArtifactPath, artifactPath)
34+
ctx = context.WithValue(ctx, artifactUtils.ContextKeyRepositoryURL, repositoryURL)
35+
ctx = context.WithValue(ctx, artifactUtils.ContextKeyRepositoryPath, repositoryPath)
3536

3637
exists, err := utils.DirectoryExists(artifactPath)
3738
if err != nil {

cmd/artifacts/utils/context.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package utils
2+
3+
type contextKey string
4+
5+
func (c contextKey) String() string {
6+
return string(c)
7+
}
8+
9+
var (
10+
ContextKeyArtifactURL = contextKey("artifactURL")
11+
ContextKeyArtifactPath = contextKey("artifactPath")
12+
ContextKeyRepositoryURL = contextKey("repositoryURL")
13+
ContextKeyRepositoryPath = contextKey("repositoryPath")
14+
)

0 commit comments

Comments
 (0)