Skip to content

Commit

Permalink
Merge pull request #252 from ingvagabund/add-goimports-into-makefile
Browse files Browse the repository at this point in the history
Add goimports into makefile
  • Loading branch information
openshift-merge-robot authored Aug 22, 2019
2 parents 117d609 + 6b25a04 commit 0278133
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ lint: ## Go lint your code
fmt: ## Go fmt your code
hack/go-fmt.sh .

.PHONY: goimports
goimports: ## Go fmt your code
hack/goimports.sh .

.PHONY: vet
vet: ## Apply go vet to all go files
hack/go-vet.sh ./...
Expand Down
16 changes: 16 additions & 0 deletions hack/goimports.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/sh

REPO_NAME=$(basename "${PWD}")
if [ "$IS_CONTAINER" != "" ]; then
for TARGET in "${@}"; do
find "${TARGET}" -name '*.go' ! -path '*/vendor/*' ! -path '*/.build/*' -exec goimports -w {} \+
done
git diff --exit-code
else
docker run -it --rm \
--env IS_CONTAINER=TRUE \
--volume "${PWD}:/go/src/sigs.k8s.io/${REPO_NAME}:z" \
--workdir "/go/src/sigs.k8s.io/${REPO_NAME}" \
openshift/origin-release:golang-1.12 \
./hack/goimports.sh "${@}"
fi
3 changes: 2 additions & 1 deletion pkg/client/mock/client_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0278133

Please sign in to comment.