From 60778cdaa42e8d5f12c73ca541c27f1bd32c302c Mon Sep 17 00:00:00 2001 From: Manjunath A Kumatagi Date: Wed, 28 Jun 2017 19:19:25 +0530 Subject: [PATCH] Move go build to image-utils --- test/images/clusterapi-tester/Makefile | 10 ++++------ test/images/entrypoint-tester/Makefile | 10 ++++------ test/images/fakegitserver/Makefile | 13 ++++++------- test/images/goproxy/Makefile | 10 ++++------ test/images/image-util.sh | 18 +++++++++++++++++- test/images/logs-generator/Makefile | 10 ++++------ test/images/mount-tester/Makefile | 10 ++++------ test/images/n-way-http/Makefile | 10 ++++------ test/images/net/Makefile | 10 ++++------ test/images/netexec/Makefile | 10 ++++------ test/images/network-tester/Makefile | 10 ++++------ test/images/no-snat-test-proxy/Makefile | 10 ++++------ test/images/no-snat-test/Makefile | 10 ++++------ test/images/port-forward-tester/Makefile | 10 ++++------ test/images/porter/Makefile | 10 ++++------ test/images/resource-consumer/Makefile | 10 ++++------ .../resource-consumer/controller/Makefile | 12 ++++++------ test/images/serve_hostname/Makefile | 10 ++++------ 18 files changed, 89 insertions(+), 104 deletions(-) diff --git a/test/images/clusterapi-tester/Makefile b/test/images/clusterapi-tester/Makefile index 369c5cad87..7e7d827fdc 100644 --- a/test/images/clusterapi-tester/Makefile +++ b/test/images/clusterapi-tester/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=clusterapi-tester +SRCS = clusterapi-tester ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/clusterapi-tester && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN)" + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/entrypoint-tester/Makefile b/test/images/entrypoint-tester/Makefile index 9d7c516fae..79201cd419 100644 --- a/test/images/entrypoint-tester/Makefile +++ b/test/images/entrypoint-tester/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=ep +SRCS=ep ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/entrypoint-tester && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/fakegitserver/Makefile b/test/images/fakegitserver/Makefile index b99b9e049f..34f07dc9da 100644 --- a/test/images/fakegitserver/Makefile +++ b/test/images/fakegitserver/Makefile @@ -12,17 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=fakegitserver +SRCS = fakegitserver ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export + +IGNORE := $(shell git rev-parse HEAD > $(TARGET)/GITHASH.txt) bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/fakegitserver && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." - @echo $(shell git rev-parse HEAD) > $(TARGET)/GITHASH.txt + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/goproxy/Makefile b/test/images/goproxy/Makefile index ce0b1bcaa5..35282790f0 100644 --- a/test/images/goproxy/Makefile +++ b/test/images/goproxy/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=goproxy +SRCS=goproxy ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/goproxy && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/image-util.sh b/test/images/image-util.sh index e6c8ade081..96ccaddfe4 100755 --- a/test/images/image-util.sh +++ b/test/images/image-util.sh @@ -21,6 +21,8 @@ set -o pipefail TASK=$1 IMAGE=$2 +KUBE_ROOT="$(cd "$(dirname "${BASH_SOURCE}")/../.." && pwd -P)" + # Mapping of go ARCH to actual architectures shipped part of multiarch/qemu-user-static project declare -A QEMUARCHS=( ["amd64"]="x86_64" ["arm"]="arm" ["arm64"]="aarch64" ["ppc64le"]="ppc64le" ["s390x"]="s390x" ) @@ -109,4 +111,18 @@ push() { done } -eval ${TASK} +# This function is for building the go code +bin() { + for SRC in $@; + do + docker run --rm -it -v ${TARGET}:${TARGET}:Z -v ${KUBE_ROOT}:/go/src/k8s.io/kubernetes:Z \ + golang:${GOLANG_VERSION} \ + /bin/bash -c "\ + cd /go/src/k8s.io/kubernetes/test/images/${SRC_DIR} && \ + CGO_ENABLED=0 GOARM=${GOARM} GOARCH=${ARCH} go build -a -installsuffix cgo --ldflags '-w' -o ${TARGET}/${SRC} ./$(dirname ${SRC})" + done +} + +shift + +eval ${TASK} "$@" diff --git a/test/images/logs-generator/Makefile b/test/images/logs-generator/Makefile index da955f391c..86902a2dac 100644 --- a/test/images/logs-generator/Makefile +++ b/test/images/logs-generator/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=logs-generator +SRCS=logs-generator ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/logs-generator && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/mount-tester/Makefile b/test/images/mount-tester/Makefile index facb75ab96..969e8080d1 100644 --- a/test/images/mount-tester/Makefile +++ b/test/images/mount-tester/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=mounttest +SRCS=mounttest ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/mount-tester && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/n-way-http/Makefile b/test/images/n-way-http/Makefile index 5d324cd85a..2847ed3f1c 100644 --- a/test/images/n-way-http/Makefile +++ b/test/images/n-way-http/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=n-way-http +SRCS=n-way-http ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/n-way-http && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/net/Makefile b/test/images/net/Makefile index 9313191bc6..aabdea01c6 100644 --- a/test/images/net/Makefile +++ b/test/images/net/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=net +SRCS=net ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/net && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/netexec/Makefile b/test/images/netexec/Makefile index ddc44efae3..eb604a5d6c 100644 --- a/test/images/netexec/Makefile +++ b/test/images/netexec/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=netexec +SRCS=netexec ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/netexec && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/network-tester/Makefile b/test/images/network-tester/Makefile index 94c0670872..e591ddecef 100644 --- a/test/images/network-tester/Makefile +++ b/test/images/network-tester/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=nettest +SRCS=nettest ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/network-tester && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/no-snat-test-proxy/Makefile b/test/images/no-snat-test-proxy/Makefile index 507a70a3d0..882b56fd09 100644 --- a/test/images/no-snat-test-proxy/Makefile +++ b/test/images/no-snat-test-proxy/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=no-snat-test-proxy +SRCS=no-snat-test-proxy ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/no-snat-test-proxy && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN)" + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/no-snat-test/Makefile b/test/images/no-snat-test/Makefile index 60e604cce9..3c257410da 100644 --- a/test/images/no-snat-test/Makefile +++ b/test/images/no-snat-test/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=no-snat-test +SRCS=no-snat-test ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/no-snat-test && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN)" + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/port-forward-tester/Makefile b/test/images/port-forward-tester/Makefile index 71acb8f88d..c6a37e9bc0 100644 --- a/test/images/port-forward-tester/Makefile +++ b/test/images/port-forward-tester/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=portforwardtester +SRSC=portforwardtester ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/port-forward-tester && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/porter/Makefile b/test/images/porter/Makefile index d36e960b8c..eefe96f71a 100644 --- a/test/images/porter/Makefile +++ b/test/images/porter/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=porter +SRCS=porter ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/porter && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/resource-consumer/Makefile b/test/images/resource-consumer/Makefile index b0ae0b4102..44b90a0392 100644 --- a/test/images/resource-consumer/Makefile +++ b/test/images/resource-consumer/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. +SRCS = consumer consume-cpu/consume-cpu ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/resource-consumer && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/consume-cpu/consume-cpu ./consume-cpu/consume_cpu.go && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/consumer ." + ../image-util.sh bin $(SRCS) .PHONY: bin diff --git a/test/images/resource-consumer/controller/Makefile b/test/images/resource-consumer/controller/Makefile index 7570296320..24564eeeef 100644 --- a/test/images/resource-consumer/controller/Makefile +++ b/test/images/resource-consumer/controller/Makefile @@ -12,14 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=controller +SRCS=controller ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = resource-consumer/$(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/resource-consumer/controller && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../../image-util.sh bin $(SRCS) + +.PHONY: bin diff --git a/test/images/serve_hostname/Makefile b/test/images/serve_hostname/Makefile index 879bcd9948..1c2ea57751 100644 --- a/test/images/serve_hostname/Makefile +++ b/test/images/serve_hostname/Makefile @@ -12,16 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -BIN=serve_hostname +SRCS=serve_hostname ARCH ?= amd64 TARGET ?= $(CURDIR) GOLANG_VERSION ?= latest +SRC_DIR = $(notdir $(shell pwd)) +export bin: - docker run --rm -it -v $(TARGET):$(TARGET):Z -v `pwd`/../../../:/go/src/k8s.io/kubernetes:Z \ - golang:$(GOLANG_VERSION) \ - /bin/bash -c "\ - cd /go/src/k8s.io/kubernetes/test/images/serve_hostname && \ - CGO_ENABLED=0 GOARM=$(GOARM) GOARCH=$(ARCH) go build -a -installsuffix cgo --ldflags '-w' -o $(TARGET)/$(BIN) ." + ../image-util.sh bin $(SRCS) .PHONY: bin