mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-03 19:58:17 +00:00 
			
		
		
		
	add --use_go_build option when building binaries
Because of Fedora's crazy packaging guidelines, go install basically isn't allowed. So allow us to use go build instead of go install. test-integration also needs to accept the flag to be able to pass it along to the build function.
This commit is contained in:
		@@ -237,10 +237,13 @@ kube::golang::build_binaries() {
 | 
				
			|||||||
    local goflags
 | 
					    local goflags
 | 
				
			||||||
    eval "goflags=(${KUBE_GOFLAGS:-})"
 | 
					    eval "goflags=(${KUBE_GOFLAGS:-})"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    local use_go_build
 | 
				
			||||||
    local -a targets=()
 | 
					    local -a targets=()
 | 
				
			||||||
    local arg
 | 
					    local arg
 | 
				
			||||||
    for arg; do
 | 
					    for arg; do
 | 
				
			||||||
      if [[ "${arg}" == -* ]]; then
 | 
					      if [[ "${arg}" == "--use_go_build" ]]; then
 | 
				
			||||||
 | 
					        use_go_build=true
 | 
				
			||||||
 | 
					      elif [[ "${arg}" == -* ]]; then
 | 
				
			||||||
        # Assume arguments starting with a dash are flags to pass to go.
 | 
					        # Assume arguments starting with a dash are flags to pass to go.
 | 
				
			||||||
        goflags+=("${arg}")
 | 
					        goflags+=("${arg}")
 | 
				
			||||||
      else
 | 
					      else
 | 
				
			||||||
@@ -264,9 +267,25 @@ kube::golang::build_binaries() {
 | 
				
			|||||||
    for platform in "${platforms[@]}"; do
 | 
					    for platform in "${platforms[@]}"; do
 | 
				
			||||||
      kube::golang::set_platform_envs "${platform}"
 | 
					      kube::golang::set_platform_envs "${platform}"
 | 
				
			||||||
      kube::log::status "Building go targets for ${platform}:" "${targets[@]}"
 | 
					      kube::log::status "Building go targets for ${platform}:" "${targets[@]}"
 | 
				
			||||||
      go install "${goflags[@]:+${goflags[@]}}" \
 | 
					      if [[ -n ${use_go_build:-} ]]; then
 | 
				
			||||||
          -ldflags "${version_ldflags}" \
 | 
					        # Try and replicate the native binary placement of go install without calling go install
 | 
				
			||||||
          "${binaries[@]}"
 | 
					        local output_path="${KUBE_GOPATH}/bin"
 | 
				
			||||||
 | 
					        if [[ $platform != $host_platform ]]; then
 | 
				
			||||||
 | 
					          output_path="${output_path}/${platform//\//_}"
 | 
				
			||||||
 | 
					        fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        for binary in "${binaries[@]}"; do
 | 
				
			||||||
 | 
					          local bin=$(basename "${binary}")
 | 
				
			||||||
 | 
					          go build -o "${output_path}/${bin}" \
 | 
				
			||||||
 | 
					              "${goflags[@]:+${goflags[@]}}" \
 | 
				
			||||||
 | 
					              -ldflags "${version_ldflags}" \
 | 
				
			||||||
 | 
					              "${binary}"
 | 
				
			||||||
 | 
					        done
 | 
				
			||||||
 | 
					      else
 | 
				
			||||||
 | 
					        go install "${goflags[@]:+${goflags[@]}}" \
 | 
				
			||||||
 | 
					            -ldflags "${version_ldflags}" \
 | 
				
			||||||
 | 
					            "${binaries[@]}"
 | 
				
			||||||
 | 
					      fi
 | 
				
			||||||
    done
 | 
					    done
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,6 +14,10 @@
 | 
				
			|||||||
# See the License for the specific language governing permissions and
 | 
					# See the License for the specific language governing permissions and
 | 
				
			||||||
# limitations under the License.
 | 
					# limitations under the License.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# any command line arguments will be passed to hack/build_go.sh to build the
 | 
				
			||||||
 | 
					# cmd/integration binary.  --use_go_build is a legitimate argument, as are
 | 
				
			||||||
 | 
					# any other build time arguments.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set -o errexit
 | 
					set -o errexit
 | 
				
			||||||
set -o nounset
 | 
					set -o nounset
 | 
				
			||||||
set -o pipefail
 | 
					set -o pipefail
 | 
				
			||||||
@@ -26,9 +30,7 @@ cleanup() {
 | 
				
			|||||||
  kube::log::status "Integration test cleanup complete"
 | 
					  kube::log::status "Integration test cleanup complete"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ -z ${KUBE_NO_BUILD_INTEGRATION-} ]]; then
 | 
					"${KUBE_ROOT}/hack/build-go.sh" "$@" cmd/integration
 | 
				
			||||||
    "${KUBE_ROOT}/hack/build-go.sh" cmd/integration
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Run cleanup to stop etcd on interrupt or other kill signal.
 | 
					# Run cleanup to stop etcd on interrupt or other kill signal.
 | 
				
			||||||
trap cleanup HUP INT QUIT TERM
 | 
					trap cleanup HUP INT QUIT TERM
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user