Skip to content

Commit

Permalink
Remove localkube from bindata
Browse files Browse the repository at this point in the history
This makes the minikube build simpler and the the binary smaller.
Localkube will always be remotely fetched and locally cached on the
host.
  • Loading branch information
r2d4 committed Oct 19, 2017
1 parent 3f08a3f commit df927ad
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ ISO_BUCKET ?= minikube/iso
GOOS ?= $(shell go env GOOS)
GOARCH ?= $(shell go env GOARCH)
BUILD_DIR ?= ./out
$(shell mkdir -p $(BUILD_DIR))

ORG := k8s.io
REPOPATH ?= $(ORG)/minikube

Expand All @@ -53,11 +55,9 @@ LOCALKUBEFILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' ./cmd/local
MINIKUBEFILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' ./cmd/minikube/ | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'
HYPERKIT_FILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' k8s.io/minikube/cmd/drivers/hyperkit | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'

KVM_DRIVER_FILES := $(shell go list -f '{{join .Deps "\n"}}' ./cmd/drivers/kvm/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')
MINIKUBE_TEST_FILES := go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./... | grep k8s.io | GOPATH=$(GOPATH) xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}'

MINIKUBE_ENV_linux := CGO_ENABLED=1 GOARCH=amd64 GOOS=linux
MINIKUBE_ENV_darwin := CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin
MINIKUBE_ENV_windows := CGO_ENABLED=0 GOARCH=amd64 GOOS=windows
KVM_DRIVER_FILES := $(shell go list -f '{{join .Deps "\n"}}' ./cmd/drivers/kvm/ | grep k8s.io | xargs go list -f '{{ range $$file := .GoFiles }} {{$$.Dir}}/{{$$file}}{{"\n"}}{{end}}')

# extra env vars that need to be set in cross build container
MINIKUBE_ENV_darwin_DOCKER := CC=o64-clang CXX=o64-clang++
Expand All @@ -70,7 +70,7 @@ KUBE_CROSS_DOCKER_CMD := docker run -w /go/src/$(REPOPATH) --user $(shell id -u)

# $(call MINIKUBE_GO_BUILD_CMD, output file, OS)
define MINIKUBE_GO_BUILD_CMD
$(MINIKUBE_ENV_$(2)) go build -tags "$(MINIKUBE_BUILD_TAGS)" --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $(1) k8s.io/minikube/cmd/minikube
GOOS=$(2) go build -tags "$(MINIKUBE_BUILD_TAGS)" --installsuffix cgo -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $(1) k8s.io/minikube/cmd/minikube
endef

ifeq ($(BUILD_IN_DOCKER),y)
Expand Down Expand Up @@ -179,7 +179,7 @@ integration-versioned: out/minikube
go test -v -test.timeout=30m $(REPOPATH)/test/integration --tags="$(MINIKUBE_INTEGRATION_BUILD_TAGS) versioned" $(TEST_ARGS)

.PHONY: test
test: pkg/minikube/assets/assets.go
test: $(shell $(MINIKUBE_TEST_FILES)) pkg/minikube/assets/assets.go
./test.sh

.PHONY: gopath
Expand All @@ -188,8 +188,8 @@ ifneq ($(GOPATH)/src/$(REPOPATH),$(PWD))
$(warning Warning: Building minikube outside the GOPATH, should be $(GOPATH)/src/$(REPOPATH) but is $(PWD))
endif

pkg/minikube/assets/assets.go: out/localkube $(GOPATH)/bin/go-bindata $(shell find deploy/addons -type f)
$(GOPATH)/bin/go-bindata -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets ./out/localkube deploy/addons/...
pkg/minikube/assets/assets.go: $(GOPATH)/bin/go-bindata $(shell find deploy/addons -type f)
$(GOPATH)/bin/go-bindata -nomemcopy -o pkg/minikube/assets/assets.go -pkg assets deploy/addons/...

$(GOPATH)/bin/go-bindata:
GOBIN=$(GOPATH)/bin go get github.com/jteeuwen/go-bindata/...
Expand Down Expand Up @@ -255,9 +255,9 @@ out/minikube-installer.exe: out/minikube-windows-amd64.exe

out/docker-machine-driver-hyperkit: $(shell $(HYPERKIT_FILES))
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
$(MINIKUBE_DOCKER_CMD) '$(MINIKUBE_ENV_darwin_DOCKER) $(MINIKUBE_ENV_darwin) go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit'
$(MINIKUBE_DOCKER_CMD) '$(MINIKUBE_ENV_darwin_DOCKER) GOOS=darwin go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit'
else
$(MINIKUBE_ENV_darwin) go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
GOOS=darwin go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
endif

.PHONY: install-hyperkit-driver
Expand Down
12 changes: 4 additions & 8 deletions pkg/minikube/bootstrapper/localkube/localkube.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,10 @@ func (lk *LocalkubeBootstrapper) UpdateCluster(config bootstrapper.KubernetesCon
var err error

//add url/file/bundled localkube to file list
if localkubeURIWasSpecified(config) && config.KubernetesVersion != constants.DefaultKubernetesVersion {
lCacher := localkubeCacher{config}
localkubeFile, err = lCacher.fetchLocalkubeFromURI()
if err != nil {
return errors.Wrap(err, "Error updating localkube from uri")
}
} else {
localkubeFile = assets.NewBinDataAsset("out/localkube", "/usr/local/bin", "localkube", "0777")
lCacher := localkubeCacher{config}
localkubeFile, err = lCacher.fetchLocalkubeFromURI()
if err != nil {
return errors.Wrap(err, "Error updating localkube from uri")
}
copyableFiles = append(copyableFiles, localkubeFile)

Expand Down
2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ COV_TMP_FILE=coverage_tmp.txt
# Run "go test" on packages that have test files. Also create coverage profile
echo "Running go tests..."
cd ${GOPATH}/src/${REPO_PATH}
rm -f out/$COV_FILE
rm -f out/$COV_FILE || true
echo "mode: count" > out/$COV_FILE
for pkg in $(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...); do
go test -tags "container_image_ostree_stub containers_image_openpgp" -v $pkg -covermode=count -coverprofile=out/$COV_TMP_FILE
Expand Down

0 comments on commit df927ad

Please sign in to comment.