diff --git a/Makefile b/Makefile index 3613c1044..fe11a4384 100644 --- a/Makefile +++ b/Makefile @@ -73,6 +73,7 @@ $(GENERATED_CRDS): $(GENERATED) @sed -i -e 's/listKind: PostgresqlList/listKind: postgresqlList/' manifests/postgresql.crd.yaml @hack/adjust_postgresql_crd.sh @mv manifests/acid.zalan.do_operatorconfigurations.yaml manifests/operatorconfiguration.crd.yaml + @hack/adjust_operatorconfiguration_crd.sh @mv manifests/acid.zalan.do_postgresteams.yaml manifests/postgresteam.crd.yaml @cp manifests/postgresql.crd.yaml pkg/apis/acid.zalan.do/v1/postgresql.crd.yaml @cp manifests/operatorconfiguration.crd.yaml pkg/apis/acid.zalan.do/v1/operatorconfiguration.crd.yaml diff --git a/charts/postgres-operator/crds/operatorconfigurations.yaml b/charts/postgres-operator/crds/operatorconfigurations.yaml index 790b9effc..423fd4a89 100644 --- a/charts/postgres-operator/crds/operatorconfigurations.yaml +++ b/charts/postgres-operator/crds/operatorconfigurations.yaml @@ -709,6 +709,9 @@ spec: type: integer type: object maintenance_windows: + items: + pattern: '^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\ *$' + type: string type: array major_version_upgrade: description: MajorVersionUpgradeConfiguration defines how to execute diff --git a/hack/adjust_operatorconfiguration_crd.sh b/hack/adjust_operatorconfiguration_crd.sh new file mode 100755 index 000000000..61fb4ac03 --- /dev/null +++ b/hack/adjust_operatorconfiguration_crd.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Hack to adjust the generated operatorconfiguration CRD YAML file and add +# missing field settings which can not be expressed via kubebuilder markers. +# +# Injections: +# +# * type: string and pattern for the maintenance_windows items. +# The MaintenanceWindow type marshals to/from a string (see marshal.go) but +# the field is declared `+kubebuilder:validation:Schemaless` / +# `+kubebuilder:validation:Type=array`, so controller-gen emits a bare +# `type: array` without the required `items` schema. A structural CRD must +# specify `items` for every array, so the generated CRD is rejected with: +# spec.validation.openAPIV3Schema.properties[configuration] +# .properties[maintenance_windows].items: Required value: must be specified + +file="${1:-"manifests/operatorconfiguration.crd.yaml"}" + +sed -i '/^[[:space:]]*maintenance_windows:$/{ + # Capture the indentation + s/^\([[:space:]]*\)maintenance_windows:$/\1maintenance_windows:\n\1 items:\n\1 pattern: '\''^\\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\\d):([0-5]?\\d)|(2[0-3]|[01]?\\d):([0-5]?\\d))-((2[0-3]|[01]?\\d):([0-5]?\\d)|(2[0-3]|[01]?\\d):([0-5]?\\d))\\ *$'\''\n\1 type: string/ +}' "$file" diff --git a/manifests/operatorconfiguration.crd.yaml b/manifests/operatorconfiguration.crd.yaml index 5f347f2ac..67487ba1c 100644 --- a/manifests/operatorconfiguration.crd.yaml +++ b/manifests/operatorconfiguration.crd.yaml @@ -704,6 +704,9 @@ spec: type: integer type: object maintenance_windows: + items: + pattern: '^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\ *$' + type: string type: array major_version_upgrade: description: MajorVersionUpgradeConfiguration defines how to execute diff --git a/pkg/apis/acid.zalan.do/v1/operatorconfiguration.crd.yaml b/pkg/apis/acid.zalan.do/v1/operatorconfiguration.crd.yaml index 5f347f2ac..67487ba1c 100644 --- a/pkg/apis/acid.zalan.do/v1/operatorconfiguration.crd.yaml +++ b/pkg/apis/acid.zalan.do/v1/operatorconfiguration.crd.yaml @@ -704,6 +704,9 @@ spec: type: integer type: object maintenance_windows: + items: + pattern: '^\ *((Mon|Tue|Wed|Thu|Fri|Sat|Sun):(2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))-((2[0-3]|[01]?\d):([0-5]?\d)|(2[0-3]|[01]?\d):([0-5]?\d))\ *$' + type: string type: array major_version_upgrade: description: MajorVersionUpgradeConfiguration defines how to execute