Skip to content

Commit

Permalink
chore: fix linting issues (ratify-project#1606)
Browse files Browse the repository at this point in the history
Signed-off-by: akashsinghal <[email protected]>
  • Loading branch information
akashsinghal committed Sep 13, 2024
1 parent bcf30ed commit f8c7beb
Show file tree
Hide file tree
Showing 23 changed files with 65 additions and 65 deletions.
2 changes: 1 addition & 1 deletion cmd/ratify/cmd/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func NewCmdDiscover(argv ...string) *cobra.Command {
Short: "Discover referrers for a subject",
Example: eg,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return discover(opts)
},
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/ratify/cmd/referrer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func NewCmdReferrer(argv ...string) *cobra.Command {
Use: referrerUse,
Short: "Discover referrers for a subject",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Usage()
},
}
Expand All @@ -71,7 +71,7 @@ func NewCmdShowBlob(argv ...string) *cobra.Command {
Short: "show blob at a digest",
Example: eg,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return showBlob(opts)
},
}
Expand Down Expand Up @@ -100,7 +100,7 @@ func NewCmdShowRefManifest(argv ...string) *cobra.Command {
Short: "show rference manifest at a digest",
Example: eg,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return showRefManifest(opts)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ratify/cmd/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func NewCmdResolve(argv ...string) *cobra.Command {
Short: "Resolve digest of a subject that is referenced by a tag",
Example: eg,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return resolve(opts)
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/ratify/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ func New(use, short string) *cobra.Command {
root := &cobra.Command{
Use: use,
Short: short,
PersistentPreRun: func(cmd *cobra.Command, args []string) {
PersistentPreRun: func(_ *cobra.Command, _ []string) {
if enableDebug {
common.SetLoggingLevel("debug", logrus.StandardLogger())
} else {
common.SetLoggingLevelFromEnv(logrus.StandardLogger())
}
},
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(cmd *cobra.Command, _ []string) error {
return cmd.Usage()
},
SilenceUsage: true,
Expand Down
2 changes: 1 addition & 1 deletion cmd/ratify/cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func NewCmdServe(_ ...string) *cobra.Command {
Short: "Run ratify as a server",
Example: "ratify server",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return serve(opts)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ratify/cmd/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewCmdVerify(_ ...string) *cobra.Command {
Short: "Verify a subject",
Example: "sample example",
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return verify(opts)
},
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ratify/cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ ratify version`
Short: "Show the ratify version information",
Example: eg,
Args: cobra.NoArgs,
RunE: func(cmd *cobra.Command, args []string) error {
RunE: func(_ *cobra.Command, _ []string) error {
return runVersion()
},
}
Expand Down
2 changes: 1 addition & 1 deletion httpserver/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func sendResponse(results *[]externaldata.Item, systemErr string, w http.Respons
}

func processTimeout(h ContextHandler, duration time.Duration, isMutation bool) ContextHandler {
return func(handlerContext context.Context, w http.ResponseWriter, r *http.Request) error {
return func(_ context.Context, w http.ResponseWriter, r *http.Request) error {
ctx, cancel := context.WithTimeout(r.Context(), duration)
defer cancel()

Expand Down
14 changes: 7 additions & 7 deletions httpserver/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func TestServer_Timeout_Failed(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == testArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
time.Sleep(time.Duration(timeoutDuration) * time.Second)
return true
},
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestServer_MultipleSubjects_Success(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == testArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
}
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestServer_Mutation_Success(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == testArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
time.Sleep(time.Duration(timeoutDuration) * time.Second)
return true
},
Expand Down Expand Up @@ -344,7 +344,7 @@ func TestServer_Mutation_ReferrerStoreConfigInvalid_Failure(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == testArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
time.Sleep(time.Duration(timeoutDuration) * time.Second)
return true
},
Expand Down Expand Up @@ -423,7 +423,7 @@ func TestServer_MultipleRequestsForSameSubject_Success(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == testArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
}
Expand Down Expand Up @@ -552,7 +552,7 @@ func TestServer_Verify_PolicyEnforcerConfigInvalid_Failure(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == testArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
time.Sleep(time.Duration(timeoutDuration) * time.Second)
return true
},
Expand Down Expand Up @@ -671,7 +671,7 @@ func TestServer_Verify_VerifierConfigInvalid_Failure(t *testing.T) {
// TestServe_serverGracefulShutdown tests the case where the server is shutdown gracefully
func TestServer_serverGracefulShutdown(t *testing.T) {
// create a server that sleeps for 5 seconds before responding
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
time.Sleep(5 * time.Second)
fmt.Fprintln(w, "request succeeded")
}))
Expand Down
2 changes: 1 addition & 1 deletion httpserver/tlsManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func (t *TLSCertWatcher) Start() error {
var watchErr error
pollInterval := 1 * time.Second
pollTimeout := 10 * time.Second
if err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, false, func(ctx context.Context) (done bool, err error) {
if err := wait.PollUntilContextTimeout(context.TODO(), pollInterval, pollTimeout, false, func(_ context.Context) (done bool, err error) {
for f := range files {
if err := t.watcher.Add(f); err != nil {
watchErr = err
Expand Down
2 changes: 1 addition & 1 deletion pkg/common/oras/authprovider/aws/awsecrbasic.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (d *awsEcrBasicAuthProvider) getEcrAuthToken(artifact string) (EcrAuthToken
ctx := context.Background()
// TODO: Update to use regional endpoint
// nolint:staticcheck
resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, options ...interface{}) (aws.Endpoint, error) {
resolver := aws.EndpointResolverWithOptionsFunc(func(service, region string, _ ...interface{}) (aws.Endpoint, error) {
if service == ecr.ServiceID && region == apiOverrideRegion {
logrus.Info("AWS ECR basic auth using custom endpoint resolver...")
logrus.Infof("AWS ECR basic auth API override endpoint: %s", apiOverrideEndpoint)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/clusterresource/policy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ func TestWritePolicyStatus(t *testing.T) {
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(_ *testing.T) {
writePolicyStatus(context.Background(), tc.reconciler, tc.policy, logger, tc.isSuccess, tc.errString)
})
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controllers/clusterresource/store_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestWriteStoreStatus(t *testing.T) {
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(_ *testing.T) {
writeStoreStatus(context.Background(), tc.reconciler, tc.store, logger, tc.isSuccess, tc.errString)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func TestWritePolicyStatus(t *testing.T) {
}

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
t.Run(tc.name, func(_ *testing.T) {
writePolicyStatus(context.Background(), tc.reconciler, tc.policy, logger, tc.isSuccess, tc.errString)
})
}
Expand Down
18 changes: 9 additions & 9 deletions pkg/executor/core/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func TestVerifySubjectInternal_CanVerify_ExpectedResults(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == testArtifactType1
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
}
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestVerifySubjectInternal_VerifyFailures_ExpectedResults(t *testing.T) {
},
}
ver := &TestVerifier{
CanVerifyFunc: func(at string) bool {
CanVerifyFunc: func(_ string) bool {
return true
},
VerifyResult: func(artifactType string) bool {
Expand Down Expand Up @@ -345,10 +345,10 @@ func TestVerifySubjectInternal_VerifySuccess_ExpectedResults(t *testing.T) {
},
}
ver := &TestVerifier{
CanVerifyFunc: func(at string) bool {
CanVerifyFunc: func(_ string) bool {
return true
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
}
Expand Down Expand Up @@ -402,7 +402,7 @@ func TestVerifySubjectInternalWithDecision_MultipleArtifacts_ExpectedResults(t *
},
}
ver := &TestVerifier{
CanVerifyFunc: func(at string) bool {
CanVerifyFunc: func(_ string) bool {
return true
},
VerifyResult: func(artifactType string) bool {
Expand Down Expand Up @@ -460,7 +460,7 @@ func TestVerifySubjectInternal_NestedReferences_Expected(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == mocks.SbomArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
nestedReferences: []string{"string-content-does-not-matter"},
Expand All @@ -470,7 +470,7 @@ func TestVerifySubjectInternal_NestedReferences_Expected(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == mocks.SignatureArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
}
Expand Down Expand Up @@ -538,7 +538,7 @@ func TestVerifySubjectInternal_NoNestedReferences_Expected(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == mocks.SbomArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
}
Expand All @@ -547,7 +547,7 @@ func TestVerifySubjectInternal_NoNestedReferences_Expected(t *testing.T) {
CanVerifyFunc: func(at string) bool {
return at == mocks.SignatureArtifactType
},
VerifyResult: func(artifactType string) bool {
VerifyResult: func(_ string) bool {
return true
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/keymanagementprovider/azurekeyvault/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestCreate(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
initKVClient = func(ctx context.Context, keyVaultEndpoint, tenantID, clientID string) (*kv.BaseClient, error) {
initKVClient = func(_ context.Context, _, _, _ string) (*kv.BaseClient, error) {
return &kv.BaseClient{}, nil
}
_, err := factory.Create("v1", tc.config, "")
Expand Down Expand Up @@ -224,7 +224,7 @@ func TestGetKeys(t *testing.T) {
},
}

initKVClient = func(ctx context.Context, keyVaultEndpoint, tenantID, clientID string) (*kv.BaseClient, error) {
initKVClient = func(_ context.Context, _, _, _ string) (*kv.BaseClient, error) {
return &kv.BaseClient{}, nil
}
provider, err := factory.Create("v1", config, "")
Expand Down
4 changes: 2 additions & 2 deletions pkg/referrerstore/oras/oras.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ func createBaseStore(version string, storeConfig config.StorePluginConfig) (*ora
insecureTransport.MaxIdleConnsPerHost = HTTPMaxIdleConnsPerHost
// #nosec G402
insecureTransport.TLSClientConfig = &tls.Config{
InsecureSkipVerify: true,
InsecureSkipVerify: true, //nolint:gosec
}
insecureRetryTransport := retry.NewTransport(insecureTransport)
insecureRetryTransport.Policy = customRetryPolicy
Expand Down Expand Up @@ -437,7 +437,7 @@ func createDefaultRepository(ctx context.Context, store *orasStore, targetRef co
}

// set the provider to return the resolved credentials
credentialProvider := func(ctx context.Context, registry string) (auth.Credential, error) {
credentialProvider := func(_ context.Context, _ string) (auth.Credential, error) {
if authConfig.Username != "" || authConfig.Password != "" || authConfig.IdentityToken != "" {
return auth.Credential{
Username: authConfig.Username,
Expand Down
12 changes: 6 additions & 6 deletions pkg/referrerstore/oras/oras_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestORASListReferrers_SubjectDesc(t *testing.T) {
},
},
}
store.createRepository = func(ctx context.Context, store *orasStore, targetRef common.Reference) (registry.Repository, error) {
store.createRepository = func(_ context.Context, _ *orasStore, _ common.Reference) (registry.Repository, error) {
return testRepo, nil
}
inputRef := common.Reference{
Expand Down Expand Up @@ -158,7 +158,7 @@ func TestORASListReferrers_NoSubjectDesc(t *testing.T) {
},
},
}
store.createRepository = func(ctx context.Context, store *orasStore, targetRef common.Reference) (registry.Repository, error) {
store.createRepository = func(_ context.Context, _ *orasStore, _ common.Reference) (registry.Repository, error) {
return testRepo, nil
}
inputRef := common.Reference{
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestORASGetReferenceManifest_CachedDesc(t *testing.T) {
artifactDigest: io.NopCloser(bytes.NewReader(manifestNotCachedBytes)),
},
}
store.createRepository = func(ctx context.Context, store *orasStore, targetRef common.Reference) (registry.Repository, error) {
store.createRepository = func(_ context.Context, _ *orasStore, _ common.Reference) (registry.Repository, error) {
return testRepo, nil
}
store.localCache = mocks.TestStorage{
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestORASGetReferenceManifest_NotCachedDesc(t *testing.T) {
artifactDigest: io.NopCloser(bytes.NewReader(manifestNotCachedBytes)),
},
}
store.createRepository = func(ctx context.Context, store *orasStore, targetRef common.Reference) (registry.Repository, error) {
store.createRepository = func(_ context.Context, _ *orasStore, _ common.Reference) (registry.Repository, error) {
return testRepo, nil
}
store.localCache = mocks.TestStorage{
Expand Down Expand Up @@ -346,7 +346,7 @@ func TestORASGetBlobContent_CachedDesc(t *testing.T) {
},
},
}
store.createRepository = func(ctx context.Context, store *orasStore, targetRef common.Reference) (registry.Repository, error) {
store.createRepository = func(_ context.Context, _ *orasStore, _ common.Reference) (registry.Repository, error) {
return testRepo, nil
}
store.localCache = mocks.TestStorage{
Expand Down Expand Up @@ -393,7 +393,7 @@ func TestORASGetBlobContent_NotCachedDesc(t *testing.T) {
},
},
}
store.createRepository = func(ctx context.Context, store *orasStore, targetRef common.Reference) (registry.Repository, error) {
store.createRepository = func(_ context.Context, _ *orasStore, _ common.Reference) (registry.Repository, error) {
return testRepo, nil
}
store.localCache = mocks.TestStorage{
Expand Down
Loading

0 comments on commit f8c7beb

Please sign in to comment.