-
Notifications
You must be signed in to change notification settings - Fork 44
/
Makefile.gen
74 lines (61 loc) · 2.78 KB
/
Makefile.gen
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
#!/usr/bin/make
#
# Copyright 2018 CSP Config Management Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
######################################################################
CANONICAL_GOPATH := $(shell go env GOPATH)/src/kpt.dev/configsync
.PHONY: symlink-gopath
symlink-gopath:
@[[ -d $(CANONICAL_GOPATH) ]] || ln -s $(shell pwd) $(CANONICAL_GOPATH)
@[[ $(shell pwd) == $(shell realpath $(CANONICAL_GOPATH)) ]] \
|| (echo "expected $(shell pwd) to equal $(shell realpath $(CANONICAL_GOPATH))" ; exit 1)
CLIENTGEN_TOOLS := client-gen deepcopy-gen informer-gen lister-gen conversion-gen
INSTALL_CLIENTGEN_TOOLS := $(patsubst %,install-%,$(CLIENTGEN_TOOLS))
.PHONY: $(INSTALL_CLIENTGEN_TOOLS)
$(INSTALL_CLIENTGEN_TOOLS):
GOPATH="$(GO_DIR)" go install "k8s.io/code-generator/cmd/$(subst install-,,$@)"
.PHONY: install-clientgen-tools
# install all clientgen tools (user-friendly target alias)
install-clientgen-tools: $(INSTALL_CLIENTGEN_TOOLS)
CLEAN_CLIENTGEN_TOOLS := $(patsubst %,clean-%,$(CLIENTGEN_TOOLS))
.PHONY: $(CLEAN_CLIENTGEN_TOOLS)
$(CLEAN_CLIENTGEN_TOOLS):
@rm $(BIN_DIR)/$(subst clean-,,$@)
.PHONY: clean-clientgen-tools
# remove all clientgen tools (user-friendly target alias)
clean-clientgen-tools: $(CLEAN_CLIENTGEN_TOOLS)
# The code generation libraries are not module aware, and expect the module to be
# at the canonical gopath. Create a symlink as a hack to enable running clientgen.
.PHONY: clientgen
clientgen: symlink-gopath $(INSTALL_CLIENTGEN_TOOLS)
@echo "+++ Generating clientgen directory"
./scripts/generate-clientset.sh
.PHONY: clientgen-in-docker
# Run make clientgen in the docker buildenv container
clientgen-in-docker: buildenv-dirs
@docker run $(DOCKER_RUN_ARGS) \
make clientgen
# To regenerate api_resources_1_15.txt:
# 1) Create a fresh 1.15 cluster that DOES NOT have ACM installed.
# 2) Run the below command:
# kubectl api-resources --verbs=create,list --no-headers | grep -P "[\w.]* {0,31}(true|false)\s+\w+$" -o > cmd/gen-core-scoper/api_resources_1_15.txt
# 3) Repeat (1) and (2) for Kubernetes 1.18.
#
# Note that we only get resources where "create" and "list" verbs are defined, as ACM
# cannot manage resources it can't create or list.
.PHONY: gen-core-scoper
gen-core-scoper:
@echo "+++ Generating core_scoper.go"
@echo "$(pwd)"
go run cmd/gen-core-scoper/main.go