Skip to content

Commit 3499476

Browse files
authored
Merge pull request #95 from awslabs/crd/changes
Enhance ResourceGroup CRD/change field names
2 parents 28862d9 + 32a93e8 commit 3499476

File tree

46 files changed

+493
-497
lines changed

Some content is hidden

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

46 files changed

+493
-497
lines changed

api/v1alpha1/resource_group.go

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,12 @@ const (
2626

2727
// ResourceGroupSpec defines the desired state of ResourceGroup
2828
type ResourceGroupSpec struct {
29-
// The kind of the resourcegroup. This is used to generate
30-
// and create the CRD for the resourcegroup.
31-
//
32-
// +kubebuilder:validation:Required
33-
Kind string `json:"kind,omitempty"`
34-
// The APIVersion of the resourcegroup. This is used to generate
35-
// and create the CRD for the resourcegroup.
36-
//
37-
// +kubebuilder:validation:Required
38-
APIVersion string `json:"apiVersion,omitempty"`
39-
// The definition of the resourcegroup, which includes the spec, status,
40-
// types, and some validation rules.
29+
// The schema of the resourcegroup, which includes the
30+
// apiVersion, kind, spec, status, types, and some validation
31+
// rules.
4132
//
4233
// +kubebuilder:validation:Required
43-
Definition *Definition `json:"definition,omitempty"`
34+
Schema *Schema `json:"schema,omitempty"`
4435
// The resources that are part of the resourcegroup.
4536
//
4637
// +kubebuilder:validation:Optional
@@ -54,9 +45,19 @@ type ResourceGroupSpec struct {
5445
DefaultServiceAccounts map[string]string `json:"defaultServiceAccounts,omitempty"`
5546
}
5647

57-
// Definition represents the attributes that define an instance of
48+
// Schema represents the attributes that define an instance of
5849
// a resourcegroup.
59-
type Definition struct {
50+
type Schema struct {
51+
// The kind of the resourcegroup. This is used to generate
52+
// and create the CRD for the resourcegroup.
53+
//
54+
// +kubebuilder:validation:Required
55+
Kind string `json:"kind,omitempty"`
56+
// The APIVersion of the resourcegroup. This is used to generate
57+
// and create the CRD for the resourcegroup.
58+
//
59+
// +kubebuilder:validation:Required
60+
APIVersion string `json:"apiVersion,omitempty"`
6061
// The spec of the resourcegroup. Typically, this is the spec of
6162
// the CRD that the resourcegroup is managing. This is adhering
6263
// to the SimpleSchema spec
@@ -83,11 +84,11 @@ type Resource struct {
8384
// +kubebuilder:validation:Required
8485
Name string `json:"name,omitempty"`
8586
// +kubebuilder:validation:Required
86-
Definition runtime.RawExtension `json:"definition,omitempty"`
87+
Template runtime.RawExtension `json:"template,omitempty"`
8788
// +kubebuilder:validation:Optional
88-
ReadyOn []string `json:"readyOn,omitempty"`
89+
ReadyWhen []string `json:"readyWhen,omitempty"`
8990
// +kubebuilder:validation:Optional
90-
Conditions []string `json:"conditions,omitempty"`
91+
IncludeWhen []string `json:"includeWhen,omitempty"`
9192
}
9293

9394
// ResourceGroupStatus defines the observed state of ResourceGroup

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 31 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/x.symphony.k8s.aws_resourcegroups.yaml

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,6 @@ spec:
5858
spec:
5959
description: ResourceGroupSpec defines the desired state of ResourceGroup
6060
properties:
61-
apiVersion:
62-
description: |-
63-
The APIVersion of the resourcegroup. This is used to generate
64-
and create the CRD for the resourcegroup.
65-
type: string
6661
defaultServiceAccounts:
6762
additionalProperties:
6863
type: string
@@ -72,11 +67,44 @@ spec:
7267
Special key "*" defines the default service account for any
7368
namespace not explicitly mapped.
7469
type: object
75-
definition:
70+
resources:
71+
description: The resources that are part of the resourcegroup.
72+
items:
73+
properties:
74+
includeWhen:
75+
items:
76+
type: string
77+
type: array
78+
name:
79+
type: string
80+
readyWhen:
81+
items:
82+
type: string
83+
type: array
84+
template:
85+
type: object
86+
x-kubernetes-preserve-unknown-fields: true
87+
required:
88+
- name
89+
- template
90+
type: object
91+
type: array
92+
schema:
7693
description: |-
77-
The definition of the resourcegroup, which includes the spec, status,
78-
types, and some validation rules.
94+
The schema of the resourcegroup, which includes the
95+
apiVersion, kind, spec, status, types, and some validation
96+
rules.
7997
properties:
98+
apiVersion:
99+
description: |-
100+
The APIVersion of the resourcegroup. This is used to generate
101+
and create the CRD for the resourcegroup.
102+
type: string
103+
kind:
104+
description: |-
105+
The kind of the resourcegroup. This is used to generate
106+
and create the CRD for the resourcegroup.
107+
type: string
80108
spec:
81109
description: |-
82110
The spec of the resourcegroup. Typically, this is the spec of
@@ -105,38 +133,12 @@ spec:
105133
items:
106134
type: string
107135
type: array
136+
required:
137+
- apiVersion
138+
- kind
108139
type: object
109-
kind:
110-
description: |-
111-
The kind of the resourcegroup. This is used to generate
112-
and create the CRD for the resourcegroup.
113-
type: string
114-
resources:
115-
description: The resources that are part of the resourcegroup.
116-
items:
117-
properties:
118-
conditions:
119-
items:
120-
type: string
121-
type: array
122-
definition:
123-
type: object
124-
x-kubernetes-preserve-unknown-fields: true
125-
name:
126-
type: string
127-
readyOn:
128-
items:
129-
type: string
130-
type: array
131-
required:
132-
- definition
133-
- name
134-
type: object
135-
type: array
136140
required:
137-
- apiVersion
138-
- definition
139-
- kind
141+
- schema
140142
type: object
141143
status:
142144
description: ResourceGroupStatus defines the observed state of ResourceGroup

examples/ack-controller/ec2-controller/ec2-controller.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ kind: ResourceGroup
33
metadata:
44
name: ec2controller.x.symphony.k8s.aws
55
spec:
6-
apiVersion: v1alpha1
7-
kind: EC2Controller
8-
definition:
6+
schema:
7+
apiVersion: v1alpha1
8+
kind: EC2Controller
99
spec:
1010
name: string | default=ec2-controller
1111
namespace: string | default=default
@@ -38,15 +38,15 @@ spec:
3838
name: string | default=ec2-controller-sa
3939
resources:
4040
- name: ec2CRDGroup
41-
definition:
41+
template:
4242
apiVersion: x.symphony.k8s.aws/v1alpha1
4343
kind: EC2CRDGroup
4444
metadata:
4545
name: ${spec.name}-crd-group
4646
spec:
4747
name: ${spec.name}-crd-group
4848
- name: ec2ControllerIamRole
49-
definition:
49+
template:
5050
apiVersion: iam.services.k8s.aws/v1alpha1
5151
kind: Role
5252
metadata:
@@ -71,7 +71,7 @@ spec:
7171
}]
7272
}
7373
- name: serviceAccount
74-
definition:
74+
template:
7575
apiVersion: v1
7676
kind: ServiceAccount
7777
metadata:
@@ -80,7 +80,7 @@ spec:
8080
annotations:
8181
eks.amazonaws.com/role-arn: ${ec2ControllerIamRole.status.ackResourceMetadata.arn}
8282
- name: deployment
83-
definition:
83+
template:
8484
apiVersion: apps/v1
8585
kind: Deployment
8686
metadata:
@@ -139,7 +139,7 @@ spec:
139139
ports:
140140
- containerPort: 80
141141
- name: clusterRoleBinding
142-
definition:
142+
template:
143143
apiVersion: rbac.authorization.k8s.io/v1
144144
kind: ClusterRoleBinding
145145
metadata:
@@ -153,7 +153,7 @@ spec:
153153
name: ${serviceAccount.metadata.name}
154154
namespace: ${serviceAccount.metadata.namespace}
155155
- name: clusterRole
156-
definition:
156+
template:
157157
apiVersion: rbac.authorization.k8s.io/v1
158158
kind: ClusterRole
159159
metadata:

0 commit comments

Comments
 (0)