Skip to content

Commit 4ebc7e2

Browse files
authored
Merge pull request #830 from youngnick/1-17-codegen
Fix CI failures for Go 1.17 and verifying invalid examples
2 parents 8343da8 + fedcdda commit 4ebc7e2

20 files changed

+45
-16
lines changed

apis/v1alpha1/zz_generated.deepcopy.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apis/v1alpha2/zz_generated.deepcopy.go

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/boilerplate/boilerplate.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,11 @@ def get_regexs():
227227
# get_dates return 2014, 2015, 2016, 2017, or 2018 until the current year as a regex like: "(2014|2015|2016|2017|2018)";
228228
# company holder names can be anything
229229
regexs["date"] = re.compile(get_dates())
230-
# strip // +build \n\n build constraints
230+
# strip the following build constraints/tags:
231+
# //go:build
232+
# // +build \n\n
231233
regexs["go_build_constraints"] = re.compile(
232-
r"^(// \+build.*\n)+\n", re.MULTILINE)
234+
r"^(//(go:build| \+build).*\n)+\n", re.MULTILINE)
233235
# strip #!.* from scripts
234236
regexs["shebang"] = re.compile(r"^(#!.*\n)\n*", re.MULTILINE)
235237
# Search for generated files

hack/verify-all.sh

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,12 @@ do
6969
ret=1
7070
fi
7171
else
72-
bash "$t" || ret=1
72+
if bash "$t"; then
73+
echo -e "${color_green}SUCCESS: $t ${color_norm}"
74+
else
75+
echo -e "${color_red}Test FAILED: $t ${color_norm}"
76+
ret=1
77+
fi
7378
fi
7479
done
7580

hack/verify-examples-kind.sh

+33-13
Original file line numberDiff line numberDiff line change
@@ -51,24 +51,44 @@ res=0
5151
KIND_CREATE_ATTEMPTED=true
5252
kind create cluster --name "${CLUSTER_NAME}" --kubeconfig "${KUBECONFIG}" || res=$?
5353

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

59-
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
60-
sleep 8
58+
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
59+
sleep 8
6160

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

65-
# Uninstall CRDs
66-
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/"${VERSION}" || res=$?
67-
done
64+
# Uninstall CRDs
65+
kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$?
6866

69-
# None of these examples should be successfully configured
70-
kubectl apply --recursive -f hack/invalid-examples | grep configured && res=2
67+
##### Test v1alpha2 CRD apply and that invalid examples are invalid.
68+
# Install CRDs
69+
kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha2 || res=$?
70+
71+
# Temporary workaround for https://github.com/kubernetes/kubernetes/issues/104090
72+
sleep 8
7173

74+
# Install all example gateway-api resources.
75+
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha2 || res=$?
76+
77+
# Install invalid gateway-api resources.
78+
# None of these examples should be successfully configured
79+
# This is very hacky, sorry.
80+
# Firstly, apply the examples, remembering that errors are on stdout
81+
kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f hack/invalid-examples 2>&1 | \
82+
# First, we grep out the expected responses.
83+
# After this, if everything is as expected, the output should be empty.
84+
grep -v 'is invalid' | \
85+
grep -v 'missing required field' | \
86+
# Then, we grep for anything else.
87+
# If anything else is found, this will return 0
88+
# which is *not* what we want.
89+
grep -e '.' && \
90+
res=2 || \
91+
echo Examples failed as expected
7292
# Clean up and exit
7393
cleanup || res=$?
7494
exit $res

0 commit comments

Comments
 (0)