Skip to content

Commit dc3d821

Browse files
committed
Update CRD generator to support experimental CRDs
Add support for a new CRD generator. This generator will use `opcon` tags to identify experimental features. A script runs the CRD generation, and creates all the CRDs. New experimental CRDs are now created. Signed-off-by: Todd Short <[email protected]>
1 parent 5812c74 commit dc3d821

File tree

16 files changed

+1537
-18
lines changed

16 files changed

+1537
-18
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ bin/*
88
testbin/*
99
/hack/tools/bin/*
1010
Dockerfile.cross
11-
crd_work_dir/
1211

1312
# Test binary, build with `go test -c`
1413
*.test

Makefile

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -138,20 +138,14 @@ tidy:
138138
go mod tidy
139139

140140
.PHONY: manifests
141-
KUSTOMIZE_CATD_CRDS_DIR := config/base/catalogd/crd/bases
142141
KUSTOMIZE_CATD_RBAC_DIR := config/base/catalogd/rbac
143142
KUSTOMIZE_CATD_WEBHOOKS_DIR := config/base/catalogd/manager/webhook
144-
KUSTOMIZE_OPCON_CRDS_DIR := config/base/operator-controller/crd/bases
145143
KUSTOMIZE_OPCON_RBAC_DIR := config/base/operator-controller/rbac
146-
CRD_WORKING_DIR := crd_work_dir
147144
# Due to https://github.com/kubernetes-sigs/controller-tools/issues/837 we can't specify individual files
148145
# So we have to generate them together and then move them into place
149146
manifests: $(CONTROLLER_GEN) $(KUSTOMIZE) #EXHELP Generate WebhookConfiguration, ClusterRole, and CustomResourceDefinition objects.
150-
mkdir $(CRD_WORKING_DIR)
151-
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) crd paths="./api/v1/..." output:crd:artifacts:config=$(CRD_WORKING_DIR)
152-
mv $(CRD_WORKING_DIR)/olm.operatorframework.io_clusterextensions.yaml $(KUSTOMIZE_OPCON_CRDS_DIR)
153-
mv $(CRD_WORKING_DIR)/olm.operatorframework.io_clustercatalogs.yaml $(KUSTOMIZE_CATD_CRDS_DIR)
154-
rmdir $(CRD_WORKING_DIR)
147+
# Generate CRDs via our own generator
148+
hack/tools/update-crds.sh
155149
# Generate the remaining operator-controller manifests
156150
$(CONTROLLER_GEN) --load-build-tags=$(GO_BUILD_TAGS) rbac:roleName=manager-role paths="./internal/operator-controller/..." output:rbac:artifacts:config=$(KUSTOMIZE_OPCON_RBAC_DIR)
157151
# Generate the remaining catalogd manifests
@@ -193,8 +187,8 @@ bingo-upgrade: $(BINGO) #EXHELP Upgrade tools
193187
.PHONY: verify-crd-compatibility
194188
CRD_DIFF_ORIGINAL_REF := git://main?path=
195189
CRD_DIFF_UPDATED_REF := file://
196-
CRD_DIFF_OPCON_SOURCE := config/base/operator-controller/crd/bases/olm.operatorframework.io_clusterextensions.yaml
197-
CRD_DIFF_CATD_SOURCE := config/base/catalogd/crd/bases/olm.operatorframework.io_clustercatalogs.yaml
190+
CRD_DIFF_OPCON_SOURCE := config/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml
191+
CRD_DIFF_CATD_SOURCE := config/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml
198192
CRD_DIFF_CONFIG := crd-diff-config.yaml
199193
verify-crd-compatibility: $(CRD_DIFF) manifests
200194
$(CRD_DIFF) --config="${CRD_DIFF_CONFIG}" "${CRD_DIFF_ORIGINAL_REF}${CRD_DIFF_OPCON_SOURCE}" ${CRD_DIFF_UPDATED_REF}${CRD_DIFF_OPCON_SOURCE}

api/v1/clustercatalog_types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"sigs.k8s.io/yaml"
2121
)
2222

23-
const crdFilePath = "../../config/base/catalogd/crd/bases/olm.operatorframework.io_clustercatalogs.yaml"
23+
const crdFilePath = "../../config/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml"
2424

2525
func TestImageSourceCELValidationRules(t *testing.T) {
2626
validators := fieldValidatorsFromFile(t, crdFilePath)

config/base/catalogd/crd/experimental/olm.operatorframework.io_clustercatalogs.yaml

Lines changed: 442 additions & 0 deletions
Large diffs are not rendered by default.

config/base/catalogd/crd/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
# since it depends on service name and namespace that are out of this kustomize package.
33
# It should be run by config/default
44
resources:
5-
- bases/olm.operatorframework.io_clustercatalogs.yaml
5+
- standard/olm.operatorframework.io_clustercatalogs.yaml
66
#+kubebuilder:scaffold:crdkustomizeresource

config/base/catalogd/crd/bases/olm.operatorframework.io_clustercatalogs.yaml renamed to config/base/catalogd/crd/standard/olm.operatorframework.io_clustercatalogs.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ kind: CustomResourceDefinition
44
metadata:
55
annotations:
66
controller-gen.kubebuilder.io/version: v0.17.3
7+
olm.operatorframework.io/feature-set: standard
78
name: clustercatalogs.olm.operatorframework.io
89
spec:
910
group: olm.operatorframework.io

config/base/operator-controller/crd/experimental/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 590 additions & 0 deletions
Large diffs are not rendered by default.

config/base/operator-controller/crd/kustomization.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# since it depends on service name and namespace that are out of this kustomize package.
33
# It should be run by config/default
44
resources:
5-
- bases/olm.operatorframework.io_clusterextensions.yaml
5+
- standard/olm.operatorframework.io_clusterextensions.yaml
66

77
# the following config is for teaching kustomize how to do kustomization for CRDs.
88
configurations:

config/base/operator-controller/crd/bases/olm.operatorframework.io_clusterextensions.yaml renamed to config/base/operator-controller/crd/standard/olm.operatorframework.io_clusterextensions.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ kind: CustomResourceDefinition
44
metadata:
55
annotations:
66
controller-gen.kubebuilder.io/version: v0.17.3
7+
olm.operatorframework.io/feature-set: standard
78
name: clusterextensions.olm.operatorframework.io
89
spec:
910
group: olm.operatorframework.io

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ require (
4343
k8s.io/kubernetes v1.32.3
4444
k8s.io/utils v0.0.0-20241210054802-24370beab758
4545
sigs.k8s.io/controller-runtime v0.20.4
46+
sigs.k8s.io/controller-tools v0.17.3
4647
sigs.k8s.io/yaml v1.4.0
4748
)
4849

@@ -99,7 +100,7 @@ require (
99100
github.com/evanphx/json-patch v5.9.0+incompatible // indirect
100101
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
101102
github.com/exponent-io/jsonpath v0.0.0-20210407135951-1de76d718b3f // indirect
102-
github.com/fatih/color v1.16.0 // indirect
103+
github.com/fatih/color v1.18.0 // indirect
103104
github.com/felixge/httpsnoop v1.0.4 // indirect
104105
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
105106
github.com/go-errors/errors v1.4.2 // indirect
@@ -119,6 +120,7 @@ require (
119120
github.com/go-openapi/strfmt v0.23.0 // indirect
120121
github.com/go-openapi/swag v0.23.1 // indirect
121122
github.com/go-openapi/validate v0.24.0 // indirect
123+
github.com/gobuffalo/flect v1.0.3 // indirect
122124
github.com/gobwas/glob v0.2.3 // indirect
123125
github.com/gogo/protobuf v1.3.2 // indirect
124126
github.com/golang/groupcache v0.0.0-20241129210726-2c02b8208cf8 // indirect

0 commit comments

Comments
 (0)