Skip to content

Commit d8a2803

Browse files
cbandydsessler7
authored andcommitted
Add PGUpgrades to the controller-gen TODO hack
Issue: [sc-16347]
1 parent f80110f commit d8a2803

File tree

6 files changed

+28
-7
lines changed

6 files changed

+28
-7
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ clean: clean-deprecated
252252
rm -f config/rbac/role.yaml
253253
[ ! -d testing/kuttl/e2e-generated ] || rm -r testing/kuttl/e2e-generated
254254
[ ! -d testing/kuttl/e2e-generated-other ] || rm -r testing/kuttl/e2e-generated-other
255-
[ ! -d build/crd/generated ] || rm -r build/crd/generated
255+
rm -rf build/crd/generated build/crd/*/generated
256256
[ ! -f hack/tools/setup-envtest ] || hack/tools/setup-envtest --bin-dir=hack/tools/envtest cleanup
257257
[ ! -f hack/tools/setup-envtest ] || rm hack/tools/setup-envtest
258258
[ ! -d hack/tools/envtest ] || rm -r hack/tools/envtest

build/crd/pgupgrades/kustomization.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ patches:
1717
patch: |-
1818
- op: remove
1919
path: /status
20+
- target:
21+
group: apiextensions.k8s.io
22+
version: v1
23+
kind: CustomResourceDefinition
24+
name: pgupgrades.postgres-operator.crunchydata.com
25+
path: todos.yaml
2026
- target:
2127
group: apiextensions.k8s.io
2228
version: v1

build/crd/pgupgrades/todos.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
- op: add
2+
path: /work
3+
value: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
4+
- op: copy
5+
from: /work
6+
path: /spec/versions/0/schema/openAPIV3Schema/properties/spec/properties/imagePullSecrets/items/properties/name/description
7+
- op: remove
8+
path: /work

config/crd/bases/postgres-operator.crunchydata.com_pgupgrades.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,7 @@ spec:
880880
let you locate the referenced object inside the same namespace.
881881
properties:
882882
name:
883-
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
884-
TODO: Add other useful fields. apiVersion, kind, uid?'
883+
description: 'Name of the referent. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
885884
type: string
886885
type: object
887886
type: array

docs/content/references/crd.md

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

hack/create-todo-patch.sh

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
# limitations under the License.
1515

1616
directory=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
17-
crd_build_dir="$directory"/../build/crd
17+
clusters_dir="${directory}/../build/crd/postgresclusters"
18+
upgrades_dir="${directory}/../build/crd/pgupgrades"
1819

1920
# Generate a Kustomize patch file for removing any TODOs we inherit from the Kubernetes API.
2021
# Right now there is one TODO in our CRD. This script focuses on removing the specific TODO
@@ -33,7 +34,7 @@ echo "Generating Kustomize patch file for removing Kube API TODOs"
3334
name_desc_with_todo=$(
3435
python3 -m yq -r \
3536
.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.customTLSSecret.properties.name.description \
36-
"${crd_build_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml"
37+
"${clusters_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml"
3738
)
3839
name_desc_without_todo=$(sed 's/ TODO.*//g' <<< "${name_desc_with_todo}")
3940

@@ -43,4 +44,11 @@ python3 -m yq -y --arg old "${name_desc_with_todo}" --arg new "${name_desc_witho
4344
[paths(select(. == $old)) | { op: "copy", from: "/work", path: "/\(map(tostring) | join("/"))" }] +
4445
[{ op: "remove", path: "/work" }]
4546
' \
46-
"${crd_build_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml" > "${crd_build_dir}/todos.yaml"
47+
"${clusters_dir}/generated/postgres-operator.crunchydata.com_postgresclusters.yaml" > "${clusters_dir}/todos.yaml"
48+
49+
python3 -m yq -y --arg old "${name_desc_with_todo}" --arg new "${name_desc_without_todo}" '
50+
[{ op: "add", path: "/work", value: $new }] +
51+
[paths(select(. == $old)) | { op: "copy", from: "/work", path: "/\(map(tostring) | join("/"))" }] +
52+
[{ op: "remove", path: "/work" }]
53+
' \
54+
"${upgrades_dir}/generated/postgres-operator.crunchydata.com_pgupgrades.yaml" > "${upgrades_dir}/todos.yaml"

0 commit comments

Comments
 (0)