diff --git a/hack/_update-generated-protobuf-dockerized.sh b/hack/_update-generated-protobuf-dockerized.sh index 501760d430b..45e0535905a 100755 --- a/hack/_update-generated-protobuf-dockerized.sh +++ b/hack/_update-generated-protobuf-dockerized.sh @@ -33,14 +33,12 @@ kube::golang::setup_env GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf GOPROXY=off go install k8s.io/code-generator/cmd/go-to-protobuf/protoc-gen-gogo -gotoprotobuf=$(kube::util::find-binary "go-to-protobuf") - # requires the 'proto' tag to build (will remove when ready) # searches for the protoc-gen-gogo extension in the output directory # satisfies import of github.com/gogo/protobuf/gogoproto/gogo.proto and the # core Google protobuf types PATH="${KUBE_ROOT}/_output/bin:${PATH}" \ - "${gotoprotobuf}" \ + go-to-protobuf \ -v "${KUBE_VERBOSE}" \ --go-header-file "${KUBE_ROOT}/hack/boilerplate/boilerplate.generatego.txt" \ --output-dir="${KUBE_ROOT}/staging/src" \ diff --git a/hack/update-codegen.sh b/hack/update-codegen.sh index a737e8f4717..9940676e596 100755 --- a/hack/update-codegen.sh +++ b/hack/update-codegen.sh @@ -142,10 +142,6 @@ function codegen::deepcopy() { # The result file, in each pkg, of deep-copy generation. local output_file="${GENERATED_FILE_PREFIX}deepcopy.go" - # The tool used to generate deep copies. - local gen_deepcopy_bin - gen_deepcopy_bin="$(kube::util::find-binary "deepcopy-gen")" - # Find all the directories that request deep-copy generation. if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: finding all +k8s:deepcopy-gen tags" @@ -166,7 +162,7 @@ function codegen::deepcopy() { kube::log::status "Generating deepcopy code for ${#tag_pkgs[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${gen_deepcopy_bin} for:" + kube::log::status "DBG: running deepcopy-gen for:" for dir in "${tag_dirs[@]}"; do kube::log::status "DBG: $dir" done @@ -174,7 +170,7 @@ function codegen::deepcopy() { git_find -z ':(glob)**'/"${output_file}" | xargs -0 rm -f - "${gen_deepcopy_bin}" \ + deepcopy-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-file "${output_file}" \ @@ -192,17 +188,13 @@ function codegen::deepcopy() { # $2: Path to the directory where types.go for that group version exists. This # is the directory where the file will be generated. function gen_types_swagger_doc() { - # The tool used to generate swagger code. - local swagger_bin - swagger_bin="$(kube::util::find-binary "genswaggertypedocs")" - local group_version="$1" local gv_dir="$2" local tmpfile tmpfile="${TMPDIR:-/tmp}/types_swagger_doc_generated.$(date +%s).go" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${swagger_bin} for ${group_version} at ${gv_dir}" + kube::log::status "DBG: running genswaggertypedocs for ${group_version} at ${gv_dir}" fi { @@ -227,7 +219,7 @@ function gen_types_swagger_doc() { EOF } > "${tmpfile}" - "${swagger_bin}" \ + genswaggertypedocs \ -s \ "${gv_dir}/types.go" \ -f - \ @@ -274,10 +266,6 @@ function codegen::prerelease() { # The result file, in each pkg, of prerelease-lifecycle generation. local output_file="${GENERATED_FILE_PREFIX}prerelease-lifecycle.go" - # The tool used to generate prerelease-lifecycle code. - local gen_prerelease_bin - gen_prerelease_bin="$(kube::util::find-binary "prerelease-lifecycle-gen")" - # Find all the directories that request prerelease-lifecycle generation. if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: finding all +k8s:prerelease-lifecycle-gen tags" @@ -298,7 +286,7 @@ function codegen::prerelease() { kube::log::status "Generating prerelease-lifecycle code for ${#tag_pkgs[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${gen_prerelease_bin} for:" + kube::log::status "DBG: running prerelease-lifecycle-gen for:" for dir in "${tag_dirs[@]}"; do kube::log::status "DBG: $dir" done @@ -306,7 +294,7 @@ function codegen::prerelease() { git_find -z ':(glob)**'/"${output_file}" | xargs -0 rm -f - "${gen_prerelease_bin}" \ + prerelease-lifecycle-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-file "${output_file}" \ @@ -342,10 +330,6 @@ function codegen::defaults() { # The result file, in each pkg, of defaulter generation. local output_file="${GENERATED_FILE_PREFIX}defaults.go" - # The tool used to generate defaulters. - local gen_defaulter_bin - gen_defaulter_bin="$(kube::util::find-binary "defaulter-gen")" - # All directories that request any form of defaulter generation. if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: finding all +k8s:defaulter-gen tags" @@ -366,7 +350,7 @@ function codegen::defaults() { kube::log::status "Generating defaulter code for ${#tag_pkgs[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${gen_defaulter_bin} for:" + kube::log::status "DBG: running defaulter-gen for:" for dir in "${tag_dirs[@]}"; do kube::log::status "DBG: $dir" done @@ -374,7 +358,7 @@ function codegen::defaults() { git_find -z ':(glob)**'/"${output_file}" | xargs -0 rm -f - "${gen_defaulter_bin}" \ + defaulter-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-file "${output_file}" \ @@ -415,10 +399,6 @@ function codegen::conversions() { # The result file, in each pkg, of conversion generation. local output_file="${GENERATED_FILE_PREFIX}conversion.go" - # The tool used to generate conversions. - local gen_conversion_bin - gen_conversion_bin="$(kube::util::find-binary "conversion-gen")" - # All directories that request any form of conversion generation. if [[ "${DBG_CODEGEN}" == 1 ]]; then kube::log::status "DBG: finding all +k8s:conversion-gen tags" @@ -445,7 +425,7 @@ function codegen::conversions() { kube::log::status "Generating conversion code for ${#tag_pkgs[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${gen_conversion_bin} for:" + kube::log::status "DBG: running conversion-gen for:" for dir in "${tag_dirs[@]}"; do kube::log::status "DBG: $dir" done @@ -453,7 +433,7 @@ function codegen::conversions() { git_find -z ':(glob)**'/"${output_file}" | xargs -0 rm -f - "${gen_conversion_bin}" \ + conversion-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-file "${output_file}" \ @@ -497,10 +477,6 @@ function codegen::openapi() { # The result file, in each pkg, of open-api generation. local output_file="${GENERATED_FILE_PREFIX}openapi.go" - # The tool used to generate open apis. - local gen_openapi_bin - gen_openapi_bin="$(kube::util::find-binary "openapi-gen")" - local output_dir="pkg/generated/openapi" local output_pkg="k8s.io/kubernetes/${output_dir}" local known_violations_file="${API_KNOWN_VIOLATIONS_DIR}/violation_exceptions.list" @@ -540,7 +516,7 @@ function codegen::openapi() { kube::log::status "Generating openapi code" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${gen_openapi_bin} for:" + kube::log::status "DBG: running openapi-gen for:" for dir in "${tag_dirs[@]}"; do kube::log::status "DBG: $dir" done @@ -548,7 +524,7 @@ function codegen::openapi() { git_find -z ':(glob)pkg/generated/**'/"${output_file}" | xargs -0 rm -f - "${gen_openapi_bin}" \ + openapi-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-file "${output_file}" \ @@ -576,11 +552,6 @@ function codegen::applyconfigs() { k8s.io/kubernetes/pkg/generated/openapi/cmd/models-schema \ k8s.io/code-generator/cmd/applyconfiguration-gen - local modelsschema - modelsschema=$(kube::util::find-binary "models-schema") - local applyconfigurationgen - applyconfigurationgen=$(kube::util::find-binary "applyconfiguration-gen") - local ext_apis=() kube::util::read-array ext_apis < <( cd "${KUBE_ROOT}/staging/src" @@ -591,7 +562,7 @@ function codegen::applyconfigs() { kube::log::status "Generating apply-config code for ${#ext_apis[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${applyconfigurationgen} for:" + kube::log::status "DBG: running applyconfiguration-gen for:" for api in "${ext_apis[@]}"; do kube::log::status "DBG: $api" done @@ -604,9 +575,9 @@ function codegen::applyconfigs() { || true) \ | xargs -0 rm -f - "${applyconfigurationgen}" \ + applyconfiguration-gen \ -v "${KUBE_VERBOSE}" \ - --openapi-schema <("${modelsschema}") \ + --openapi-schema <(models-schema) \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-dir "${KUBE_ROOT}/staging/src/${APPLYCONFIG_PKG}" \ --output-pkg "${APPLYCONFIG_PKG}" \ @@ -622,9 +593,6 @@ function codegen::clients() { GOPROXY=off go install \ k8s.io/code-generator/cmd/client-gen - local clientgen - clientgen=$(kube::util::find-binary "client-gen") - IFS=" " read -r -a group_versions <<< "${KUBE_AVAILABLE_GROUP_VERSIONS}" local gv_dirs=() for gv in "${group_versions[@]}"; do @@ -645,7 +613,7 @@ function codegen::clients() { kube::log::status "Generating client code for ${#gv_dirs[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${clientgen} for:" + kube::log::status "DBG: running client-gen for:" for dir in "${gv_dirs[@]}"; do kube::log::status "DBG: $dir" done @@ -658,7 +626,7 @@ function codegen::clients() { || true) \ | xargs -0 rm -f - "${clientgen}" \ + client-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-dir "${KUBE_ROOT}/staging/src/k8s.io/client-go" \ @@ -678,9 +646,6 @@ function codegen::listers() { GOPROXY=off go install \ k8s.io/code-generator/cmd/lister-gen - local listergen - listergen=$(kube::util::find-binary "lister-gen") - local ext_apis=() kube::util::read-array ext_apis < <( cd "${KUBE_ROOT}/staging/src" @@ -690,7 +655,7 @@ function codegen::listers() { kube::log::status "Generating lister code for ${#ext_apis[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${listergen} for:" + kube::log::status "DBG: running lister-gen for:" for api in "${ext_apis[@]}"; do kube::log::status "DBG: $api" done @@ -703,7 +668,7 @@ function codegen::listers() { || true) \ | xargs -0 rm -f - "${listergen}" \ + lister-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-dir "${KUBE_ROOT}/staging/src/k8s.io/client-go/listers" \ @@ -720,9 +685,6 @@ function codegen::informers() { GOPROXY=off go install \ k8s.io/code-generator/cmd/informer-gen - local informergen - informergen=$(kube::util::find-binary "informer-gen") - local ext_apis=() kube::util::read-array ext_apis < <( cd "${KUBE_ROOT}/staging/src" @@ -732,7 +694,7 @@ function codegen::informers() { kube::log::status "Generating informer code for ${#ext_apis[@]} targets" if [[ "${DBG_CODEGEN}" == 1 ]]; then - kube::log::status "DBG: running ${informergen} for:" + kube::log::status "DBG: running informer-gen for:" for api in "${ext_apis[@]}"; do kube::log::status "DBG: $api" done @@ -745,7 +707,7 @@ function codegen::informers() { || true) \ | xargs -0 rm -f - "${informergen}" \ + informer-gen \ -v "${KUBE_VERBOSE}" \ --go-header-file "${BOILERPLATE_FILENAME}" \ --output-dir "${KUBE_ROOT}/staging/src/k8s.io/client-go/informers" \ diff --git a/hack/update-kustomize.sh b/hack/update-kustomize.sh index 82de57a3089..80f8cab5ce5 100755 --- a/hack/update-kustomize.sh +++ b/hack/update-kustomize.sh @@ -18,8 +18,10 @@ set -o errexit set -o nounset set -o pipefail -source hack/lib/util.sh +KUBE_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. +source "${KUBE_ROOT}/hack/lib/init.sh" +kube::golang::setup_env kube::util::require-jq kube::util::ensure_clean_working_dir @@ -62,9 +64,11 @@ git add . git commit -a -m "Update kubectl kustomize to kyaml/$LATEST_KYAML, cmd/config/$LATEST_CONFIG, api/$LATEST_API, kustomize/$LATEST_KUSTOMIZE" echo -e "\n${color_blue:?}Verifying kubectl kustomize version${color_norm:?}" -make WHAT=cmd/kubectl +# We use `make` here intead of `go install` to ensure that all of the +# linker-defined values are set. +make -C "${KUBE_ROOT}" WHAT=./cmd/kubectl -if [[ $(_output/bin/kubectl version --client -o json | jq -r '.kustomizeVersion') != "$LATEST_KUSTOMIZE" ]]; then +if [[ $(kubectl version --client -o json | jq -r '.kustomizeVersion') != "$LATEST_KUSTOMIZE" ]]; then echo -e "${color_red:?}Unexpected kubectl kustomize version${color_norm:?}" exit 1 fi diff --git a/hack/update-openapi-spec.sh b/hack/update-openapi-spec.sh index 90d59115111..35a787cd798 100755 --- a/hack/update-openapi-spec.sh +++ b/hack/update-openapi-spec.sh @@ -30,6 +30,8 @@ kube::util::require-jq kube::golang::setup_env kube::etcd::install +# We need to call `make` here because that includes all of the compile and link +# flags that we use for a production build, which we need for this script. make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver function cleanup() @@ -70,7 +72,7 @@ fi # Start kube-apiserver # omit enums from static openapi snapshots used to generate clients until #109177 is resolved kube::log::status "Starting kube-apiserver" -"${THIS_PLATFORM_BIN}/kube-apiserver" \ +kube-apiserver \ --bind-address="${API_HOST}" \ --secure-port="${API_PORT}" \ --etcd-servers="http://${ETCD_HOST}:${ETCD_PORT}" \ diff --git a/hack/verify-cli-conventions.sh b/hack/verify-cli-conventions.sh index 809d493a5f5..ac89cf60058 100755 --- a/hack/verify-cli-conventions.sh +++ b/hack/verify-cli-conventions.sh @@ -27,7 +27,7 @@ source "${KUBE_ROOT}/hack/lib/init.sh" kube::golang::setup_env -hack/make-rules/build.sh ./cmd/clicheck +GOPROXY=off go install ./cmd/clicheck if ! output=$(clicheck 2>&1) then diff --git a/hack/verify-description.sh b/hack/verify-description.sh index cf9d5dc5e11..7c543895cde 100755 --- a/hack/verify-description.sh +++ b/hack/verify-description.sh @@ -28,12 +28,7 @@ source "${KUBE_ROOT}/hack/lib/util.sh" kube::golang::setup_env -make -C "${KUBE_ROOT}" WHAT=cmd/genswaggertypedocs - -# Find binary -genswaggertypedocs=$(kube::util::find-binary "genswaggertypedocs") - -result=0 +GOPROXY=off go install ./cmd/genswaggertypedocs find_files() { find . -not \( \ @@ -69,10 +64,11 @@ kube::util::check-file-in-alphabetical-order "${failure_file}" failing_files=() while IFS='' read -r line; do failing_files+=("$line"); done < <(cat "$failure_file") +result=0 for file in $versioned_api_files; do if ! kube::util::array_contains "$file" "${failing_files[@]}"; then gen_swagger_result=0 - $genswaggertypedocs -v -s "${file}" -f - || gen_swagger_result=$? + genswaggertypedocs -v -s "${file}" -f - || gen_swagger_result=$? if [[ "${gen_swagger_result}" -ne 0 ]]; then echo "API file: ${file} is missing: ${gen_swagger_result} descriptions" result=1 diff --git a/hack/verify-fieldname-docs.sh b/hack/verify-fieldname-docs.sh index 723ac211e1d..7ab7f5ec96a 100755 --- a/hack/verify-fieldname-docs.sh +++ b/hack/verify-fieldname-docs.sh @@ -28,12 +28,7 @@ source "${KUBE_ROOT}/hack/lib/util.sh" kube::golang::setup_env -make -C "${KUBE_ROOT}" WHAT=cmd/fieldnamedocscheck - -# Find binary -fieldnamedocscheck=$(kube::util::find-binary "fieldnamedocscheck") - -result=0 +GOPROXY=off go install ./cmd/fieldnamedocscheck find_files() { find . -not \( \ @@ -55,10 +50,11 @@ find_files() { versioned_api_files=$(find_files) || true +result=0 for file in ${versioned_api_files}; do package="${file%"/types.go"}" echo "Checking ${package}" - ${fieldnamedocscheck} -s "${file}" || result=$? + fieldnamedocscheck -s "${file}" || result=$? done exit ${result} diff --git a/hack/verify-generated-docs.sh b/hack/verify-generated-docs.sh index a38df2e91d4..27a9e6b2ba5 100755 --- a/hack/verify-generated-docs.sh +++ b/hack/verify-generated-docs.sh @@ -28,12 +28,12 @@ source "${KUBE_ROOT}/hack/lib/init.sh" kube::golang::setup_env BINS=( - cmd/gendocs - cmd/genkubedocs - cmd/genman - cmd/genyaml + ./cmd/gendocs + ./cmd/genkubedocs + ./cmd/genman + ./cmd/genyaml ) -make -C "${KUBE_ROOT}" WHAT="${BINS[*]}" +GOPROXY=off go install "${BINS[@]}" kube::util::ensure-temp-dir diff --git a/hack/verify-imports.sh b/hack/verify-imports.sh index 35a2e5caa69..164c7010b53 100755 --- a/hack/verify-imports.sh +++ b/hack/verify-imports.sh @@ -28,19 +28,6 @@ source "${KUBE_ROOT}/hack/lib/init.sh" kube::golang::setup_env -make -C "${KUBE_ROOT}" WHAT=cmd/importverifier +GOPROXY=off go install ./cmd/importverifier -# Find binary -importverifier=$(kube::util::find-binary "importverifier") - -if [[ ! -x "$importverifier" ]]; then - { - echo "It looks as if you don't have a compiled importverifier binary" - echo - echo "If you are running from a clone of the git repo, please run" - echo "'make WHAT=cmd/importverifier'." - } >&2 - exit 1 -fi - -"${importverifier}" "k8s.io/" "${KUBE_ROOT}/staging/publishing/import-restrictions.yaml" +importverifier "k8s.io/" "${KUBE_ROOT}/staging/publishing/import-restrictions.yaml" diff --git a/hack/verify-openapi-spec.sh b/hack/verify-openapi-spec.sh index cfb582bb845..e37fa00866c 100755 --- a/hack/verify-openapi-spec.sh +++ b/hack/verify-openapi-spec.sh @@ -29,7 +29,9 @@ source "${KUBE_ROOT}/hack/lib/init.sh" kube::golang::setup_env kube::etcd::install -make -C "${KUBE_ROOT}" WHAT=cmd/kube-apiserver +# We use `make` here intead of `go install` to ensure that all of the +# linker-defined values are set. +make -C "${KUBE_ROOT}" WHAT=./cmd/kube-apiserver SPECROOT="${KUBE_ROOT}/api/openapi-spec" SPECV3PATH="${SPECROOT}/v3"