Skip to content

Commit a25aa22

Browse files
committed
Improve API specification
Signed-off-by: Erik Godding Boye <[email protected]>
1 parent bbea895 commit a25aa22

File tree

3 files changed

+57
-15
lines changed

3 files changed

+57
-15
lines changed

deploy/charts/trust-manager/templates/crd-trust.cert-manager.io_bundles.yaml

+16
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,13 @@ spec:
8282
type: boolean
8383
key:
8484
description: Key of the entry in the object's `data` field to be used.
85+
minLength: 1
8586
type: string
8687
name:
8788
description: |-
8889
Name is the name of the source object in the trust Namespace.
8990
This field must be left empty when `selector` is set
91+
minLength: 1
9092
type: string
9193
selector:
9294
description: |-
@@ -135,6 +137,7 @@ spec:
135137
type: object
136138
x-kubernetes-map-type: atomic
137139
type: object
140+
x-kubernetes-map-type: atomic
138141
inLine:
139142
description: InLine is a simple string to append as the source data.
140143
type: string
@@ -150,11 +153,13 @@ spec:
150153
type: boolean
151154
key:
152155
description: Key of the entry in the object's `data` field to be used.
156+
minLength: 1
153157
type: string
154158
name:
155159
description: |-
156160
Name is the name of the source object in the trust Namespace.
157161
This field must be left empty when `selector` is set
162+
minLength: 1
158163
type: string
159164
selector:
160165
description: |-
@@ -203,6 +208,7 @@ spec:
203208
type: object
204209
x-kubernetes-map-type: atomic
205210
type: object
211+
x-kubernetes-map-type: atomic
206212
useDefaultCAs:
207213
description: |-
208214
UseDefaultCAs, when true, requests the default CA bundle to be used as a source.
@@ -215,7 +221,11 @@ spec:
215221
defaultCAPackageVersion field of the Bundle's status field.
216222
type: boolean
217223
type: object
224+
x-kubernetes-map-type: atomic
225+
maxItems: 100
226+
minItems: 1
218227
type: array
228+
x-kubernetes-list-type: atomic
219229
target:
220230
description: Target is the target location in all namespaces to sync source data to.
221231
properties:
@@ -230,6 +240,7 @@ spec:
230240
properties:
231241
key:
232242
description: Key is the key of the entry in the object's `data` field to be used.
243+
minLength: 1
233244
type: string
234245
password:
235246
default: changeit
@@ -240,13 +251,15 @@ spec:
240251
required:
241252
- key
242253
type: object
254+
x-kubernetes-map-type: atomic
243255
pkcs12:
244256
description: |-
245257
PKCS12 requests a PKCS12-formatted binary trust bundle to be written to the target.
246258
The bundle is by default created without a password.
247259
properties:
248260
key:
249261
description: Key is the key of the entry in the object's `data` field to be used.
262+
minLength: 1
250263
type: string
251264
password:
252265
default: ""
@@ -256,6 +269,7 @@ spec:
256269
required:
257270
- key
258271
type: object
272+
x-kubernetes-map-type: atomic
259273
type: object
260274
configMap:
261275
description: |-
@@ -264,6 +278,7 @@ spec:
264278
properties:
265279
key:
266280
description: Key is the key of the entry in the object's `data` field to be used.
281+
minLength: 1
267282
type: string
268283
required:
269284
- key
@@ -289,6 +304,7 @@ spec:
289304
properties:
290305
key:
291306
description: Key is the key of the entry in the object's `data` field to be used.
307+
minLength: 1
292308
type: string
293309
required:
294310
- key

docs/api/api.md

+25-15
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ func Resource(resource string) schema.GroupResource
125125
Resource takes an unqualified resource and returns a Group qualified GroupResource
126126

127127
<a name="AdditionalFormats"></a>
128-
## type [AdditionalFormats](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L120-L128>)
128+
## type [AdditionalFormats](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L126-L136>)
129129

130130
AdditionalFormats specifies any additional formats to write to the target
131131

