Skip to content

[Maintenance] Generate CRD with Schemas #1875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- (Feature) Backup Retry Until and BackupPolicy Until Propagation feature
- (Bugfix) Improve Profile Tolerations Merge
- (Maintenance) Update Envoy to v1.32.5
- (Maintenance) Generate CRD with Schemas

## [1.2.47](https://github.com/arangodb/kube-arangodb/tree/1.2.47) (2025-03-28)
- (Bugfix) Use Profile Annotations
Expand Down
42 changes: 37 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ endif

ifeq ($(RELEASE_MODE),community)
MANIFESTPATHCRD := manifests/arango-crd$(MANIFESTSUFFIX).yaml
MANIFESTPATHCRDBASIC := manifests/arango-crd-basic$(MANIFESTSUFFIX).yaml
MANIFESTPATHCRDALL := manifests/arango-crd-all$(MANIFESTSUFFIX).yaml
MANIFESTPATHDEPLOYMENT := manifests/arango-deployment$(MANIFESTSUFFIX).yaml
MANIFESTPATHDEPLOYMENTREPLICATION := manifests/arango-deployment-replication$(MANIFESTSUFFIX).yaml
MANIFESTPATHBACKUP := manifests/arango-backup$(MANIFESTSUFFIX).yaml
Expand All @@ -172,6 +174,8 @@ MANIFESTPATHK2KCLUSTERSYNC := manifests/arango-k2kclustersync$(MANIFESTSUFFIX).y
MANIFESTPATHSTORAGE := manifests/arango-storage$(MANIFESTSUFFIX).yaml
MANIFESTPATHALL := manifests/arango-all$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHCRD := manifests/kustomize/crd/arango-crd$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHCRDBASIC := manifests/kustomize/crd/arango-crd-basic$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHCRDALL := manifests/kustomize/crd/arango-crd-all$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHDEPLOYMENT := manifests/kustomize/deployment/arango-deployment$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHDEPLOYMENTREPLICATION := manifests/kustomize/deployment-replication/arango-deployment-replication$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHBACKUP := manifests/kustomize/backup/arango-backup$(MANIFESTSUFFIX).yaml
Expand All @@ -182,6 +186,8 @@ KUSTOMIZEPATHSTORAGE := manifests/kustomize/storage/arango-storage$(MANIFESTSUFF
KUSTOMIZEPATHALL := manifests/kustomize/all/arango-all$(MANIFESTSUFFIX).yaml
else
MANIFESTPATHCRD := manifests/enterprise-crd$(MANIFESTSUFFIX).yaml
MANIFESTPATHCRDBASIC := manifests/enterprise-crd-basic$(MANIFESTSUFFIX).yaml
MANIFESTPATHCRDALL := manifests/enterprise-crd-all$(MANIFESTSUFFIX).yaml
MANIFESTPATHDEPLOYMENT := manifests/enterprise-deployment$(MANIFESTSUFFIX).yaml
MANIFESTPATHDEPLOYMENTREPLICATION := manifests/enterprise-deployment-replication$(MANIFESTSUFFIX).yaml
MANIFESTPATHBACKUP := manifests/enterprise-backup$(MANIFESTSUFFIX).yaml
Expand All @@ -191,6 +197,8 @@ MANIFESTPATHK2KCLUSTERSYNC := manifests/enterprise-k2kclustersync$(MANIFESTSUFFI
MANIFESTPATHSTORAGE := manifests/enterprise-storage$(MANIFESTSUFFIX).yaml
MANIFESTPATHALL := manifests/enterprise-all$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHCRD := manifests/kustomize-enterprise/crd/enterprise-crd$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHCRDBASIC := manifests/kustomize-enterprise/crd/enterprise-crd-basic$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHCRDALL := manifests/kustomize-enterprise/crd/enterprise-crd-all$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHDEPLOYMENT := manifests/kustomize-enterprise/deployment/enterprise-deployment$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHDEPLOYMENTREPLICATION := manifests/kustomize-enterprise/deployment-replication/enterprise-deployment-replication$(MANIFESTSUFFIX).yaml
KUSTOMIZEPATHBACKUP := manifests/kustomize-enterprise/backup/enterprise-backup$(MANIFESTSUFFIX).yaml
Expand Down Expand Up @@ -524,16 +532,40 @@ manifests:
.PHONY: manifests-crd-file
manifests-crd-file:
@echo Building manifests for CRD - $(MANIFESTPATHCRD)
@printf "" > $(MANIFESTPATHCRD)
@$(foreach FILE,$(CRDS),printf '%s\n# File: chart/kube-arangodb/crds/%s.yaml\n' '---' $(FILE) >> $(MANIFESTPATHCRD) && \
cat '$(ROOT)/chart/kube-arangodb/crds/$(FILE).yaml' >> $(MANIFESTPATHCRD);)
manifests: manifests-crd-file
@go run ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" '$(ROOT)/cmd/main-ops/' crd generate --crd.validation-schema 'all=false' --crd.skip arangolocalstorages.storage.arangodb.com > $(MANIFESTPATHCRD)
manifests-crd: manifests-crd-file

.PHONY: manifests-crd-all-file
manifests-crd-all-file:
@echo Building manifests for CRD with schemas - $(MANIFESTPATHCRDALL)
@go run ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" '$(ROOT)/cmd/main-ops/' crd generate --crd.validation-schema 'all=true' > $(MANIFESTPATHCRDALL)
manifests-crd: manifests-crd-all-file

.PHONY: manifests-crd-basic-file
manifests-crd-basic-file:
@echo Building manifests for CRD with basic schemas - $(MANIFESTPATHCRDBASIC)
@go run ${GOBUILDARGS} --tags "$(GOBUILDTAGS)" '$(ROOT)/cmd/main-ops/' crd generate > $(MANIFESTPATHCRDBASIC)
manifests-crd: manifests-crd-basic-file

.PHONY: manifests-crd-kustomize
manifests-crd-kustomize: manifests-crd-file
@echo Building manifests for CRD - $(KUSTOMIZEPATHCRD)
@cp "$(MANIFESTPATHCRD)" "$(KUSTOMIZEPATHCRD)"
manifests: manifests-crd-kustomize
manifests-crd: manifests-crd-kustomize

.PHONY: manifests-crd-basic-kustomize
manifests-crd-basic-kustomize: manifests-crd-basic-file
@echo Building manifests for CRD with schemas - $(KUSTOMIZEPATHCRDBASIC)
@cp "$(MANIFESTPATHCRDBASIC)" "$(KUSTOMIZEPATHCRDBASIC)"
manifests-crd: manifests-crd-basic-kustomize

.PHONY: manifests-crd-all-kustomize
manifests-crd-all-kustomize: manifests-crd-all-file
@echo Building manifests for CRD with schemas - $(KUSTOMIZEPATHCRDALL)
@cp "$(MANIFESTPATHCRDALL)" "$(KUSTOMIZEPATHCRDALL)"
manifests-crd: manifests-crd-all-kustomize

manifests: manifests-crd

$(eval $(call manifest-generator, deployment, kube-arangodb, \
--set "operator.features.deployment=true" \
Expand Down
6 changes: 4 additions & 2 deletions cmd/crd.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ var (
crdInstallOptions struct {
validationSchema []string
preserveUnknownFields []string
skip []string
force bool
}
)
Expand All @@ -79,6 +80,7 @@ func init() {
f := cmdCRD.PersistentFlags()
f.StringArrayVar(&crdInstallOptions.validationSchema, "crd.validation-schema", defaultValidationSchemaEnabled, "Controls which CRD should have validation schema <crd-name>=<true/false>.")
f.StringArrayVar(&crdInstallOptions.preserveUnknownFields, "crd.preserve-unknown-fields", nil, "Controls which CRD should have enabled preserve unknown fields in validation schema <crd-name>=<true/false>.")
f.StringArrayVar(&crdInstallOptions.skip, "crd.skip", nil, "Controls which CRD should be skipped.")
f.BoolVar(&crdInstallOptions.force, "crd.force-update", false, "Enforce CRD Schema update")

cmdCRD.AddCommand(cmdCRDInstall)
Expand Down Expand Up @@ -191,7 +193,7 @@ func cmdCRDInstallRun(cmd *cobra.Command, args []string) {
ctx, cancel := context.WithTimeout(shutdown.Context(), time.Minute)
defer cancel()

err = crd.EnsureCRDWithOptions(ctx, client, crd.EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts, ForceUpdate: crdInstallOptions.force})
err = crd.EnsureCRDWithOptions(ctx, client, crd.EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts, ForceUpdate: crdInstallOptions.force, Skip: crdInstallOptions.skip})
if err != nil {
os.Exit(1)
}
Expand All @@ -204,7 +206,7 @@ func cmdCRDGenerateRun(cmd *cobra.Command, args []string) {
return
}

err = crd.GenerateCRDYAMLWithOptions(crd.EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts, ForceUpdate: crdInstallOptions.force}, cmd.OutOrStdout())
err = crd.GenerateCRDYAMLWithOptions(crd.EnsureCRDOptions{IgnoreErrors: false, CRDOptions: crdOpts, ForceUpdate: crdInstallOptions.force, Skip: crdInstallOptions.skip}, cmd.OutOrStdout())
if err != nil {
os.Exit(1)
}
Expand Down
3 changes: 3 additions & 0 deletions docs/cli/arangodb_operator_ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Available Commands:
Flags:
--crd.force-update Enforce CRD Schema update
--crd.preserve-unknown-fields stringArray Controls which CRD should have enabled preserve unknown fields in validation schema <crd-name>=<true/false>.
--crd.skip stringArray Controls which CRD should be skipped.
--crd.validation-schema stringArray Controls which CRD should have validation schema <crd-name>=<true/false>.
-h, --help help for crd

Expand All @@ -65,6 +66,7 @@ Flags:
Global Flags:
--crd.force-update Enforce CRD Schema update
--crd.preserve-unknown-fields stringArray Controls which CRD should have enabled preserve unknown fields in validation schema <crd-name>=<true/false>.
--crd.skip stringArray Controls which CRD should be skipped.
--crd.validation-schema stringArray Controls which CRD should have validation schema <crd-name>=<true/false>.
```
[END_INJECT]: # (arangodb_operator_ops_cmd_crd_install)
Expand All @@ -84,6 +86,7 @@ Flags:
Global Flags:
--crd.force-update Enforce CRD Schema update
--crd.preserve-unknown-fields stringArray Controls which CRD should have enabled preserve unknown fields in validation schema <crd-name>=<true/false>.
--crd.skip stringArray Controls which CRD should be skipped.
--crd.validation-schema stringArray Controls which CRD should have validation schema <crd-name>=<true/false>.
```
[END_INJECT]: # (arangodb_operator_ops_cmd_crd_generate)
Expand Down
Loading