Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add make target script
Browse files Browse the repository at this point in the history
wilkermichael committed Feb 9, 2024

Verified

This commit was signed with the committer’s verified signature.
rouault Even Rouault
1 parent 4600d5d commit 24f69ca
Showing 2 changed files with 41 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -309,6 +309,14 @@ eks-test-packages: ## eks test packages
aks-test-packages: ## aks test packages
@./control-plane/build-support/scripts/set_test_package_matrix.sh "acceptance/ci-inputs/aks_acceptance_test_packages.yaml"

.PHONY: go-mod-tidy
go-mod-tidy: ## Recursively run go mod tidy on all subdirectories
@./control-plane/build-support/scripts/mod_tidy.sh

.PHONY: check-mod-tidy
check-mod-tidy: ## Recursively run go mod tidy on all subdirectories and check if there are any changes
@./control-plane/build-support/scripts/mod_tidy.sh --check

##@ Release Targets

.PHONY: check-env
33 changes: 33 additions & 0 deletions control-plane/build-support/scripts/mod_tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

CHECK=false

# Check if the --check argument is passed
for arg in "$@"
do
if [ "$arg" == "--check" ]
then
CHECK=true
fi
done

# Find directories containing a go.mod file
for dir in $(find . -type f -name go.mod -exec dirname {} \;); do
# Change into the directory
cd "$dir" || exit

# Run go mod tidy
echo "Running go mod tidy in $dir"
go mod tidy

# Change back to the original directory
cd - || exit
done

# Check for differences if the --check argument was passed
if [ "$CHECK" = true ]; then
if [[ -n "$(git status --porcelain)" ]]; then
echo "differences were found in go.mod or go.sum, run go mod tidy to fix them"
exit 1
fi
fi

0 comments on commit 24f69ca

Please sign in to comment.