Skip to content

Commit

Permalink
Merge pull request #830 from youngnick/1-17-codegen
Browse files Browse the repository at this point in the history
Fix CI failures for Go 1.17 and verifying invalid examples
  • Loading branch information
k8s-ci-robot authored Aug 26, 2021
2 parents 8343da8 + fedcdda commit 4ebc7e2
Show file tree
Hide file tree
Showing 20 changed files with 45 additions and 16 deletions.
1 change: 1 addition & 0 deletions apis/v1alpha1/zz_generated.deepcopy.go

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

1 change: 1 addition & 0 deletions apis/v1alpha2/zz_generated.deepcopy.go

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

6 changes: 4 additions & 2 deletions hack/boilerplate/boilerplate.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,11 @@ def get_regexs():
# get_dates return 2014, 2015, 2016, 2017, or 2018 until the current year as a regex like: "(2014|2015|2016|2017|2018)";
# company holder names can be anything
regexs["date"] = re.compile(get_dates())
# strip // +build \n\n build constraints
# strip the following build constraints/tags:
# //go:build
# // +build \n\n
regexs["go_build_constraints"] = re.compile(
r"^(// \+build.*\n)+\n", re.MULTILINE)
r"^(//(go:build| \+build).*\n)+\n", re.MULTILINE)
# strip #!.* from scripts
regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE)
# Search for generated files
Expand Down
7 changes: 6 additions & 1 deletion hack/verify-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,12 @@ do
ret=1
fi
else
bash "$t" || ret=1
if bash "$t"; then
echo -e "${color_green}SUCCESS: $t ${color_norm}"
else
echo -e "${color_red}Test FAILED: $t ${color_norm}"
ret=1
fi
fi
done

Expand Down
46 changes: 33 additions & 13 deletions hack/verify-examples-kind.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,24 +51,44 @@ res=0
KIND_CREATE_ATTEMPTED=true
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || res=$?

for VERSION in v1alpha1 v1alpha2
do
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
##### Test v1alpha1 CRD apply
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?

# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/"${VERSION}" || res=$?
# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha1 || res=$?

# Uninstall CRDs
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
done
# Uninstall CRDs
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?

# None of these examples should be successfully configured
kubectl apply --recursive -f hack/invalid-examples | grep configured && res=2
##### Test v1alpha2 CRD apply and that invalid examples are invalid.
# Install CRDs
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha2 || res=$?

# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
sleep 8

# Install all example gateway-api resources.
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha2 || res=$?

# Install invalid gateway-api resources.
# None of these examples should be successfully configured
# This is very hacky, sorry.
# Firstly, apply the examples, remembering that errors are on stdout
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f hack/invalid-examples 2>&1 | \
# First, we grep out the expected responses.
# After this, if everything is as expected, the output should be empty.
grep -v 'is invalid' | \
grep -v 'missing required field' | \
# Then, we grep for anything else.
# If anything else is found, this will return 0
# which is *not* what we want.
grep -e '.' && \
res=2 || \
echo Examples failed as expected
# Clean up and exit
cleanup || res=$?
exit $res

0 comments on commit 4ebc7e2

Please sign in to comment.