-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
77 lines (61 loc) · 2.47 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
SHELL=/bin/bash -o pipefail
FIRST_GOPATH:=$(firstword $(subst :, ,$(shell go env GOPATH)))
GO_PKG=github.com/draveness/proxier
K8S_GEN_BINARIES:=deepcopy-gen informer-gen lister-gen client-gen
TYPES_V1BETA1_TARGET:=pkg/apis/maegus/v1beta1/proxier_types.go
K8S_GEN_DEPS:=.header
K8S_GEN_DEPS+=$(TYPES_V1BETA1_TARGET)
K8S_GEN_DEPS+=$(foreach bin,$(K8S_GEN_BINARIES),$(FIRST_GOPATH)/bin/$(bin))
K8S_GEN_DEPS+=$(OPENAPI_GEN_BINARY)
OPERATOR_E2E_IMAGE_TAG:=$(shell tar -cf - pkg | md5)
OPERATOR_E2E_IMAGE_NAME:=draveness/proxier-e2e:$(OPERATOR_E2E_IMAGE_TAG)
.PHONY: test
test:
go test -count=1 ./pkg/...
e2e:
./hack/docker-image-exists.sh || \
(operator-sdk build $(OPERATOR_E2E_IMAGE_NAME) && docker push $(OPERATOR_E2E_IMAGE_NAME))
go test -v ./test/e2e/ --kubeconfig "$(HOME)/.kube/k8s-playground-kubeconfig.yaml" --operator-image $(OPERATOR_E2E_IMAGE_NAME)
run:
operator-sdk up local --namespace=default
LISTER_TARGET := pkg/client/listers/maegus/v1beta1/proxier.go
$(LISTER_TARGET): $(K8S_GEN_DEPS)
$(LISTER_GEN_BINARY) \
$(K8S_GEN_ARGS) \
--input-dirs "$(GO_PKG)/pkg/apis/maegus/v1beta1" \
--output-package "$(GO_PKG)/pkg/client/listers"
CLIENT_TARGET := pkg/client/versioned/clientset.go
$(CLIENT_TARGET): $(K8S_GEN_DEPS)
$(CLIENT_GEN_BINARY) \
$(K8S_GEN_ARGS) \
--input-base "" \
--clientset-name "versioned" \
--input "$(GO_PKG)/pkg/apis/maegus/v1beta1" \
--output-package "$(GO_PKG)/pkg/client"
INFORMER_TARGET := pkg/client/informers/externalversions/maegus/v1beta1/proxier.go
$(INFORMER_TARGET): $(K8S_GEN_DEPS) $(LISTER_TARGET) $(CLIENT_TARGET)
$(INFORMER_GEN_BINARY) \
$(K8S_GEN_ARGS) \
--versioned-clientset-package "$(GO_PKG)/pkg/client/versioned" \
--listers-package "$(GO_PKG)/pkg/client/listers" \
--input-dirs "$(GO_PKG)/pkg/apis/maegus/v1beta1" \
--output-package "$(GO_PKG)/pkg/client/informers"
.PHONY: k8s-gen
k8s-gen: \
$(CLIENT_TARGET) \
$(LISTER_TARGET) \
$(INFORMER_TARGET)
.PHONY: release
release:
./hack/make-release.sh
operator-sdk build draveness/proxier:$(RELEASE)
docker push draveness/proxier:$(RELEASE)
git tag $(RELEASE)
define _K8S_GEN_VAR_TARGET_
$(shell echo $(1) | tr '[:lower:]' '[:upper:]' | tr '-' '_')_BINARY:=$(FIRST_GOPATH)/bin/$(1)
$(FIRST_GOPATH)/bin/$(1):
go get -u -d k8s.io/code-generator/cmd/$(1)
cd $(FIRST_GOPATH)/src/k8s.io/code-generator; git checkout $(K8S_GEN_VERSION)
go install k8s.io/code-generator/cmd/$(1)
endef
$(foreach binary,$(K8S_GEN_BINARIES),$(eval $(call _K8S_GEN_VAR_TARGET_,$(binary))))