Skip to content

Commit

Permalink
build: bump golangci-lint version in build image (#3195)
Browse files Browse the repository at this point in the history
  • Loading branch information
hairyhum authored Oct 23, 2024
1 parent 9e25955 commit fa2649b
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ linters-settings:
skip-generated: true
stylecheck:
checks: [ "all", "-ST1001", "-ST1005", "-ST1016", "-ST1023", "-ST1000"]
errcheck:
exclude-functions:
- fmt.Fprintln

exclude-dirs:
- pkg/client/applyconfiguration/cr/v1alpha1 # generated from code-gen
Expand Down
2 changes: 1 addition & 1 deletion docker/build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ COPY --from=goreleaser/goreleaser:v1.26.2 /usr/bin/goreleaser /usr/local/bin/

COPY --from=alpine/helm:3.12.2 /usr/bin/helm /usr/local/bin/

COPY --from=golangci/golangci-lint:v1.57.2 /usr/bin/golangci-lint /usr/local/bin/
COPY --from=golangci/golangci-lint:v1.60.1 /usr/bin/golangci-lint /usr/local/bin/

RUN wget -O /usr/local/bin/kind \
https://github.com/kubernetes-sigs/kind/releases/download/v0.18.0/kind-$(echo $TARGETPLATFORM | tr / -) \
Expand Down
2 changes: 1 addition & 1 deletion pkg/function/create_volume_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func createVolumeSnapshot(ctx context.Context, tp param.TemplateParams, cli kube
}
wg.Wait()

err := fmt.Errorf(strings.Join(errstrings, "\n"))
err := errkit.New(strings.Join(errstrings, "\n"))
if len(err.Error()) > 0 {
return nil, errkit.Wrap(err, "Failed to snapshot one of the volumes")
}
Expand Down
22 changes: 11 additions & 11 deletions pkg/function/delete_rds_snapshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,22 @@ func (*deleteRDSSnapshotFunc) Name() string {
return DeleteRDSSnapshotFuncName
}

func deleteRDSSnapshot(ctx context.Context, snapshotID string, profile *param.Profile, dbEngine RDSDBEngine) (map[string]interface{}, error) {
func deleteRDSSnapshot(ctx context.Context, snapshotID string, profile *param.Profile, dbEngine RDSDBEngine) error {
// Validate profile
if err := ValidateProfile(profile); err != nil {
return nil, errkit.Wrap(err, "Profile Validation failed")
return errkit.Wrap(err, "Profile Validation failed")
}

// Get aws config from profile
awsConfig, region, err := getAWSConfigFromProfile(ctx, profile)
if err != nil {
return nil, errkit.Wrap(err, "Failed to get AWS creds from profile")
return errkit.Wrap(err, "Failed to get AWS creds from profile")
}

// Create rds client
rdsCli, err := rds.NewClient(ctx, awsConfig, region)
if err != nil {
return nil, errkit.Wrap(err, "Failed to create RDS client")
return errkit.Wrap(err, "Failed to create RDS client")
}

if !isAuroraCluster(string(dbEngine)) {
Expand All @@ -82,16 +82,16 @@ func deleteRDSSnapshot(ctx context.Context, snapshotID string, profile *param.Pr
switch err.Code() {
case awsrds.ErrCodeDBSnapshotNotFoundFault:
log.WithContext(ctx).Print("Could not find matching RDS snapshot; might have been deleted previously", field.M{"SnapshotId": snapshotID})
return nil, nil
return nil
default:
return nil, errkit.Wrap(err, "Failed to delete snapshot")
return errkit.Wrap(err, "Failed to delete snapshot")
}
}
}
// Wait until snapshot is deleted
log.WithContext(ctx).Print("Waiting for RDS snapshot to be deleted", field.M{"SnapshotID": snapshotID})
err = rdsCli.WaitUntilDBSnapshotDeleted(ctx, snapshotID)
return nil, errkit.Wrap(err, "Error while waiting for snapshot to be deleted")
return errkit.Wrap(err, "Error while waiting for snapshot to be deleted")
}

// delete Aurora DB cluster snapshot
Expand All @@ -102,17 +102,17 @@ func deleteRDSSnapshot(ctx context.Context, snapshotID string, profile *param.Pr
switch err.Code() {
case awsrds.ErrCodeDBClusterSnapshotNotFoundFault:
log.WithContext(ctx).Print("Could not find matching Aurora DB cluster snapshot; might have been deleted previously", field.M{"SnapshotId": snapshotID})
return nil, nil
return nil
default:
return nil, errkit.Wrap(err, "Error deleting Aurora DB cluster snapshot")
return errkit.Wrap(err, "Error deleting Aurora DB cluster snapshot")
}
}
}

log.WithContext(ctx).Print("Waiting for Aurora DB cluster snapshot to be deleted")
err = rdsCli.WaitUntilDBClusterDeleted(ctx, snapshotID)

return nil, errkit.Wrap(err, "Error waiting for Aurora DB cluster snapshot to be deleted")
return errkit.Wrap(err, "Error waiting for Aurora DB cluster snapshot to be deleted")
}

func (d *deleteRDSSnapshotFunc) Exec(ctx context.Context, tp param.TemplateParams, args map[string]interface{}) (map[string]interface{}, error) {
Expand All @@ -130,7 +130,7 @@ func (d *deleteRDSSnapshotFunc) Exec(ctx context.Context, tp param.TemplateParam
return nil, err
}

return deleteRDSSnapshot(ctx, snapshotID, tp.Profile, dbEngine)
return nil, deleteRDSSnapshot(ctx, snapshotID, tp.Profile, dbEngine)
}

func (*deleteRDSSnapshotFunc) RequiredArgs() []string {
Expand Down
2 changes: 1 addition & 1 deletion pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (*healthCheckHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
w.WriteHeader(http.StatusOK)
w.Header().Set("Content-Type", "application/json")
_, _ = io.WriteString(w, string(js))
_, _ = io.Writer.Write(w, js)
}

// RunWebhookServer starts the validating webhook resources for blueprint kanister resources
Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func GetPodObjectFromPodOptions(ctx context.Context, cli kubernetes.Interface, o
ServiceAccountName: sa,
}

if opts.EnvironmentVariables != nil && len(opts.EnvironmentVariables) > 0 {
if len(opts.EnvironmentVariables) > 0 {
defaultSpecs.Containers[0].Env = opts.EnvironmentVariables
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/kube/pod_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ func (s *PodSuite) TestPod(c *check.C) {
c.Assert(pod.Spec.RestartPolicy, check.Equals, po.RestartPolicy)
}

if po.EnvironmentVariables != nil && len(po.EnvironmentVariables) > 0 {
if len(po.EnvironmentVariables) > 0 {
c.Assert(pod.Spec.Containers[0].Env, check.DeepEquals, po.EnvironmentVariables)
}

Expand Down

0 comments on commit fa2649b

Please sign in to comment.