@@ -134,9 +134,11 @@ type AdditionalFormats struct {
134134
// JKS requests a JKS-formatted binary trust bundle to be written to the target.
135135
// The bundle has "changeit" as the default password.
136136
// For more information refer to this link https://cert-manager.io/docs/faq/#keystore-passwords
137+
// +optional
137138
JKS *JKS `json:"jks,omitempty"`
138139
// PKCS12 requests a PKCS12-formatted binary trust bundle to be written to the target.
139140
// The bundle is by default created without a password.
141+
// +optional
140142
PKCS12 *PKCS12 `json:"pkcs12,omitempty"`
141143
}
142144
```
@@ -206,7 +208,7 @@ func (in *Bundle) DeepCopyObject() runtime.Object
206208
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
207209

208210
<a name="BundleCondition"></a>
209-
## type [BundleCondition](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L206-L245>)
211+
## type [BundleCondition](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L222-L261>)
210212

211213
BundleCondition contains condition information for a Bundle.
212214

@@ -313,9 +315,9 @@ func (in *BundleList) DeepCopyObject() runtime.Object
313315
DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
314316

315317
<a name="BundleSource"></a>
316-
## type [BundleSource](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L70-L95>)
318+
## type [BundleSource](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L74-L99>)
317319

318-
BundleSource is the set of sources whose data will be appended and synced to the BundleTarget in all Namespaces.
320+
BundleSource is the set of sources whose data will be appended and synced to the BundleTarget in all Namespaces. \+structType=atomic
319321

320322
```go
321323
type BundleSource struct {
@@ -365,13 +367,16 @@ func (in *BundleSource) DeepCopyInto(out *BundleSource)
365367
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
366368

367369
<a name="BundleSpec"></a>
368-
## type [BundleSpec](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L60-L66>)
370+
## type [BundleSpec](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L60-L69>)
369371

370372
BundleSpec defines the desired state of a Bundle.
371373

372374
```go
373375
type BundleSpec struct {
374376
// Sources is a set of references to data whose data will sync to the target.
377+
// +listType=atomic
378+
// +kubebuilder:validation:MinItems=1
379+
// +kubebuilder:validation:MaxItems=100
375380
Sources []BundleSource `json:"sources"`
376381

377382
// Target is the target location in all namespaces to sync source data to.
@@ -398,7 +403,7 @@ func (in *BundleSpec) DeepCopyInto(out *BundleSpec)
398403
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
399404

400405
<a name="BundleStatus"></a>
401-
## type [BundleStatus](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L189-L203>)
406+
## type [BundleStatus](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L205-L219>)
402407

403408
BundleStatus defines the observed state of the Bundle.
404409

@@ -439,19 +444,21 @@ func (in *BundleStatus) DeepCopyInto(out *BundleStatus)
439444
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
440445

441446
<a name="BundleTarget"></a>
442-
## type [BundleTarget](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L99-L117>)
447+
## type [BundleTarget](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L103-L123>)
443448

444449
BundleTarget is the target resource that the Bundle will sync all source data to.
445450

446451
```go
447452
type BundleTarget struct {
448453
// ConfigMap is the target ConfigMap in Namespaces that all Bundle source
449454
// data will be synced to.
455+
// +optional
450456
ConfigMap *KeySelector `json:"configMap,omitempty"`
451457

452458
// Secret is the target Secret that all Bundle source data will be synced to.
453459
// Using Secrets as targets is only supported if enabled at trust-manager startup.
454460
// By default, trust-manager has no permissions for writing to secrets and can only read secrets in the trust namespace.
461+
// +optional
455462
Secret *KeySelector `json:"secret,omitempty"`
456463

457464
// AdditionalFormats specifies any additional formats to write to the target
@@ -484,9 +491,9 @@ func (in *BundleTarget) DeepCopyInto(out *BundleTarget)
484491
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
485492

486493
<a name="JKS"></a>
487-
## type [JKS](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L130-L139>)
488-
494+
## type [JKS](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L140-L149>)
489495

496+
JKS specifies additional target JKS files \+structType=atomic
490497

491498
```go
492499
type JKS struct {
@@ -520,13 +527,14 @@ func (in *JKS) DeepCopyInto(out *JKS)
520527
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
521528

522529
<a name="KeySelector"></a>
523-
## type [KeySelector](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L183-L186>)
530+
## type [KeySelector](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L198-L202>)
524531

525532
KeySelector is a reference to a key for some map data object.
526533

527534
```go
528535
type KeySelector struct {
529536
// Key is the key of the entry in the object's `data` field to be used.
537+
// +kubebuilder:validation:MinLength=1
530538
Key string `json:"key"`
531539
}
532540
```
@@ -550,7 +558,7 @@ func (in *KeySelector) DeepCopyInto(out *KeySelector)
550558
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
551559

552560
<a name="NamespaceSelector"></a>
553-
## type [NamespaceSelector](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L152-L157>)
561+
## type [NamespaceSelector](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L164-L169>)
554562

555563
NamespaceSelector defines selectors to match on Namespaces.
556564

@@ -582,9 +590,9 @@ func (in *NamespaceSelector) DeepCopyInto(out *NamespaceSelector)
582590
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
583591

584592
<a name="PKCS12"></a>
585-
## type [PKCS12](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L141-L149>)
586-
593+
## type [PKCS12](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L153-L161>)
587594

595+
PKCS12 specifies additional target PKCS\#12 files \+structType=atomic
588596

589597
```go
590598
type PKCS12 struct {
@@ -617,15 +625,16 @@ func (in *PKCS12) DeepCopyInto(out *PKCS12)
617625
DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non\-nil.
618626

619627
<a name="SourceObjectKeySelector"></a>
620-
## type [SourceObjectKeySelector](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L161-L180>)
628+
## type [SourceObjectKeySelector](<https://github.com/cert-manager/trust-manager/blob/main/pkg/apis/trust/v1alpha1/types_bundle.go#L174-L195>)
621629

622-
SourceObjectKeySelector is a reference to a source object and its \`data\` key\(s\) in the trust Namespace.
630+
SourceObjectKeySelector is a reference to a source object and its \`data\` key\(s\) in the trust Namespace. \+structType=atomic
623631

624632
```go
625633
type SourceObjectKeySelector struct {
626634
// Name is the name of the source object in the trust Namespace.
627635
// This field must be left empty when `selector` is set
628636
//+optional
637+
// +kubebuilder:validation:MinLength=1
629638
Name string `json:"name,omitempty"`
630639

631640
// Selector is the label selector to use to fetch a list of objects. Must not be set
@@ -635,6 +644,7 @@ type SourceObjectKeySelector struct {
635644

636645
// Key of the entry in the object's `data` field to be used.
637646
//+optional
647+
// +kubebuilder:validation:MinLength=1
638648
Key string `json:"key,omitempty"`
639649

640650
// IncludeAllKeys is a flag to include all keys in the object's `data` field to be used. False by default.

pkg/apis/trust/v1alpha1/types_bundle.go

+16
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ type BundleList struct {
5959
// BundleSpec defines the desired state of a Bundle.
6060
type BundleSpec struct {
6161
// Sources is a set of references to data whose data will sync to the target.
62+
// +listType=atomic
63+
// +kubebuilder:validation:MinItems=1
64+
// +kubebuilder:validation:MaxItems=100
6265
Sources []BundleSource `json:"sources"`
6366

6467
// Target is the target location in all namespaces to sync source data to.
@@ -67,6 +70,7 @@ type BundleSpec struct {
6770

6871
// BundleSource is the set of sources whose data will be appended and synced to
6972
// the BundleTarget in all Namespaces.
73+
// +structType=atomic
7074
type BundleSource struct {
7175
// ConfigMap is a reference (by name) to a ConfigMap's `data` key(s), or to a
7276
// list of ConfigMap's `data` key(s) using label selector, in the trust Namespace.
@@ -99,11 +103,13 @@ type BundleSource struct {
99103
type BundleTarget struct {
100104
// ConfigMap is the target ConfigMap in Namespaces that all Bundle source
101105
// data will be synced to.
106+
// +optional
102107
ConfigMap *KeySelector `json:"configMap,omitempty"`
103108

104109
// Secret is the target Secret that all Bundle source data will be synced to.
105110
// Using Secrets as targets is only supported if enabled at trust-manager startup.
106111
// By default, trust-manager has no permissions for writing to secrets and can only read secrets in the trust namespace.
112+
// +optional
107113
Secret *KeySelector `json:"secret,omitempty"`
108114

109115
// AdditionalFormats specifies any additional formats to write to the target
@@ -121,12 +127,16 @@ type AdditionalFormats struct {
121127
// JKS requests a JKS-formatted binary trust bundle to be written to the target.
122128
// The bundle has "changeit" as the default password.
123129
// For more information refer to this link https://cert-manager.io/docs/faq/#keystore-passwords
130+
// +optional
124131
JKS *JKS `json:"jks,omitempty"`
125132
// PKCS12 requests a PKCS12-formatted binary trust bundle to be written to the target.
126133
// The bundle is by default created without a password.
134+
// +optional
127135
PKCS12 *PKCS12 `json:"pkcs12,omitempty"`
128136
}
129137

138+
// JKS specifies additional target JKS files
139+
// +structType=atomic
130140
type JKS struct {
131141
KeySelector `json:",inline"`
132142

@@ -138,6 +148,8 @@ type JKS struct {
138148
Password *string `json:"password"`
139149
}
140150

151+
// PKCS12 specifies additional target PKCS#12 files
152+
// +structType=atomic
141153
type PKCS12 struct {
142154
KeySelector `json:",inline"`
143155

@@ -158,10 +170,12 @@ type NamespaceSelector struct {
158170

159171
// SourceObjectKeySelector is a reference to a source object and its `data` key(s)
160172
// in the trust Namespace.
173+
// +structType=atomic
161174
type SourceObjectKeySelector struct {
162175
// Name is the name of the source object in the trust Namespace.
163176
// This field must be left empty when `selector` is set
164177
//+optional
178+
// +kubebuilder:validation:MinLength=1
165179
Name string `json:"name,omitempty"`
166180

167181
// Selector is the label selector to use to fetch a list of objects. Must not be set
@@ -171,6 +185,7 @@ type SourceObjectKeySelector struct {
171185

172186
// Key of the entry in the object's `data` field to be used.
173187
//+optional
188+
// +kubebuilder:validation:MinLength=1
174189
Key string `json:"key,omitempty"`
175190

176191
// IncludeAllKeys is a flag to include all keys in the object's `data` field to be used. False by default.
@@ -182,6 +197,7 @@ type SourceObjectKeySelector struct {
182197
// KeySelector is a reference to a key for some map data object.
183198
type KeySelector struct {
184199
// Key is the key of the entry in the object's `data` field to be used.
200+
// +kubebuilder:validation:MinLength=1
185201
Key string `json:"key"`
186202
}
187203

0 commit comments

Comments
 (0)