Skip to content

Commit 1619aee

Browse files
ZashaarnqXartos
committed
schema: Specify config properties for capi, hnc, storage
This adds: - common reusable things under $defs - clusterApi - harbor - hnc - objectStorage - rookCeph - storageClasses - user - velero Common objects defined by the Kubernetes project are either prefixed with 'kubernetes' when authored by us, using an 'io.k8s' prefix when imported directly from the Kubernetes API definitions. They can be found in the file kubernetes/spec/api/openapi-spec/v3/api__v1_openapi.json The following script was used to find all referenced objects that were needed. ```bash set -euxo pipefail yq4 -i -P 'del(.$defs.kubernetesAffinity)' config/schemas/config.yaml c="io.k8s.api.core.v1.Affinity" yq4 -i -P '.$defs[env(c)] = load(".../kubernetes/api/openapi-spec/v3/api__v1_openapi.json").components.schemas[env(c)]' config/schemas/config.yaml c="io.k8s.apimachinery.pkg.apis.meta.v1.LabelSelectorRequirement" yq4 -i -P '.$defs[env(c)] = load(".../kubernetes/api/openapi-spec/v3/api__v1_openapi.json").components.schemas[env(c)]' config/schemas/config.yaml while grep -qF '#/components/schemas/' config/schemas/config.yaml; do for component in $(grep -oP "#/components/schemas/[^'\"]*" config/schemas/config.yaml | cut -d/ -f4); do c="${component}" yq4 -i -P '.$defs[env(c)] = load(".../kubernetes/api/openapi-spec/v3/api__v1_openapi.json").components.schemas[env(c)]' config/schemas/config.yaml sed -i "s|#/components/schemas/${component}|#/\$defs/${component}|" config/schemas/config.yaml done done ``` Co-authored-by: André Arnqvist <58822152+aarnq@users.noreply.github.com> Co-authored-by: Fredrik Liv <fredrik.liv@elastisys.com>
1 parent 7614c4f commit 1619aee

File tree

4 files changed

+1253
-10
lines changed

4 files changed

+1253
-10
lines changed

config/schemas/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ EOF
8585

8686
The output can be tweaked and inserted into `config/schemas/config.yaml` under `.properties`.
8787

88+
To limit duplication, common properties that are used in many places can be placed under `.$defs` and referenced via `$ref: '#/$defs/thing'`
89+
90+
```yaml
91+
$defs:
92+
common:
93+
title: Some Common Thing
94+
service:
95+
title: The Service
96+
common:
97+
$ref: '#/$defs/common'
98+
```
99+
88100
## VSCode
89101
90102
The plugin `redhat.vscode-yaml` can provide auto completion, validation and help texts from the schema.

0 commit comments

Comments
 (0)