From 284e48bb54a52cc7a726112399b03db27d8d4e3c Mon Sep 17 00:00:00 2001 From: Nick Young Date: Thu, 26 Aug 2021 00:13:37 +0000 Subject: [PATCH 1/5] Update generated files for Go 1.17 Signed-off-by: Nick Young --- apis/v1alpha1/zz_generated.deepcopy.go | 1 + apis/v1alpha2/zz_generated.deepcopy.go | 1 + 2 files changed, 2 insertions(+) diff --git a/apis/v1alpha1/zz_generated.deepcopy.go b/apis/v1alpha1/zz_generated.deepcopy.go index 64399d898f..81696264ad 100644 --- a/apis/v1alpha1/zz_generated.deepcopy.go +++ b/apis/v1alpha1/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* diff --git a/apis/v1alpha2/zz_generated.deepcopy.go b/apis/v1alpha2/zz_generated.deepcopy.go index 169e84c1ae..d0c786d5cf 100644 --- a/apis/v1alpha2/zz_generated.deepcopy.go +++ b/apis/v1alpha2/zz_generated.deepcopy.go @@ -1,3 +1,4 @@ +//go:build !ignore_autogenerated // +build !ignore_autogenerated /* From c6f4e988488f2905306bb3b82ba104586b019e00 Mon Sep 17 00:00:00 2001 From: Nick Young Date: Thu, 26 Aug 2021 06:18:16 +0000 Subject: [PATCH 2/5] Fix verify-examples-kind.sh, it was not working at all Signed-off-by: Nick Young --- .../gateway/duplicate-listeners.yaml | 0 .../gateway/invalid-listener-name.yaml | 0 .../gateway/invalid-listener-port.yaml | 0 .../gatewayclass/invalid-controller.yaml | 0 .../httproute/duplicate-header-match.yaml | 0 .../httproute/duplicate-query-match.yaml | 0 .../httproute/invalid-backend-group.yaml | 0 .../httproute/invalid-backend-kind.yaml | 0 .../httproute/invalid-backend-port.yaml | 0 .../httproute/invalid-header-name.yaml | 0 .../httproute/invalid-hostname.yaml | 0 .../httproute/invalid-method.yaml | 0 .../referencepolicy/missing-from.yaml | 0 .../referencepolicy/missing-to.yaml | 0 .../tlsroute/invalid-hostname.yaml | 0 hack/verify-examples-kind.sh | 49 ++++++++++++++----- 16 files changed, 36 insertions(+), 13 deletions(-) rename hack/invalid-examples/{ => v1alpha2}/gateway/duplicate-listeners.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/gateway/invalid-listener-name.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/gateway/invalid-listener-port.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/gatewayclass/invalid-controller.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/duplicate-header-match.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/duplicate-query-match.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/invalid-backend-group.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/invalid-backend-kind.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/invalid-backend-port.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/invalid-header-name.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/invalid-hostname.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/httproute/invalid-method.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/referencepolicy/missing-from.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/referencepolicy/missing-to.yaml (100%) rename hack/invalid-examples/{ => v1alpha2}/tlsroute/invalid-hostname.yaml (100%) diff --git a/hack/invalid-examples/gateway/duplicate-listeners.yaml b/hack/invalid-examples/v1alpha2/gateway/duplicate-listeners.yaml similarity index 100% rename from hack/invalid-examples/gateway/duplicate-listeners.yaml rename to hack/invalid-examples/v1alpha2/gateway/duplicate-listeners.yaml diff --git a/hack/invalid-examples/gateway/invalid-listener-name.yaml b/hack/invalid-examples/v1alpha2/gateway/invalid-listener-name.yaml similarity index 100% rename from hack/invalid-examples/gateway/invalid-listener-name.yaml rename to hack/invalid-examples/v1alpha2/gateway/invalid-listener-name.yaml diff --git a/hack/invalid-examples/gateway/invalid-listener-port.yaml b/hack/invalid-examples/v1alpha2/gateway/invalid-listener-port.yaml similarity index 100% rename from hack/invalid-examples/gateway/invalid-listener-port.yaml rename to hack/invalid-examples/v1alpha2/gateway/invalid-listener-port.yaml diff --git a/hack/invalid-examples/gatewayclass/invalid-controller.yaml b/hack/invalid-examples/v1alpha2/gatewayclass/invalid-controller.yaml similarity index 100% rename from hack/invalid-examples/gatewayclass/invalid-controller.yaml rename to hack/invalid-examples/v1alpha2/gatewayclass/invalid-controller.yaml diff --git a/hack/invalid-examples/httproute/duplicate-header-match.yaml b/hack/invalid-examples/v1alpha2/httproute/duplicate-header-match.yaml similarity index 100% rename from hack/invalid-examples/httproute/duplicate-header-match.yaml rename to hack/invalid-examples/v1alpha2/httproute/duplicate-header-match.yaml diff --git a/hack/invalid-examples/httproute/duplicate-query-match.yaml b/hack/invalid-examples/v1alpha2/httproute/duplicate-query-match.yaml similarity index 100% rename from hack/invalid-examples/httproute/duplicate-query-match.yaml rename to hack/invalid-examples/v1alpha2/httproute/duplicate-query-match.yaml diff --git a/hack/invalid-examples/httproute/invalid-backend-group.yaml b/hack/invalid-examples/v1alpha2/httproute/invalid-backend-group.yaml similarity index 100% rename from hack/invalid-examples/httproute/invalid-backend-group.yaml rename to hack/invalid-examples/v1alpha2/httproute/invalid-backend-group.yaml diff --git a/hack/invalid-examples/httproute/invalid-backend-kind.yaml b/hack/invalid-examples/v1alpha2/httproute/invalid-backend-kind.yaml similarity index 100% rename from hack/invalid-examples/httproute/invalid-backend-kind.yaml rename to hack/invalid-examples/v1alpha2/httproute/invalid-backend-kind.yaml diff --git a/hack/invalid-examples/httproute/invalid-backend-port.yaml b/hack/invalid-examples/v1alpha2/httproute/invalid-backend-port.yaml similarity index 100% rename from hack/invalid-examples/httproute/invalid-backend-port.yaml rename to hack/invalid-examples/v1alpha2/httproute/invalid-backend-port.yaml diff --git a/hack/invalid-examples/httproute/invalid-header-name.yaml b/hack/invalid-examples/v1alpha2/httproute/invalid-header-name.yaml similarity index 100% rename from hack/invalid-examples/httproute/invalid-header-name.yaml rename to hack/invalid-examples/v1alpha2/httproute/invalid-header-name.yaml diff --git a/hack/invalid-examples/httproute/invalid-hostname.yaml b/hack/invalid-examples/v1alpha2/httproute/invalid-hostname.yaml similarity index 100% rename from hack/invalid-examples/httproute/invalid-hostname.yaml rename to hack/invalid-examples/v1alpha2/httproute/invalid-hostname.yaml diff --git a/hack/invalid-examples/httproute/invalid-method.yaml b/hack/invalid-examples/v1alpha2/httproute/invalid-method.yaml similarity index 100% rename from hack/invalid-examples/httproute/invalid-method.yaml rename to hack/invalid-examples/v1alpha2/httproute/invalid-method.yaml diff --git a/hack/invalid-examples/referencepolicy/missing-from.yaml b/hack/invalid-examples/v1alpha2/referencepolicy/missing-from.yaml similarity index 100% rename from hack/invalid-examples/referencepolicy/missing-from.yaml rename to hack/invalid-examples/v1alpha2/referencepolicy/missing-from.yaml diff --git a/hack/invalid-examples/referencepolicy/missing-to.yaml b/hack/invalid-examples/v1alpha2/referencepolicy/missing-to.yaml similarity index 100% rename from hack/invalid-examples/referencepolicy/missing-to.yaml rename to hack/invalid-examples/v1alpha2/referencepolicy/missing-to.yaml diff --git a/hack/invalid-examples/tlsroute/invalid-hostname.yaml b/hack/invalid-examples/v1alpha2/tlsroute/invalid-hostname.yaml similarity index 100% rename from hack/invalid-examples/tlsroute/invalid-hostname.yaml rename to hack/invalid-examples/v1alpha2/tlsroute/invalid-hostname.yaml diff --git a/hack/verify-examples-kind.sh b/hack/verify-examples-kind.sh index 182fbb0327..e567caaeb5 100755 --- a/hack/verify-examples-kind.sh +++ b/hack/verify-examples-kind.sh @@ -51,24 +51,47 @@ 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 +sleep 3 -# None of these examples should be successfully configured -kubectl apply --recursive -f hack/invalid-examples | grep configured && res=2 +# Uninstall CRDs +kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$? + + +##### 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 expoected, 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 From 3d50c858e632e205c1b2855dbee259b530aba527 Mon Sep 17 00:00:00 2001 From: Nick Young Date: Thu, 26 Aug 2021 06:41:40 +0000 Subject: [PATCH 3/5] Bring in changes to boilerplate.py from k/k Signed-off-by: Nick Young --- hack/boilerplate/boilerplate.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hack/boilerplate/boilerplate.py b/hack/boilerplate/boilerplate.py index cae0cd4d11..60bc691a8f 100755 --- a/hack/boilerplate/boilerplate.py +++ b/hack/boilerplate/boilerplate.py @@ -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 From 2ee71ab764b9c71d62032fa4aa6df7fa72469cb7 Mon Sep 17 00:00:00 2001 From: Nick Young Date: Thu, 26 Aug 2021 06:47:37 +0000 Subject: [PATCH 4/5] Update verify-all.sh verbose mode to make finding the broken test easier Signed-off-by: Nick Young --- hack/verify-all.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/hack/verify-all.sh b/hack/verify-all.sh index 9c7132a713..2f67b64c17 100755 --- a/hack/verify-all.sh +++ b/hack/verify-all.sh @@ -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 From fedcdda74b337c8a3a14bc6f33e951a5692e5650 Mon Sep 17 00:00:00 2001 From: Nick Young Date: Thu, 26 Aug 2021 21:49:57 +0000 Subject: [PATCH 5/5] Fix PR comments Signed-off-by: Nick Young --- hack/verify-examples-kind.sh | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hack/verify-examples-kind.sh b/hack/verify-examples-kind.sh index e567caaeb5..a2163d3632 100755 --- a/hack/verify-examples-kind.sh +++ b/hack/verify-examples-kind.sh @@ -61,12 +61,9 @@ sleep 8 # Install all example gateway-api resources. kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha1 || res=$? -sleep 3 - # Uninstall CRDs kubectl delete --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha1 || res=$? - ##### Test v1alpha2 CRD apply and that invalid examples are invalid. # Install CRDs kubectl apply --kubeconfig "${KUBECONFIG}" -f config/crd/v1alpha2 || res=$? @@ -83,7 +80,7 @@ kubectl apply --kubeconfig "${KUBECONFIG}" --recursive -f examples/v1alpha2 || r # 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 expoected, the output should be empty. + # 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.