|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2025 The Kubernetes Authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +set -o errexit |
| 18 | +set -o nounset |
| 19 | +set -o pipefail |
| 20 | + |
| 21 | +SCRIPT_ROOT=$(dirname "${BASH_SOURCE}")/.. |
| 22 | +GATEWAY_API_VERSION="${GATEWAY_API_VERSION:-v1.3.0}" |
| 23 | +GKE_GATEWAY_API_VERSION="${GKE_GATEWAY_API_VERSION:-v1.4.0}" |
| 24 | +ISTIO_VERSION="${ISTIO_VERSION:-1.26.2}" |
| 25 | +TEMP_DIR=$(mktemp -d) |
| 26 | + |
| 27 | +cleanup() { |
| 28 | + rm -rf "${TEMP_DIR}" || true |
| 29 | +} |
| 30 | +trap cleanup EXIT |
| 31 | + |
| 32 | +fetch_crds() { |
| 33 | + local url="$1" |
| 34 | + curl -sL "${url}" -o "${TEMP_DIR}/$(basename "${url}")" |
| 35 | +} |
| 36 | + |
| 37 | +main() { |
| 38 | + cp ${SCRIPT_ROOT}/config/crd/bases/* "${TEMP_DIR}/" |
| 39 | + |
| 40 | + # Download external CRDs for validation |
| 41 | + fetch_crds "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/refs/tags/${GATEWAY_API_VERSION}/config/crd/standard/gateway.networking.k8s.io_gateways.yaml" |
| 42 | + fetch_crds "https://raw.githubusercontent.com/kubernetes-sigs/gateway-api/refs/tags/${GATEWAY_API_VERSION}/config/crd/standard/gateway.networking.k8s.io_httproutes.yaml" |
| 43 | + fetch_crds "https://raw.githubusercontent.com/GoogleCloudPlatform/gke-gateway-api/refs/tags/${GKE_GATEWAY_API_VERSION}/config/crd/networking.gke.io_gcpbackendpolicies.yaml" |
| 44 | + fetch_crds "https://raw.githubusercontent.com/GoogleCloudPlatform/gke-gateway-api/refs/tags/${GKE_GATEWAY_API_VERSION}/config/crd/networking.gke.io_healthcheckpolicies.yaml" |
| 45 | + fetch_crds "https://raw.githubusercontent.com/istio/istio/refs/tags/${ISTIO_VERSION}/manifests/charts/base/files/crd-all.gen.yaml" |
| 46 | + |
| 47 | + make kubectl-validate |
| 48 | + |
| 49 | + ${SCRIPT_ROOT}/bin/kubectl-validate "${TEMP_DIR}" |
| 50 | + ${SCRIPT_ROOT}/bin/kubectl-validate "${SCRIPT_ROOT}/config/manifests" --local-crds "${TEMP_DIR}" |
| 51 | +} |
| 52 | + |
| 53 | +main |
0 commit comments