-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.subctl
57 lines (45 loc) · 2.21 KB
/
Makefile.subctl
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
# -*- makefile -*-
VERSION ?= devel
GO ?= go
GOARCH = $(shell $(GO) env GOARCH)
export GOARCH
GOEXE = $(shell $(GO) env GOEXE)
GOOS = $(shell $(GO) env GOOS)
export GOOS
CRD_OPTIONS ?= "crd:crdVersions=v1,trivialVersions=false"
bin/subctl: bin/subctl-$(VERSION)-$(GOOS)-$(GOARCH)$(GOEXE)
ln -sf $(<F) $@
# Versions may include hyphens so it's easier to use $(VERSION) than to extract them from the target
bin/subctl-%: generate-embeddedyamls $(shell find pkg/subctl/ -name "*.go")
mkdir -p $(@D)
$(SCRIPTS_DIR)/compile.sh \
--ldflags "-X github.com/submariner-io/submariner-operator/pkg/version.Version=$(VERSION) \
-X=github.com/submariner-io/submariner-operator/api.DefaultSubmarinerOperatorVersion=$${DEFAULT_IMAGE_VERSION#v}" \
--noupx --debug $@ ./pkg/subctl/main.go $(BUILD_ARGS)
generate-embeddedyamls: generate pkg/subctl/operator/common/embeddedyamls/yamls.go
OPERATOR_CRDS=\
deploy/crds/submariner.io_servicediscoveries.yaml \
deploy/crds/submariner.io_brokers.yaml \
deploy/crds/submariner.io_submariners.yaml
SUBMARINER_CRDS=\
deploy/submariner/crds/submariner.io_clusters.yaml \
deploy/submariner/crds/submariner.io_endpoints.yaml \
deploy/submariner/crds/submariner.io_gateways.yaml
pkg/subctl/operator/common/embeddedyamls/yamls.go: pkg/embeddedyamls/generators/yamls2go.go $(OPERATOR_CRDS) $(SUBMARINER_CRDS) $(shell find deploy/ -name "*.yaml") $(shell find config/rbac/ -name "*.yaml")
$(GO) generate pkg/embeddedyamls/generate.go
CONTROLLER_GEN := $(CURDIR)/bin/controller-gen
$(CONTROLLER_GEN):
mkdir -p $(@D)
$(GO) build -o $@ sigs.k8s.io/controller-tools/cmd/controller-gen
# Operator CRDs
$(OPERATOR_CRDS): $(CONTROLLER_GEN) ./api/submariner/v1alpha1/servicediscovery_types.go ./api/submariner/v1alpha1/submariner_types.go
cd api && $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:artifacts:config=../deploy/crds
test -f $@
# Submariner CRDs
$(SUBMARINER_CRDS): $(CONTROLLER_GEN)
mkdir -p $(@D)
cd ../submariner/pkg/apis && $(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:dir=../../../submariner-operator/deploy/submariner/crds
test -f $@
# Generate code
generate: $(CONTROLLER_GEN)
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt,year=$(shell date +"%Y")" paths="./..."