use go_container.sh more consistently

This commit is contained in:
Benjamin Elder
2019-08-23 16:31:46 -07:00
parent 742844eb41
commit cd26291fe3
8 changed files with 29 additions and 48 deletions

2
go.mod
View File

@@ -1,5 +1,7 @@
module sigs.k8s.io/kind
go 1.13
require (
github.com/google/gofuzz v1.0.0
github.com/google/uuid v1.1.1

View File

@@ -22,16 +22,11 @@ set -o errexit -o nounset -o pipefail
REPO_ROOT=$(git rev-parse --show-toplevel)
cd "${REPO_ROOT}"
# enable modules and the proxy cache
export GO111MODULE="on"
GOPROXY="${GOPROXY:-https://proxy.golang.org}"
export GOPROXY
# build and test kind
hack/release/build/cross.sh
go test -v ./...
hack/go_container.sh go test -v ./...
# build and test kindnetd
cd ./cmd/kindnetd
go install -v .
go test -v ./...
"${REPO_ROOT}/hack/go_container.sh" go build -v -o /out/kindnetd .
"${REPO_ROOT}/hack/go_container.sh" go test -v ./...

View File

@@ -21,15 +21,13 @@ cd "${REPO_ROOT}"
# ensure we have up to date kind
make build
KIND="${REPO_ROOT}/bin/kind"
# generate tag
DATE="$(date +v%Y%m%d)"
TAG="${DATE}-$(git describe --always --dirty)"
TAG="$(date +v%Y%m%d)-$(git describe --always --dirty)"
IMAGE="kindest/base:${TAG}"
# build
(set -x; "${KIND}" build base-image --image="${IMAGE}" --source="${REPO_ROOT}/images/base/")
(set -x; "${REPO_ROOT}/bin/kind" build base-image --image="${IMAGE}" --source="${REPO_ROOT}/images/base/")
# push
docker push "${IMAGE}"

View File

@@ -21,7 +21,6 @@ cd "${REPO_ROOT}"
# ensure we have up to date kind
make build
KIND="${REPO_ROOT}/bin/kind"
# generate tag
DATE="$(date +v%Y%m%d)"
@@ -30,7 +29,7 @@ TAG="${DATE}-$(git describe --always --dirty)"
# build
KUBEROOT="${KUBEROOT:-${GOPATH}/src/k8s.io/kubernetes}"
set -x
"${KIND}" build node-image --image="kindest/node:${TAG}" --kube-root="${KUBEROOT}"
"${REPO_ROOT}/bin/kind" build node-image --image="kindest/node:${TAG}" --kube-root="${KUBEROOT}"
# re-tag with kubernetes version
IMG="kindest/node:${TAG}"

View File

@@ -20,6 +20,6 @@ set -o errexit -o nounset -o pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"
"${REPO_ROOT}"/hack/update/deps.sh
"${REPO_ROOT}"/hack/update/generated.sh
"${REPO_ROOT}"/hack/update/gofmt.sh
hack/update/deps.sh
hack/update/generated.sh
hack/update/gofmt.sh

View File

@@ -23,12 +23,7 @@ set -o errexit -o nounset -o pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"
# enable modules and the proxy cache
export GO111MODULE="on"
GOPROXY="${GOPROXY:-https://proxy.golang.org}"
export GOPROXY
go mod tidy
cd "hack/tools"
go mod tidy
# tidy all modules
hack/go_container.sh go mod tidy
SOURCE_DIR="${REPO_ROOT}/hack/tools" hack/go_container.sh go mod tidy
SOURCE_DIR="${REPO_ROOT}/cmd/kindnetd" hack/go_container.sh go mod tidy

View File

@@ -20,26 +20,19 @@ set -o errexit -o nounset -o pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"
# enable modules and the proxy cache
export GO111MODULE="on"
GOPROXY="${GOPROXY:-https://proxy.golang.org}"
export GOPROXY
# build the generators
BINDIR="${REPO_ROOT}/bin"
# use the tools module
# build the generators using the tools module
cd "hack/tools"
go build -o "${BINDIR}/defaulter-gen" k8s.io/code-generator/cmd/defaulter-gen
go build -o "${BINDIR}/deepcopy-gen" k8s.io/code-generator/cmd/deepcopy-gen
go build -o "${BINDIR}/conversion-gen" k8s.io/code-generator/cmd/conversion-gen
"${REPO_ROOT}/hack/go_container.sh" go build -o /out/defaulter-gen k8s.io/code-generator/cmd/defaulter-gen
"${REPO_ROOT}/hack/go_container.sh" go build -o /out/deepcopy-gen k8s.io/code-generator/cmd/deepcopy-gen
"${REPO_ROOT}/hack/go_container.sh" go build -o /out/conversion-gen k8s.io/code-generator/cmd/conversion-gen
# go back to the root
cd "${REPO_ROOT}"
# turn off module mode before running the generators
# https://github.com/kubernetes/code-generator/issues/69
# we also need to populate vendor
go mod tidy
go mod vendor
hack/go_container.sh go mod tidy
hack/go_container.sh go mod vendor
export GO111MODULE="off"
# fake being in a gopath
@@ -53,15 +46,14 @@ export GOPATH="${FAKE_GOPATH}"
cd "${FAKE_REPOPATH}"
# run the generators
"${BINDIR}/deepcopy-gen" -i ./pkg/internal/apis/config/ -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
"${BINDIR}/defaulter-gen" -i ./pkg/internal/apis/config/ -O zz_generated.default --go-header-file hack/tools/boilerplate.go.txt
bin/deepcopy-gen -i ./pkg/internal/apis/config/ -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
bin/defaulter-gen -i ./pkg/internal/apis/config/ -O zz_generated.default --go-header-file hack/tools/boilerplate.go.txt
"${BINDIR}/deepcopy-gen" -i ./pkg/apis/config/v1alpha3 -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
"${BINDIR}/defaulter-gen" -i ./pkg/apis/config/v1alpha3 -O zz_generated.default --go-header-file hack/tools/boilerplate.go.txt
"${BINDIR}/conversion-gen" -i ./pkg/internal/apis/config/v1alpha3 -O zz_generated.conversion --go-header-file hack/tools/boilerplate.go.txt
bin/deepcopy-gen -i ./pkg/apis/config/v1alpha3 -O zz_generated.deepcopy --go-header-file hack/tools/boilerplate.go.txt
bin/defaulter-gen -i ./pkg/apis/config/v1alpha3 -O zz_generated.default --go-header-file hack/tools/boilerplate.go.txt
bin/conversion-gen -i ./pkg/internal/apis/config/v1alpha3 -O zz_generated.conversion --go-header-file hack/tools/boilerplate.go.txt
# set module mode back, return to repo root and gofmt to ensure we format generated code
export GO111MODULE="on"
cd "${REPO_ROOT}"
# gofmt the tree
find . -name "*.go" -type f -print0 | xargs -0 gofmt -s -w
hack/update/gofmt.sh

View File

@@ -21,4 +21,4 @@ set -o errexit -o nounset -o pipefail
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd -P)"
cd "${REPO_ROOT}"
find . -name "*.go" -type f -print0 | xargs -0 gofmt -s -w
hack/go_container.sh sh -c "find . -name '*.go' -type f -print0 | xargs -0 gofmt -s -w"