Skip to content

Commit a12b4bd

Browse files
Merge pull request #328 from cert-manager/revert-312-simplify-golangci-lint
Revert "Simplify GCI golangci-lint config with localmodule"
2 parents e8fadfa + 9615b46 commit a12b4bd

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

modules/go/.golangci.override.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ formatters:
7272
sections:
7373
- standard # Standard section: captures all standard packages.
7474
- default # Default section: contains all imports that could not be matched to another section type.
75-
- localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled.
75+
- prefix({{REPO-NAME}}) # Custom section: groups all imports with the specified Prefix.
7676
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
7777
- dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled.
7878
exclusions:

modules/go/01_mod.mk

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ ifndef bin_dir
1616
$(error bin_dir is not set)
1717
endif
1818

19+
ifndef repo_name
20+
$(error repo_name is not set)
21+
endif
22+
1923
golangci_lint_override := $(dir $(lastword $(MAKEFILE_LIST)))/.golangci.override.yaml
2024

2125
.PHONY: go-workspace
@@ -115,6 +119,7 @@ generate-golangci-lint-config: | $(NEEDS_GOLANGCI-LINT) $(NEEDS_YQ) $(bin_dir)/s
115119
cp $(golangci_lint_config) $(bin_dir)/scratch/golangci-lint.yaml.tmp
116120
$(YQ) -i 'del(.linters.enable)' $(bin_dir)/scratch/golangci-lint.yaml.tmp
117121
$(YQ) eval-all -i '. as $$item ireduce ({}; . * $$item)' $(bin_dir)/scratch/golangci-lint.yaml.tmp $(golangci_lint_override)
122+
$(YQ) -i '(.. | select(tag == "!!str")) |= sub("{{REPO-NAME}}", "$(repo_name)")' $(bin_dir)/scratch/golangci-lint.yaml.tmp
118123
mv $(bin_dir)/scratch/golangci-lint.yaml.tmp $(golangci_lint_config)
119124

120125
shared_generate_targets += generate-golangci-lint-config

0 commit comments

Comments
 (0)