github.com/argoproj/argo-cd/v3@v3.2.1/hack/update-codegen.sh (about) 1 #!/bin/bash 2 3 # Copyright 2017 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 -x 18 set -o errexit 19 set -o nounset 20 set -o pipefail 21 22 PROJECT_ROOT=$( 23 cd "$(dirname "${BASH_SOURCE[0]}")"/.. 24 pwd 25 ) 26 PATH="${PROJECT_ROOT}/dist:${PATH}" 27 GOPATH=$(go env GOPATH) 28 GOPATH_PROJECT_ROOT="${GOPATH}/src/github.com/argoproj/argo-cd" 29 30 TARGET_SCRIPT=kube_codegen.sh 31 32 # codegen utilities are installed outside kube_codegen.sh so remove the `go install` step in the script. 33 sed -e '/go install/d' "${PROJECT_ROOT}/vendor/k8s.io/code-generator/kube_codegen.sh" > ${TARGET_SCRIPT} 34 35 # generate-groups.sh assumes codegen utilities are installed to GOBIN, but we just ensure the CLIs 36 # are in the path and invoke them without assumption of their location 37 # shellcheck disable=SC2016 38 sed -i.bak -e 's#${GOBIN}/##g' ${TARGET_SCRIPT} 39 40 [ -e ./v3 ] || ln -s . v3 41 [ -e "${GOPATH_PROJECT_ROOT}" ] || (mkdir -p "$(dirname "${GOPATH_PROJECT_ROOT}")" && ln -s "${PROJECT_ROOT}" "${GOPATH_PROJECT_ROOT}") 42 43 # shellcheck source=pkg/apis/application/v1alpha1/kube_codegen.sh 44 . ${TARGET_SCRIPT} 45 46 kube::codegen::gen_helpers pkg/apis/application/v1alpha1 47 kube::codegen::gen_client pkg/apis \ 48 --output-dir pkg/client \ 49 --output-pkg github.com/argoproj/argo-cd/v3/pkg/client \ 50 --boilerplate "${PROJECT_ROOT}/hack/custom-boilerplate.go.txt" \ 51 --with-watch 52 53 rm ${TARGET_SCRIPT} 54 rm ${TARGET_SCRIPT}.bak 55 56 [ -L "${GOPATH_PROJECT_ROOT}" ] && rm -rf "${GOPATH_PROJECT_ROOT}" 57 [ -L ./v3 ] && rm -rf v3