2021-07-23 09:00:07 +00:00
|
|
|
#!/bin/bash -e
|
2022-09-14 13:10:08 +00:00
|
|
|
# shellcheck disable=SC2046
|
2021-07-23 09:00:07 +00:00
|
|
|
|
|
|
|
set -e -o pipefail
|
|
|
|
|
|
|
|
PROJECT_MODULE="github.com/traefik/traefik"
|
|
|
|
MODULE_VERSION="v2"
|
|
|
|
IMAGE_NAME="kubernetes-codegen:latest"
|
2022-09-14 13:10:08 +00:00
|
|
|
CURRENT_DIR="$(pwd)"
|
2021-07-23 09:00:07 +00:00
|
|
|
|
|
|
|
echo "Building codegen Docker image..."
|
2022-09-14 13:10:08 +00:00
|
|
|
docker build --build-arg KUBE_VERSION=v0.20.2 \
|
|
|
|
--build-arg USER="${USER}" \
|
|
|
|
--build-arg UID="$(id -u)" \
|
|
|
|
--build-arg GID="$(id -g)" \
|
|
|
|
-f "./script/codegen.Dockerfile" \
|
2021-07-23 09:00:07 +00:00
|
|
|
-t "${IMAGE_NAME}" \
|
|
|
|
"."
|
|
|
|
|
2021-09-02 12:40:08 +00:00
|
|
|
echo "Generating Traefik clientSet code ..."
|
|
|
|
docker run --rm \
|
2022-09-14 13:10:08 +00:00
|
|
|
-v "${CURRENT_DIR}:/go/src/${PROJECT_MODULE}" \
|
2021-09-02 12:40:08 +00:00
|
|
|
-w "/go/src/${PROJECT_MODULE}" \
|
2023-03-20 14:38:08 +00:00
|
|
|
"${IMAGE_NAME}" \
|
|
|
|
/go/src/k8s.io/code-generator/generate-groups.sh all \
|
|
|
|
${PROJECT_MODULE}/${MODULE_VERSION}/pkg/provider/kubernetes/crd/generated \
|
|
|
|
${PROJECT_MODULE}/${MODULE_VERSION}/pkg/provider/kubernetes/crd \
|
|
|
|
"traefikcontainous:v1alpha1 traefikio:v1alpha1" \
|
|
|
|
--go-header-file=/go/src/${PROJECT_MODULE}/script/boilerplate.go.tmpl
|
2021-07-23 09:00:07 +00:00
|
|
|
|
2021-09-02 12:40:08 +00:00
|
|
|
echo "Generating DeepCopy code ..."
|
2023-03-21 15:51:10 +00:00
|
|
|
|
2021-07-23 09:00:07 +00:00
|
|
|
docker run --rm \
|
2022-09-14 13:10:08 +00:00
|
|
|
-v "${CURRENT_DIR}:/go/src/${PROJECT_MODULE}" \
|
2021-07-23 09:00:07 +00:00
|
|
|
-w "/go/src/${PROJECT_MODULE}" \
|
2023-03-20 14:38:08 +00:00
|
|
|
"${IMAGE_NAME}" \
|
|
|
|
deepcopy-gen \
|
|
|
|
--input-dirs ${PROJECT_MODULE}/${MODULE_VERSION}/pkg/config/dynamic \
|
|
|
|
--input-dirs ${PROJECT_MODULE}/${MODULE_VERSION}/pkg/tls \
|
|
|
|
--input-dirs ${PROJECT_MODULE}/${MODULE_VERSION}/pkg/types \
|
|
|
|
--output-package ${PROJECT_MODULE}/${MODULE_VERSION} -O zz_generated.deepcopy \
|
|
|
|
--go-header-file=/go/src/${PROJECT_MODULE}/script/boilerplate.go.tmpl
|
2021-07-23 09:00:07 +00:00
|
|
|
|
2021-09-02 12:40:08 +00:00
|
|
|
echo "Generating the CRD definitions for the documentation ..."
|
|
|
|
docker run --rm \
|
2022-09-14 13:10:08 +00:00
|
|
|
-v "${CURRENT_DIR}:/go/src/${PROJECT_MODULE}" \
|
2021-09-02 12:40:08 +00:00
|
|
|
-w "/go/src/${PROJECT_MODULE}" \
|
2023-03-20 14:38:08 +00:00
|
|
|
"${IMAGE_NAME}" \
|
|
|
|
controller-gen crd:crdVersions=v1 \
|
|
|
|
paths={./pkg/provider/kubernetes/crd/traefikio/v1alpha1/...,./pkg/provider/kubernetes/crd/traefikcontainous/v1alpha1/...} \
|
|
|
|
output:dir=./docs/content/reference/dynamic-configuration/
|
2021-09-02 12:40:08 +00:00
|
|
|
|
2022-06-24 10:40:08 +00:00
|
|
|
echo "Concatenate the CRD definitions for publication and integration tests ..."
|
2023-03-20 14:38:08 +00:00
|
|
|
cat "${CURRENT_DIR}"/docs/content/reference/dynamic-configuration/traefik.io_*.yaml > "${CURRENT_DIR}"/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml
|
|
|
|
cat "${CURRENT_DIR}"/docs/content/reference/dynamic-configuration/traefik.containo.us_*.yaml >> "${CURRENT_DIR}"/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml
|
2022-09-14 13:10:08 +00:00
|
|
|
cp -f "${CURRENT_DIR}"/docs/content/reference/dynamic-configuration/kubernetes-crd-definition-v1.yml "${CURRENT_DIR}"/integration/fixtures/k8s/01-traefik-crd.yml
|
2021-09-02 12:40:08 +00:00
|
|
|
|
2022-09-14 13:10:08 +00:00
|
|
|
cp -r "${CURRENT_DIR}/${MODULE_VERSION}"/* "${CURRENT_DIR}"
|
|
|
|
rm -rf "${CURRENT_DIR:?}/${MODULE_VERSION}"
|