Skip to content

Commit

Permalink
UPSTREAM: <carry>: openshift: Extend makefile with 'make goimports' t…
Browse files Browse the repository at this point in the history
…arget

So the target can be run in CI and fail in case files are not properly goimport formated.
  • Loading branch information
ingvagabund authored and enxebre committed Oct 28, 2019
1 parent 8e8c4d4 commit 8d95ce2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,7 @@ fmt: ## Go fmt your code
.PHONY: vet
vet: ## Go fmt your code
hack/go-vet.sh ./cluster-autoscaler/cloudprovider/openshiftmachineapi

.PHONY: goimports
goimports: ## Go fmt your code
hack/goimports.sh ./cluster-autoscaler/cloudprovider/openshiftmachineapi
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

0 comments on commit 8d95ce2

Please sign in to comment.