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 /* 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 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-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 diff --git a/hack/verify-examples-kind.sh b/hack/verify-examples-kind.sh index 182fbb0327..a2163d3632 100755 --- a/hack/verify-examples-kind.sh +++ b/hack/verify-examples-kind.sh @@ -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