Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make fmt-imports #855

Merged
merged 1 commit into from
Dec 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ boilerplate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto,
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: generate
generate: userconfigs boilerplate imports manifests docs charts fmt ## Run all code generation targets.
generate: userconfigs boilerplate fmt-imports manifests docs charts fmt ## Run all code generation targets.

.PHONY: fmt
fmt: ## Format code.
Expand All @@ -73,10 +73,15 @@ fmt: ## Format code.
vet: ## Run go vet against code.
go vet ./...

# On MACOS requires gnu-sed. Run `brew info gnu-sed` and follow instructions to replace default sed.
.PHONY: imports
imports: ## Run goimports against code.
find . -type f -name '*.go' -exec sed -zi 's/"\n\+\t"/"\n"/g' {} +
.PHONY: fmt-imports
# macOS requires to install GNU sed first. Use `brew install gnu-sed` to install it.
# It has to be added to PATH as `sed` command, to replace default BSD sed.
# See `brew info gnu-sed` for more details on how to add it to PATH.
# /^import ($$/: starts with "import ("
# /^)/: ends with ")"
# /^[[:space:]]*$$/: empty lines
fmt-imports:
find . -type f -name '*.go' -exec sed -i '/^import ($$/,/^)/ {/^[[:space:]]*$$/d}' {} +
goimports -local "github.com/aiven/aiven-operator" -w .

##@ Checks
Expand Down
Loading