Skip to content

Commit fd42765

Browse files
author
Martin Vladev
authored
Generate CRDs for APIs (#471)
- CRDs are now generated with `make generate` with `controller-gen` from `controller-runtime`. - Removed unneeded `MachineTemplate`. - Use `k8s.io/api/autoscaling/v1.Scale` instead of home-brew copy. - Split all versioned APIs into separate `go` files for better code navigation.
1 parent 737093b commit fd42765

File tree

55 files changed

+4049
-3487
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+4049
-3487
lines changed

Makefile

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ CONTROL_NAMESPACE := default
2020
CONTROL_KUBECONFIG := dev/target-kubeconfig.yaml
2121
TARGET_KUBECONFIG := dev/target-kubeconfig.yaml
2222

23+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
24+
ifeq (,$(shell go env GOBIN))
25+
GOBIN=$(shell go env GOPATH)/bin
26+
else
27+
GOBIN=$(shell go env GOBIN)
28+
endif
29+
2330
#########################################
2431
# Rules for local development scenarios #
2532
#########################################
@@ -120,3 +127,25 @@ show-coverage:
120127
test-clean:
121128
@find . -name "*.coverprofile" -type f -delete
122129
@rm -f $(COVERPROFILE)
130+
131+
generate: controller-gen
132+
$(CONTROLLER_GEN) crd paths=./pkg/apis/machine/v1alpha1... output:crd:dir=kubernetes/crds output:stdout
133+
@./hack/generate-code
134+
135+
# find or download controller-gen
136+
# download controller-gen if necessary
137+
.PHONY: controller-gen
138+
controller-gen:
139+
ifeq (, $(shell which controller-gen))
140+
@{ \
141+
set -e ;\
142+
CONTROLLER_GEN_TMP_DIR=$$(mktemp -d) ;\
143+
cd $$CONTROLLER_GEN_TMP_DIR ;\
144+
go mod init tmp ;\
145+
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.3.0 ;\
146+
rm -rf $$CONTROLLER_GEN_TMP_DIR ;\
147+
}
148+
CONTROLLER_GEN=$(GOBIN)/controller-gen
149+
else
150+
CONTROLLER_GEN=$(shell which controller-gen)
151+
endif

0 commit comments

Comments
 (0)