Skip to content

Commit 131fb9e

Browse files
committed
Workaround for CRD generation with preserveUnknownFields=false
1 parent e3a5d9c commit 131fb9e

10 files changed

+3870
-6377
lines changed

Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
99
### Changed
1010
### Removed
1111
### Fixed
12+
* Workaround CRD generation with `preserveUnknownFields=false` [kubernetes-sigs/controller-tools#476](https://github.com/kubernetes-sigs/controller-tools/issues/476)
1213

1314
## [0.5.2] - 2021-11-23
1415
### Added

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ TEST_FILTER_PARAM += $(GO_INTEGRATION_TESTS_PARAMS)
4848
# Kubebuilder v2 compatible paths
4949
CRD_DIR := config/crd/bases
5050
RBAC_DIR := config/rbac
51+
GEN_CRD_OPTIONS := crd:crdVersions=v1,preserveUnknownFields=false
52+
53+
# fix for https://github.com/kubernetes-sigs/controller-tools/issues/476
54+
.PHONY: .kubebuilder.fix-preserve-unknown-fields
55+
.kubebuilder.fix-preserve-unknown-fields:
56+
for crd in $(wildcard $(CRD_DIR)/*.yaml) ; do \
57+
$(YQ) e '.spec.preserveUnknownFields=false' -i "$${crd}" ;\
58+
done
59+
.kubebuilder.manifests.done: .kubebuilder.fix-preserve-unknown-fields
5160

5261
.PHONY: .kubebuilder.update.chart
5362
.kubebuilder.update.chart: kubebuilder.manifests $(YQ)

config/crd/bases/mysql.presslabs.org_mysqlbackups.yaml

Lines changed: 71 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
2-
---
31
apiVersion: apiextensions.k8s.io/v1
42
kind: CustomResourceDefinition
53
metadata:
@@ -16,90 +14,77 @@ spec:
1614
singular: mysqlbackup
1715
scope: Namespaced
1816
versions:
19-
- name: v1alpha1
20-
schema:
21-
openAPIV3Schema:
22-
description: MysqlBackup is the Schema for the mysqlbackups API
23-
properties:
24-
apiVersion:
25-
description: 'APIVersion defines the versioned schema of this representation
26-
of an object. Servers should convert recognized schemas to the latest
27-
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
28-
type: string
29-
kind:
30-
description: 'Kind is a string value representing the REST resource this
31-
object represents. Servers may infer this from the endpoint the client
32-
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
33-
type: string
34-
metadata:
35-
type: object
36-
spec:
37-
description: MysqlBackupSpec defines the desired state of MysqlBackup
38-
properties:
39-
backupSecretName:
40-
description: BackupSecretName the name of secrets that contains the
41-
credentials to access the bucket. Default is used the secret specified
42-
in cluster.
43-
type: string
44-
backupURL:
45-
description: BackupURL represents the URL to the backup location,
46-
this can be partially specifyied. Default is used the one specified
47-
in the cluster.
48-
type: string
49-
clusterName:
50-
description: ClustterName represents the cluster for which to take
51-
backup
52-
type: string
53-
remoteDeletePolicy:
54-
description: RemoteDeletePolicy the deletion policy that specify how
55-
to treat the data from remote storage. By default it's used softDelete.
56-
type: string
57-
required:
58-
- clusterName
59-
type: object
60-
status:
61-
description: MysqlBackupStatus defines the observed state of MysqlBackup
62-
properties:
63-
completed:
64-
description: Completed indicates whether the backup is in a final
65-
state, no matter whether its' corresponding job failed or succeeded
66-
type: boolean
67-
conditions:
68-
description: Conditions represents the backup resource conditions
69-
list.
70-
items:
71-
description: BackupCondition defines condition struct for backup
72-
resource
73-
properties:
74-
lastTransitionTime:
75-
description: LastTransitionTime
76-
format: date-time
77-
type: string
78-
message:
79-
description: Message
80-
type: string
81-
reason:
82-
description: Reason
83-
type: string
84-
status:
85-
description: Status of the condition, one of (\"True\", \"False\",
86-
\"Unknown\")
87-
type: string
88-
type:
89-
description: type of cluster condition, values in (\"Ready\")
90-
type: string
91-
required:
92-
- lastTransitionTime
93-
- message
94-
- reason
95-
- status
96-
- type
97-
type: object
98-
type: array
99-
type: object
100-
type: object
101-
served: true
102-
storage: true
17+
- name: v1alpha1
18+
schema:
19+
openAPIV3Schema:
20+
description: MysqlBackup is the Schema for the mysqlbackups API
21+
properties:
22+
apiVersion:
23+
description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
24+
type: string
25+
kind:
26+
description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
27+
type: string
28+
metadata:
29+
type: object
30+
spec:
31+
description: MysqlBackupSpec defines the desired state of MysqlBackup
32+
properties:
33+
backupSecretName:
34+
description: BackupSecretName the name of secrets that contains the credentials to access the bucket. Default is used the secret specified in cluster.
35+
type: string
36+
backupURL:
37+
description: BackupURL represents the URL to the backup location, this can be partially specifyied. Default is used the one specified in the cluster.
38+
type: string
39+
clusterName:
40+
description: ClustterName represents the cluster for which to take backup
41+
type: string
42+
remoteDeletePolicy:
43+
description: RemoteDeletePolicy the deletion policy that specify how to treat the data from remote storage. By default it's used softDelete.
44+
type: string
45+
required:
46+
- clusterName
47+
type: object
48+
status:
49+
description: MysqlBackupStatus defines the observed state of MysqlBackup
50+
properties:
51+
completed:
52+
description: Completed indicates whether the backup is in a final state, no matter whether its' corresponding job failed or succeeded
53+
type: boolean
54+
conditions:
55+
description: Conditions represents the backup resource conditions list.
56+
items:
57+
description: BackupCondition defines condition struct for backup resource
58+
properties:
59+
lastTransitionTime:
60+
description: LastTransitionTime
61+
format: date-time
62+
type: string
63+
message:
64+
description: Message
65+
type: string
66+
reason:
67+
description: Reason
68+
type: string
69+
status:
70+
description: Status of the condition, one of (\"True\", \"False\", \"Unknown\")
71+
type: string
72+
type:
73+
description: type of cluster condition, values in (\"Ready\")
74+
type: string
75+
required:
76+
- lastTransitionTime
77+
- message
78+
- reason
79+
- status
80+
- type
81+
type: object
82+
type: array
83+
type: object
84+
type: object
85+
served: true
86+
storage: true
87+
preserveUnknownFields: false
10388
status:
10489
acceptedNames:
10590
kind: ""

0 commit comments

Comments
 (0)