Skip to content

Commit d9089c3

Browse files
authored
Merge pull request #2089 from r2d4/no-localkube
Remove localkube from bindata
2 parents 2b23ac9 + a19f90f commit d9089c3

File tree

6 files changed

+73
-34
lines changed

6 files changed

+73
-34
lines changed

Makefile

+17-23
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ INSTALL_SIZE ?= $(shell du out/minikube-windows-amd64.exe | cut -f1)
2222
BUILDROOT_BRANCH ?= 2017.02
2323
REGISTRY?=gcr.io/k8s-minikube
2424

25-
MINIKUBE_BUILD_IMAGE ?= karalabe/xgo-1.8.3
26-
LOCALKUBE_BUILD_IMAGE ?= gcr.io/google_containers/kube-cross:v1.8.3-1
25+
HYPERKIT_BUILD_IMAGE ?= karalabe/xgo-1.8.3
26+
BUILD_IMAGE ?= gcr.io/google_containers/kube-cross:v1.8.3-1
2727
ISO_BUILD_IMAGE ?= $(REGISTRY)/buildroot-image
2828

2929
ISO_VERSION ?= v0.23.6
@@ -32,6 +32,8 @@ ISO_BUCKET ?= minikube/iso
3232
GOOS ?= $(shell go env GOOS)
3333
GOARCH ?= $(shell go env GOARCH)
3434
BUILD_DIR ?= ./out
35+
$(shell mkdir -p $(BUILD_DIR))
36+
3537
ORG := k8s.io
3638
REPOPATH ?= $(ORG)/minikube
3739

@@ -53,24 +55,16 @@ LOCALKUBEFILES := GOPATH=$(GOPATH) go list -f '{{join .Deps "\n"}}' ./cmd/local
5355
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}}'
5456
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}}'
5557

56-
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}}')
57-
58-
MINIKUBE_ENV_linux := CGO_ENABLED=1 GOARCH=amd64 GOOS=linux
59-
MINIKUBE_ENV_darwin := CGO_ENABLED=1 GOARCH=amd64 GOOS=darwin
60-
MINIKUBE_ENV_windows := CGO_ENABLED=0 GOARCH=amd64 GOOS=windows
58+
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}}'
6159

62-
# extra env vars that need to be set in cross build container
63-
MINIKUBE_ENV_darwin_DOCKER := CC=o64-clang CXX=o64-clang++
60+
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}}')
6461

6562
MINIKUBE_BUILD_TAGS := container_image_ostree_stub containers_image_openpgp
6663
MINIKUBE_INTEGRATION_BUILD_TAGS := integration $(MINIKUBE_BUILD_TAGS)
6764

