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

Replace kubeval with kubeconform for static analysis #52

Merged
merged 1 commit into from
Feb 17, 2022
Merged
Show file tree
Hide file tree
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
10 changes: 4 additions & 6 deletions .github/actions/tools/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,25 @@ set -eu

YQ_VERSION="v4.6.1"
KUSTOMIZE_VERSION="4.5.2"
KUBEVAL_VERSION="0.15.0"
KUBECONFORM_VERSION="0.4.12"

mkdir -p $GITHUB_WORKSPACE/bin
cd $GITHUB_WORKSPACE/bin

curl -sL https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -o yq

cp ./yq $GITHUB_WORKSPACE/bin
chmod +x $GITHUB_WORKSPACE/bin/yq

kustomize_url=https://github.com/kubernetes-sigs/kustomize/releases/download && \
curl -sL ${kustomize_url}/kustomize%2Fv${KUSTOMIZE_VERSION}/kustomize_v${KUSTOMIZE_VERSION}_linux_amd64.tar.gz | \
tar xz

cp ./kustomize $GITHUB_WORKSPACE/bin
chmod +x $GITHUB_WORKSPACE/bin/kustomize

curl -sL https://github.com/instrumenta/kubeval/releases/download/${KUBEVAL_VERSION}/kubeval-linux-amd64.tar.gz | \
curl -sL https://github.com/yannh/kubeconform/releases/download/v${KUBECONFORM_VERSION}/kubeconform-linux-amd64.tar.gz | \
tar xz

cp ./kubeval $GITHUB_WORKSPACE/bin
chmod +x $GITHUB_WORKSPACE/bin/kubeval
chmod +x $GITHUB_WORKSPACE/bin/kubeconform

echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH
echo "$RUNNER_WORKSPACE/$(basename $GITHUB_REPOSITORY)/bin" >> $GITHUB_PATH
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -526,5 +526,5 @@ a pull requests is merged into the main branch and synced on the cluster.

This repository contains the following GitHub CI workflows:

* the [test](./.github/workflows/test.yaml) workflow validates the Kubernetes manifests and Kustomize overlays with kubeval
* the [test](./.github/workflows/test.yaml) workflow validates the Kubernetes manifests and Kustomize overlays with [kubeconform](https://github.com/yannh/kubeconform)
* the [e2e](./.github/workflows/e2e.yaml) workflow starts a Kubernetes cluster in CI and tests the staging setup by running Flux in Kubernetes Kind
10 changes: 6 additions & 4 deletions scripts/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@

# Prerequisites
# - yq v4.6
# - kustomize v4.5
# - kubeval v0.15
# - kustomize v4.1
# - kubeconform v0.4.12

set -o errexit

Expand All @@ -40,10 +40,12 @@ find . -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
yq e 'true' "$file" > /dev/null
done

kubeconform_config="-strict -ignore-missing-schemas -schema-location default -schema-location /tmp/flux-crd-schemas -verbose"

echo "INFO - Validating clusters"
find ./clusters -maxdepth 2 -type f -name '*.yaml' -print0 | while IFS= read -r -d $'\0' file;
do
kubeval ${file} --strict --ignore-missing-schemas --additional-schema-locations=file:///tmp/flux-crd-schemas
kubeconform $kubeconform_config ${file}
if [[ ${PIPESTATUS[0]} != 0 ]]; then
exit 1
fi
Expand All @@ -58,7 +60,7 @@ find . -type f -name $kustomize_config -print0 | while IFS= read -r -d $'\0' fil
do
echo "INFO - Validating kustomization ${file/%$kustomize_config}"
kustomize build "${file/%$kustomize_config}" $kustomize_flags | \
kubeval --ignore-missing-schemas --strict --additional-schema-locations=file:///tmp/flux-crd-schemas
kubeconform $kubeconform_config
if [[ ${PIPESTATUS[0]} != 0 ]]; then
exit 1
fi
Expand Down