Skip to content

Commit 4d0a1e7

Browse files
committed
api: Generate CRDs from APIs
1 parent d4d856b commit 4d0a1e7

14 files changed

+1116
-661
lines changed

Makefile

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@ GIT_BRANCH:=$(shell git symbolic-ref --short HEAD 2>&1 | grep -v fatal)
77
#define the GO_BUILD_ARGS if you need to pass additional arguments to the go build
88
GO_BUILD_ARGS?=
99

10+
## Location to install dependencies to
11+
LOCALBIN ?= $(shell pwd)/bin
12+
$(LOCALBIN):
13+
mkdir -p $(LOCALBIN)
14+
15+
## Tool Versions
16+
CONTROLLER_TOOLS_VERSION ?= v0.9.2
17+
18+
## Tool Binaries
19+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
20+
1021
# Reset branch name if this a Travis CI environment
1122
ifneq ($(strip $(TRAVIS_BRANCH)),)
1223
GIT_BRANCH:=${TRAVIS_BRANCH}
@@ -35,7 +46,7 @@ endif
3546

3647
.PHONY: print-global-variables
3748

38-
# Build the controler executable for use in docker image build
49+
# Build the controller executable for use in docker image build
3950
mcad-controller: init generate-code
4051
ifeq ($(strip $(GO_BUILD_ARGS)),)
4152
$(info Compiling controller)
@@ -67,6 +78,15 @@ verify-tag-name: print-global-variables
6778
# Check for invalid tag name
6879
t=${TAG} && [ $${#t} -le 128 ] || { echo "Target name $$t has 128 or more chars"; false; }
6980

81+
.PHONY: controller-gen
82+
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
83+
$(CONTROLLER_GEN): $(LOCALBIN)
84+
test -s $(LOCALBIN)/controller-gen || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
85+
86+
.PHONY: manifests
87+
manifests: controller-gen ## Generate CustomResourceDefinition objects.
88+
$(CONTROLLER_GEN) crd:allowDangerousTypes=true paths="./pkg/apis/..." output:crd:artifacts:config=config/crd/bases
89+
7090
generate-code: pkg/apis/controller/v1beta1/zz_generated.deepcopy.go
7191

7292
pkg/apis/controller/v1beta1/zz_generated.deepcopy.go: ${BIN_DIR}/deepcopy-gen
@@ -141,18 +161,17 @@ clean:
141161
#CRD file maintenance rules
142162
DEPLOYMENT_CRD_DIR=deployment/mcad-controller/crds
143163
CRD_BASE_DIR=config/crd/bases
144-
MCAD_CRDS= ${DEPLOYMENT_CRD_DIR}/ibm.com_quotasubtree-v1.yaml \
164+
MCAD_CRDS= ${DEPLOYMENT_CRD_DIR}/ibm.com_quotasubtrees.yaml \
145165
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_appwrappers.yaml \
146166
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_queuejobs.yaml \
147167
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_schedulingspecs.yaml
148168

149169
update-deployment-crds: ${MCAD_CRDS}
150170

151-
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_schedulingspecs.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_schedulingspecs.yaml
171+
${DEPLOYMENT_CRD_DIR}/ibm.com_quotasubtrees.yaml : ${CRD_BASE_DIR}/ibm.com_quotasubtrees.yaml
152172
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_appwrappers.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_appwrappers.yaml
153173
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_queuejobs.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_queuejobs.yaml
154174
${DEPLOYMENT_CRD_DIR}/mcad.ibm.com_schedulingspecs.yaml : ${CRD_BASE_DIR}/mcad.ibm.com_schedulingspecs.yaml
155175

156-
157176
$(DEPLOYMENT_CRD_DIR)/%: ${CRD_BASE_DIR}/%
158-
cp $< $@
177+
cp $< $@

config/crd/bases/ibm.com_quotasubtree-v1.yaml

Lines changed: 0 additions & 62 deletions
This file was deleted.
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
---
2+
apiVersion: apiextensions.k8s.io/v1
3+
kind: CustomResourceDefinition
4+
metadata:
5+
annotations:
6+
controller-gen.kubebuilder.io/version: v0.9.2
7+
creationTimestamp: null
8+
name: quotasubtrees.ibm.com
9+
spec:
10+
group: ibm.com
11+
names:
12+
kind: QuotaSubtree
13+
listKind: QuotaSubtreeList
14+
plural: quotasubtrees
15+
singular: quotasubtree
16+
scope: Namespaced
17+
versions:
18+
- name: v1
19+
schema:
20+
openAPIV3Schema:
21+
description: QuotaSubtree is a specification for a quota subtree resource
22+
properties:
23+
apiVersion:
24+
description: 'APIVersion defines the versioned schema of this representation
25+
of an object. Servers should convert recognized schemas to the latest
26+
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
27+
type: string
28+
kind:
29+
description: 'Kind is a string value representing the REST resource this
30+
object represents. Servers may infer this from the endpoint the client
31+
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
32+
type: string
33+
metadata:
34+
type: object
35+
spec:
36+
description: QuotaSubtreeSpec is the spec for a resource plan
37+
properties:
38+
children:
39+
items:
40+
description: Child is the spec for a QuotaSubtree resource
41+
properties:
42+
name:
43+
type: string
44+
namespace:
45+
type: string
46+
path:
47+
type: string
48+
quotas:
49+
description: Quota is the spec for a QuotaSubtree resource
50+
properties:
51+
disabled:
52+
type: boolean
53+
hardLimit:
54+
type: boolean
55+
requests:
56+
additionalProperties:
57+
anyOf:
58+
- type: integer
59+
- type: string
60+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
61+
x-kubernetes-int-or-string: true
62+
type: object
63+
type: object
64+
type: object
65+
type: array
66+
parent:
67+
type: string
68+
parentNamespace:
69+
type: string
70+
type: object
71+
status:
72+
description: QuotaSubtreeStatus is the status for a QuotaSubtree resource
73+
properties:
74+
children:
75+
items:
76+
description: ResourceAllocation is the spec for the child status
77+
properties:
78+
allocated:
79+
description: ResourceAllocationStatus is the spec for the child
80+
resource usage
81+
properties:
82+
requests:
83+
additionalProperties:
84+
type: string
85+
type: object
86+
type: object
87+
name:
88+
type: string
89+
namespace:
90+
type: string
91+
path:
92+
type: string
93+
type: object
94+
type: array
95+
totalAllocation:
96+
description: ResourceAllocation is the spec for the child status
97+
properties:
98+
allocated:
99+
description: ResourceAllocationStatus is the spec for the child
100+
resource usage
101+
properties:
102+
requests:
103+
additionalProperties:
104+
type: string
105+
type: object
106+
type: object
107+
name:
108+
type: string
109+
namespace:
110+
type: string
111+
path:
112+
type: string
113+
type: object
114+
required:
115+
- children
116+
- totalAllocation
117+
type: object
118+
required:
119+
- spec
120+
type: object
121+
served: true
122+
storage: true

0 commit comments

Comments
 (0)