diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml index 2954e9dff3..78dc145821 100644 --- a/.github/workflows/maven.yml +++ b/.github/workflows/maven.yml @@ -63,3 +63,29 @@ jobs: -B \ -De2e.skip=false \ -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn + codegen: + runs-on: ubuntu-latest + services: + registry: + image: registry:2 + ports: + - 5000:5000 + name: CRD Java Models Code Generation + steps: + - name: Publish to Registry + uses: elgohr/Publish-Docker-Github-Action@master + with: + name: kubernetes-client/java/crd-model-gen + tags: gh-action-tmp + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + registry: docker.pkg.github.com + workdir: client-java-contrib + no_push: true + - name: Run Code-gen for Cert-Manager + working-directory: ${{ github.workspace }}/client-java-contrib/cert-manager + run: IMAGE_TAG=gh-action-tmp ./update.sh + - name: Run Code-gen for Prometheus-Operator + working-directory: ${{ github.workspace }}/client-java-contrib/prometheus-operator + run: IMAGE_TAG=gh-action-tmp ./update.sh + diff --git a/client-java-contrib/cert-manager/update.sh b/client-java-contrib/cert-manager/update.sh index 49fc2ff60b..838c893e5f 100755 --- a/client-java-contrib/cert-manager/update.sh +++ b/client-java-contrib/cert-manager/update.sh @@ -16,6 +16,9 @@ # This script generates the model classes from a released version of cert-manager CRDs # under src/main/java/io/cert/manager/models. +IMAGE_NAME=${IMAGE_NAME:docker.pkg.github.com/kubernetes-client/java/crd-model-gen} +IMAGE_TAG=${IMAGE_TAG:v1.0.2} + # a crdgen container is run in a way that: # 1. it has access to the docker daemon on the host so that it is able to create sibling container on the host # 2. it runs on the host network so that it is able to communicate with the KinD cluster it launched on the host @@ -23,9 +26,8 @@ docker run \ --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ -v "$(pwd)":"$(pwd)" \ - -ti \ --network host \ - docker.pkg.github.com/kubernetes-client/java/crd-model-gen:v1.0.1 \ + ${IMAGE_NAME}:${IMAGE_TAG} \ /generate.sh \ -u https://github.com/jetstack/cert-manager/releases/download/v0.16.1/cert-manager.crds.yaml \ -n io.cert-manager \ diff --git a/client-java-contrib/generate.sh b/client-java-contrib/generate.sh index 4f17db1bb5..fddfb4cff3 100644 --- a/client-java-contrib/generate.sh +++ b/client-java-contrib/generate.sh @@ -41,12 +41,16 @@ while getopts 'u:n:p:o:' flag; do esac done +set -e + # create a KinD cluster on the host kind create cluster # install CRDs to the KinD cluster and dump the swagger spec for url in "${CRD_URLS[@]}"; do - kubectl apply -f "$url" + if [[ ! -z $url ]]; then + kubectl apply -f "$url" + fi done sleep 5 @@ -58,10 +62,12 @@ kubectl get crd -o name \ do if [[ $(kubectl get $L -o jsonpath='{.status.conditions[?(@.type=="NonStructuralSchema")].status}') == "True" ]]; then echo "$L failed publishing openapi schema because it's attached non-structral-schema condition." + kind delete cluster exit 1 fi if [[ $(kubectl get $L -o jsonpath='{.spec.preserveUnknownFields}') == "true" ]]; then echo "$L failed publishing openapi schema because it explicitly disabled unknown fields pruning." + kind delete cluster exit 1 fi echo "$L successfully installed" diff --git a/client-java-contrib/prometheus-operator/update.sh b/client-java-contrib/prometheus-operator/update.sh index 96cf18d7a1..2f1390cd29 100755 --- a/client-java-contrib/prometheus-operator/update.sh +++ b/client-java-contrib/prometheus-operator/update.sh @@ -16,6 +16,9 @@ # This script generates the model classes from a released version of cert-manager CRDs # under src/main/java/io/cert/manager/models. +IMAGE_NAME=${IMAGE_NAME:docker.pkg.github.com/kubernetes-client/java/crd-model-gen} +IMAGE_TAG=${IMAGE_TAG:v1.0.2} + # a crdgen container is run in a way that: # 1. it has access to the docker daemon on the host so that it is able to create sibling container on the host # 2. it runs on the host network so that it is able to communicate with the KinD cluster it launched on the host @@ -23,9 +26,8 @@ docker run \ --rm \ -v /var/run/docker.sock:/var/run/docker.sock \ -v "$(pwd)":"$(pwd)" \ - -ti \ --network host \ - docker.pkg.github.com/kubernetes-client/java/crd-model-gen:v1.0.1 \ + ${IMAGE_NAME}:${IMAGE_TAG} \ /generate.sh \ -u https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.38.1/example/prometheus-operator-crd/monitoring.coreos.com_alertmanagers.yaml \ -u https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.38.1/example/prometheus-operator-crd/monitoring.coreos.com_thanosrulers.yaml \ diff --git a/docs/generate-model-from-third-party-resources.md b/docs/generate-model-from-third-party-resources.md index a877403a1d..3ebd9fa7e0 100644 --- a/docs/generate-model-from-third-party-resources.md +++ b/docs/generate-model-from-third-party-resources.md @@ -53,7 +53,7 @@ docker run \ -v "$(pwd)":"$(pwd)" \ -ti \ --network host \ - docker.pkg.github.com/kubernetes-client/java/crd-model-gen:v1.0.1 \ + docker.pkg.github.com/kubernetes-client/java/crd-model-gen:v1.0.2 \ /generate.sh \ -u https://gist.githubusercontent.com/yue9944882/266fee8e95c2f15a93778263633e72ed/raw/be12c13379eeed13d2532cb65da61fffb19ee3e7/crontab-crd.yaml \ -n com.example.stable \ @@ -84,7 +84,7 @@ docker run \ -v "$(pwd)":"$(pwd)" \ -ti \ --network host \ - docker.pkg.github.com/kubernetes-client/java/crd-model-gen:v1.0.1 \ + docker.pkg.github.com/kubernetes-client/java/crd-model-gen:v1.0.2 \ /generate.sh \ -u $LOCAL_MANIFEST_FILE \ -n com.example.stable \