Skip to content

Commit

Permalink
refactor: Fix up golines config for linting
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmidyson committed Jun 22, 2023
1 parent 1853180 commit 4e3e548
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 8 deletions.
2 changes: 2 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ repos:
rev: v1.0.0-rc.1
hooks:
- id: go-mod-tidy
stages: [commit]
- id: golangci-lint-mod
stages: [commit]
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
Expand Down
31 changes: 25 additions & 6 deletions cmd/mindthegap/push/bundle/bundle.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,9 @@ func NewCommand(out output.Output, bundleCmdName string) *cobra.Command {
// If a password hasn't been specified, then try to retrieve a token.
if destRegistryPassword == "" {
out.StartOperation("Retrieving ECR credentials")
destRegistryUsername, destRegistryPassword, err = ecr.RetrieveUsernameAndToken(ecrClient)
destRegistryUsername, destRegistryPassword, err = ecr.RetrieveUsernameAndToken(
ecrClient,
)
if err != nil {
out.EndOperationWithStatus(output.Failure())
return fmt.Errorf(
Expand Down Expand Up @@ -171,11 +173,17 @@ func NewCommand(out output.Output, bundleCmdName string) *cobra.Command {
}
destRemoteOpts = append(destRemoteOpts, remote.WithAuthFromKeychain(keychain))

srcRegistry, err := name.NewRegistry(reg.Address(), name.Insecure, name.StrictValidation)
srcRegistry, err := name.NewRegistry(
reg.Address(),
name.Insecure,
name.StrictValidation,
)
if err != nil {
return err
}
destRegistry, err := name.NewRegistry(destRegistryURI.Host(), append(destNameOpts, name.StrictValidation)...)
destRegistry, err := name.NewRegistry(
destRegistryURI.Host(),
append(destNameOpts, name.StrictValidation)...)
if err != nil {
return err
}
Expand Down Expand Up @@ -297,7 +305,12 @@ func pushImages(
}
}

existingImageTags, err := getExistingImages(context.Background(), onExistingTag, puller, destRepository)
existingImageTags, err := getExistingImages(
context.Background(),
onExistingTag,
puller,
destRepository,
)
if err != nil {
return err
}
Expand Down Expand Up @@ -364,7 +377,10 @@ func pushOCIArtifacts(
chartNames := repoConfig.SortedChartNames()

for _, chartName := range chartNames {
srcRepository := sourceRegistry.Repo(strings.TrimLeft(sourceRegistryPath, "/"), chartName)
srcRepository := sourceRegistry.Repo(
strings.TrimLeft(sourceRegistryPath, "/"),
chartName,
)
destRepository := destRegistry.Repo(strings.TrimLeft(destRegistryPath, "/"), chartName)

chartVersions := repoConfig.Charts[chartName]
Expand Down Expand Up @@ -406,7 +422,10 @@ func pushOCIArtifacts(
}

func getExistingImages(
ctx context.Context, onExistingTag onExistingTagMode, puller *remote.Puller, repo name.Repository,
ctx context.Context,
onExistingTag onExistingTagMode,
puller *remote.Puller,
repo name.Repository,
) (map[string]struct{}, error) {
if onExistingTag == Overwrite {
return nil, nil
Expand Down
4 changes: 3 additions & 1 deletion docker/ecr/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ func RetrieveUsernameAndToken(ecrClient *ecr.Client) (username, token string, er
// guaranteed.
base64EncodedAuthorizationToken := aws.ToString(out.AuthorizationData[0].AuthorizationToken)

decodedAuthorizationToken, err := base64.StdEncoding.DecodeString(base64EncodedAuthorizationToken)
decodedAuthorizationToken, err := base64.StdEncoding.DecodeString(
base64EncodedAuthorizationToken,
)
if err != nil {
return "", "", err
}
Expand Down
2 changes: 1 addition & 1 deletion make/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ endif
.PHONY: lint.%
lint.%: ## Runs golangci-lint for a specific module
lint.%: ; $(info $(M) linting $* module)
$(if $(filter-out root,$*),cd $* && )golines -w $$(go list ./... | sed "s|^$$(go list -m)|.|")
$(if $(filter-out root,$*),cd $* && )golangci-lint run --fix --config=$(GOLANGCI_CONFIG_FILE)
$(if $(filter-out root,$*),cd $* && )golines -w $$(go list ./... | sed "s|^$$(go list -m)|.|")
$(if $(filter-out root,$*),cd $* && )go fix ./...

.PHONY: mod-tidy
Expand Down

0 comments on commit 4e3e548

Please sign in to comment.