68-
MINIKUBE_DOCKER_CMD := docker run -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) --workdir /go/src/$(REPOPATH) --entrypoint /bin/bash -v $(PWD):/go/src/$(REPOPATH) $(MINIKUBE_BUILD_IMAGE) -c
69-
KUBE_CROSS_DOCKER_CMD := docker run -w /go/src/$(REPOPATH) --user $(shell id -u):$(shell id -g) -e IN_DOCKER=1 -v $(shell pwd):/go/src/$(REPOPATH) $(LOCALKUBE_BUILD_IMAGE)
70-
71-
# $(call MINIKUBE_GO_BUILD_CMD, output file, OS)
72-
define MINIKUBE_GO_BUILD_CMD
73-
$(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
65+
# $(call DOCKER, image, command)
66+
define DOCKER
67+
docker run --rm -e IN_DOCKER=1 --user $(shell id -u):$(shell id -g) -w /go/src/$(REPOPATH) -v $(GOPATH):/go --entrypoint /bin/bash $(1) -c '$(2)'
7468
endef
7569

7670
ifeq ($(BUILD_IN_DOCKER),y)
@@ -99,7 +93,7 @@ out/minikube$(IS_EXE): gopath out/minikube-$(GOOS)-$(GOARCH)$(IS_EXE)
9993

10094
out/localkube: $(shell $(LOCALKUBEFILES))
10195
ifeq ($(LOCALKUBE_BUILD_IN_DOCKER),y)
102-
$(KUBE_CROSS_DOCKER_CMD) make $@
96+
$(call DOCKER,$(BUILD_IMAGE),/usr/bin/make $@)
10397
else
10498
CGO_ENABLED=1 go build -tags static_build -ldflags=$(LOCALKUBE_LDFLAGS) -o $(BUILD_DIR)/localkube ./cmd/localkube
10599
endif
@@ -109,9 +103,9 @@ out/minikube-windows-amd64.exe: out/minikube-windows-amd64
109103

110104
out/minikube-%-amd64: pkg/minikube/assets/assets.go $(shell $(MINIKUBEFILES))
111105
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
112-
$(MINIKUBE_DOCKER_CMD) '$(MINIKUBE_ENV_$*_DOCKER) $(call MINIKUBE_GO_BUILD_CMD,$@,$*)'
106+
$(call DOCKER,$(BUILD_IMAGE),GOOS=$* /usr/bin/make $@)
113107
else
114-
$(call MINIKUBE_GO_BUILD_CMD,$@,$*)
108+
go build -tags "$(MINIKUBE_BUILD_TAGS)" -ldflags="$(MINIKUBE_LDFLAGS) $(K8S_VERSION_LDFLAGS)" -a -o $@ k8s.io/minikube/cmd/minikube
115109
endif
116110

117111
.PHONY: e2e-%-amd64
@@ -179,7 +173,7 @@ integration-versioned: out/minikube
179173
go test -v -test.timeout=30m $(REPOPATH)/test/integration --tags="$(MINIKUBE_INTEGRATION_BUILD_TAGS) versioned" $(TEST_ARGS)
180174

181175
.PHONY: test
182-
test: pkg/minikube/assets/assets.go
176+
test: $(shell $(MINIKUBE_TEST_FILES)) pkg/minikube/assets/assets.go
183177
./test.sh
184178

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

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

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

256250
out/docker-machine-driver-hyperkit: $(shell $(HYPERKIT_FILES))
257251
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
258-
$(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'
252+
$(call DOCKER,$(HYPERKIT_BUILD_IMAGE),CC=o64-clang CXX=o64-clang++ /usr/bin/make $@)
259253
else
260-
$(MINIKUBE_ENV_darwin) go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
254+
GOOS=darwin CGO_ENABLED=1 go build -o $(BUILD_DIR)/docker-machine-driver-hyperkit k8s.io/minikube/cmd/drivers/hyperkit
261255
endif
262256

263257
.PHONY: install-hyperkit-driver

pkg/drivers/hyperkit/driver.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import (
3232
hyperkit "github.com/moby/hyperkit/go"
3333
"github.com/pborman/uuid"
3434
"github.com/pkg/errors"
35-
vmnet "github.com/zchee/go-vmnet"
3635
pkgdrivers "k8s.io/minikube/pkg/drivers"
3736
commonutil "k8s.io/minikube/pkg/util"
3837
)
@@ -159,7 +158,7 @@ func (d *Driver) Start() error {
159158
// Set UUID
160159
h.UUID = uuid.NewUUID().String()
161160
log.Infof("Generated UUID %s", h.UUID)
162-
mac, err := vmnet.GetMACAddressFromUUID(h.UUID)
161+
mac, err := GetMACAddressFromUUID(h.UUID)
163162
if err != nil {
164163
return err
165164
}

pkg/drivers/hyperkit/vmnet.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// +build darwin,cgo
2+
3+
/*
4+
Copyright 2016 The Kubernetes Authors All rights reserved.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package hyperkit
20+
21+
import vmnet "github.com/zchee/go-vmnet"
22+
23+
func GetMACAddressFromUUID(UUID string) (string, error) {
24+
return vmnet.GetMACAddressFromUUID(UUID)
25+
}

pkg/drivers/hyperkit/vmnet_stub.go

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// +build darwin,!cgo
2+
3+
/*
4+
Copyright 2016 The Kubernetes Authors All rights reserved.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
package hyperkit
20+
21+
import "errors"
22+
23+
func GetMACAddressFromUUID(UUID string) (string, error) {
24+
return "", errors.New("Function not supported on CGO_ENABLED=0 binaries")
25+
}

pkg/minikube/bootstrapper/localkube/localkube.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,10 @@ func (lk *LocalkubeBootstrapper) UpdateCluster(config bootstrapper.KubernetesCon
116116
var err error
117117

118118
//add url/file/bundled localkube to file list
119-
if localkubeURIWasSpecified(config) && config.KubernetesVersion != constants.DefaultKubernetesVersion {
120-
lCacher := localkubeCacher{config}
121-
localkubeFile, err = lCacher.fetchLocalkubeFromURI()
122-
if err != nil {
123-
return errors.Wrap(err, "Error updating localkube from uri")
124-
}
125-
} else {
126-
localkubeFile = assets.NewBinDataAsset("out/localkube", "/usr/local/bin", "localkube", "0777")
119+
lCacher := localkubeCacher{config}
120+
localkubeFile, err = lCacher.fetchLocalkubeFromURI()
121+
if err != nil {
122+
return errors.Wrap(err, "Error updating localkube from uri")
127123
}
128124
copyableFiles = append(copyableFiles, localkubeFile)
129125

test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ COV_TMP_FILE=coverage_tmp.txt
3232
# Run "go test" on packages that have test files. Also create coverage profile
3333
echo "Running go tests..."
3434
cd ${GOPATH}/src/${REPO_PATH}
35-
rm -f out/$COV_FILE
35+
rm -f out/$COV_FILE || true
3636
echo "mode: count" > out/$COV_FILE
3737
for pkg in $(go list -f '{{ if .TestGoFiles }} {{.ImportPath}} {{end}}' ./...); do
3838
go test -tags "container_image_ostree_stub containers_image_openpgp" -v $pkg -covermode=count -coverprofile=out/$COV_TMP_FILE

0 commit comments

Comments
 (0)