knative.dev/pkg@v0.0.0-20260602142205-ac97e43f6622/test/test-reconciler-codegen.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  # Copyright 2020 The Knative 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  source $(dirname $0)/../vendor/knative.dev/hack/library.sh
    22  
    23  CODEGEN_PKG=${CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/k8s.io/code-generator 2>/dev/null || echo ../code-generator)}
    24  KNATIVE_CODEGEN_PKG=${KNATIVE_CODEGEN_PKG:-$(cd ${REPO_ROOT_DIR}; ls -d -1 $(dirname $0)/../vendor/knative.dev/pkg 2>/dev/null || echo ../pkg)}
    25  
    26  GENCLIENT_PKG=knative.dev/pkg/test/genclient
    27  
    28  echo "Pre-deleting $(dirname $0)/genclient"
    29  rm -rf $(dirname $0)/genclient
    30  
    31  header "Test Generated Reconciler Builds."
    32  
    33  source "${CODEGEN_PKG}/kube_codegen.sh"
    34  
    35  kube::codegen::gen_helpers \
    36    --boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \
    37    "${REPO_ROOT_DIR}/apis/test"
    38  
    39  kube::codegen::gen_client \
    40    --boilerplate "${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt" \
    41    --output-dir "${REPO_ROOT_DIR}/test/genclient" \
    42    --output-pkg "${GENCLIENT_PKG}" \
    43    --with-watch \
    44    "${REPO_ROOT_DIR}/apis/test"
    45  
    46  # Knative Injection
    47  ${KNATIVE_CODEGEN_PKG}/hack/generate-knative.sh "injection" \
    48    ${GENCLIENT_PKG} knative.dev/pkg/apis/test \
    49    "example:v1alpha1,pub:v1alpha1" \
    50    --go-header-file ${REPO_ROOT_DIR}/hack/boilerplate/boilerplate.go.txt \
    51    --force-genreconciler-kinds "Foo,Bar"
    52  
    53  if ! go build -v $(dirname $0)/genclient/... ; then
    54      exit 1
    55  fi
    56  
    57  echo "Finished, deleting $(dirname $0)/genclient"
    58  rm -rf $(dirname $0)/genclient