Skip to content

Commit

Permalink
fix: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
NewbMiao committed Feb 5, 2024
1 parent 9604a1a commit 3b1e1cf
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 8 deletions.
9 changes: 7 additions & 2 deletions demos/entitlements/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ set -eu
workspace=$(cd "$(dirname "$0")" && pwd -P)
{
cd "$workspace" || exit
files=$(ls -1 *.rego | grep -v _test.rego | xargs)
opa build -t wasm -e entitlements $files
files=()
for file in *.rego; do
if [[ $file != *_test.rego ]]; then
files+=("$file")
fi
done
opa build -t wasm -e entitlements "${files[@]}"
tar -xf bundle.tar.gz "/policy.wasm"
mv policy.wasm ../node-wasm/
rm bundle.tar.gz
Expand Down
1 change: 0 additions & 1 deletion demos/entitlements/rules/purchaseManagement.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ purchaseManagment:
product:
money_available:
min: 1

1 change: 0 additions & 1 deletion demos/entitlements/utils.rego
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package entitlements

fullVersion(product) = concat(".", [product.version, product.sub_version])

2 changes: 1 addition & 1 deletion scripts/regoFmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ workspace=$(cd "$(dirname "$0")" && pwd -P)
cd "$workspace"/../ || exit
echo "Rego Fmting"
# shellcheck disable=SC2046
docker run --rm -v "$(pwd)":/code -w /code openpolicyagent/opa:"${opa_version}" fmt -w $(find . -type f -name '*.rego' ! -path '*/node_modules/*' ! -path '*/.go-cache/*')
docker run --platform linux/amd64 --rm -v "$(pwd)":/code -w /code openpolicyagent/opa:"${opa_version}" fmt -w $(find . -type f -name '*.rego' ! -path '*/node_modules/*' ! -path '*/.go-cache/*')
}
2 changes: 1 addition & 1 deletion scripts/regoLint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ workspace=$(cd "$(dirname "$0")" && pwd -P)
cd "$workspace"/../ || exit
echo "Rego Linting"
# shellcheck disable=SC2046
unfmts=$(docker run --rm -v "$(pwd)":/code -w /code openpolicyagent/opa:"$opa_version" fmt -l $(find . -type f -name '*.rego' ! -path '*/node_modules/*' ! -path '*/.go-cache/*'))
unfmts=$(docker run --platform linux/amd64 --rm -v "$(pwd)":/code -w /code openpolicyagent/opa:"$opa_version" fmt -l $(find . -type f -name '*.rego' ! -path '*/node_modules/*' ! -path '*/.go-cache/*'))
if [ "$unfmts" != "" ]; then
echo "Found unforamt rego files:"
echo "$unfmts"
Expand Down
2 changes: 1 addition & 1 deletion scripts/regoTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ workspace=$(cd "$(dirname "$0")" && pwd -P)
opa_version="${1:-latest}"
cd "$workspace"/../ || exit
echo "Rego Testing"
docker run --rm -v "$(pwd)":/code -w /code openpolicyagent/opa:"$opa_version" test -c --threshold 100 quick-start
docker run --platform linux/amd64 --rm -v "$(pwd)":/code -w /code openpolicyagent/opa:"$opa_version" test -c --threshold 100 quick-start
}
2 changes: 1 addition & 1 deletion scripts/yamlLint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ workspace=$(cd "$(dirname "$0")" && pwd -P)
cd "$workspace"/../ || exit
echo "Yaml Linting"
# shellcheck disable=SC2046
docker run --rm -v "$(pwd)":/workdir giantswarm/yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" $(find . -type f \( -name '*.yaml' -or -name '*.yml' \) ! -path '*/.github/*' ! -path '*/.go-cache/*')
docker run --platform linux/amd64 --rm -v "$(pwd)":/workdir giantswarm/yamllint -d "{extends: relaxed, rules: {line-length: {max: 120}}}" $(find . -type f \( -name '*.yaml' -or -name '*.yml' \) ! -path '*/.github/*' ! -path '*/.go-cache/*')
}

0 comments on commit 3b1e1cf

Please sign in to comment.