You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: config/schemas/README.md
+152Lines changed: 152 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -109,3 +109,155 @@ This can be enabled this in other repositories by editing the file `.vscode/sett
109
109
}
110
110
}
111
111
```
112
+
113
+
## Guidelines
114
+
115
+
The uses for the schema is to provide structural and conditional validation here in this repository, and to provide reference documentation in the public documentation repository.
116
+
To make it easier to read, write, and use the schema we have a set of guidelines to make the most out of it that will follow below.
117
+
118
+
> [!note]
119
+
> The word "schema" here refers to any part of the schema, even subschemas, or schemas in definitions, etc.
120
+
>
121
+
> The example keys given are within the schema, shortened by stripping any `properties` and `items` components.
122
+
123
+
### Metadata
124
+
125
+
These guidelines aim to help in creating better quality reference documentation.
126
+
127
+
#### Titles
128
+
129
+
- Must be provided, else it becomes rendered as `Untitled`.
130
+
- Should be capitalised, as it becomes part of rendered headers `<title> Schema`.
131
+
- Should be short, as it becomes part of rendered names.
132
+
- Should be based on the key of the schema, as it becomes more intuitive.
133
+
- Should include the context of the schema for common keys, e.g. `Object Storage` and `Object Storage Network Policies`.
134
+
- Should include the context type of the schema last, as it becomes part of rendered headers `<title> <type> Schema`.
135
+
136
+
#### Descriptions
137
+
138
+
- Must be [GitHub Flavoured Markdown (GFM)](https://github.github.com/gfm/), as it will be rendered down into markdown documentation.
139
+
- Should be provided for all complex types, `array` and `object` with `items` or `properties` respectively, and other types of note.
140
+
- Should be written with full sentences, including proper punctuation.
141
+
- Should include a leading explanation of what the option does and affect.
142
+
- For the root of larger schemas, e.g:
143
+
- `.dex`- "Configure Dex, the federated OpenID connect identity provider."
144
+
- For the root of smaller schemas, e.g.:
145
+
- `.dex.expiry`- "Configure expiry when authenticating via Dex."
146
+
- For the leaf of schemas, e.g.:
147
+
- `.dex.expiry.idToken`- "Configure expiry of id tokens."
148
+
- Should include a follow up explanation for more details when required, e.g:
149
+
- `.grafana`- "Compliant Kubernetes hosts two instances of Grafana one for the Platform Administrator and one for the Application Developer"
150
+
- Should include a follow up explanation for conditionals, e.g:
151
+
- `.networkPolicies.ingressNginx.ingressOverride`- "When enabled a list of IPs must be set that should override the allowed ingress traffic."
152
+
- Should include a follow up explanation for requirements, e.g:
153
+
- `.velero`- "This requires that `.objectStorage` is configured, and will use the bucket or container set in `.objectStorage.buckets.velero`."
154
+
- Should include a reference to upstream documentation, and applicable mapping rules, wrapped in a note GFM alert, e.g.:
155
+
- `.fluentd.forwarder.buffer`- "See \[the upstream documentation for reference\]\(\<link\>\), set keys will converted from `camelCase` to `snake_case` as required."
156
+
- Should include a note about which cluster it is applicable, either in schema roots as a general case or in schema leafs as an exception, wrapped in a note GFM alert:
157
+
- For the root of larger schemas, e.g.:
158
+
- `.dex`- "Dex is installed in the service cluster, therefore this configuration mainly applies there."
159
+
- For the leaf of schemas, e.g.:
160
+
- `.dex.subdomain`- "Must be set for both service and workload clusters."
161
+
162
+
#### Defaults and examples
163
+
164
+
- Must be provided for all simple types, all `array` types, all compositional, conditional, and reusable `object` types.
165
+
- Must be valid input to the schema, with the exception of `set-me`.
166
+
- Should degrade gracefully, e.g. disabling optional components rather than enabling.
167
+
168
+
### Structural
169
+
170
+
These guidelines aim to help in creating schemas that are easier to read and write.
171
+
172
+
- All schemas must define a type.
173
+
- All schemas should define a single type to not cause type confusion.
174
+
- All schemas should use `additionalProperties: false` when no additional properties should be defined to make it easier to find misspelled keys.
175
+
176
+
#### Defines
177
+
178
+
Defines here refer to the use of `$defs` to define schemas, and `$ref`:s to use schemas.
179
+
This is usable in two situations:
180
+
181
+
1. To reuse common schemas
182
+
2. To reduce and flatten nested schemas
183
+
184
+
- Must be grouped, so documentation can be generated for it, e.g.:
185
+
- `.opensearch.$defs.roles`is not used on its own, but contains schemas that are reused.
186
+
- Must be flattened, so documentation can be generated for it, e.g.:
187
+
- `.opensearch.$defs.roles`contains schemas, but those schemas does not define subschemas instead they use `$refs` to other schemas under `.opensearch.$defs.roles`.
188
+
- Should be used whenever possible to reuse common schemas, e.g. to have common definitions for similar things like `.grafana.ops` and `.grafana.user`.
189
+
- Should be used whenever needed to reduce nested schemas, e.g. to reduce the generated names of a schema which is composed of the path to it within the schema.
190
+
- Should be defined under `$defs` local to where they are used, e.g.:
191
+
- `.opensearch.$defs.node`with subschemas reused by `.opensearch.master`, `.opensearch.data`, and `.opensearch.client` node.
192
+
- `.opensearch.$defs.roles`with subschemas reduced and flattened for `.opensearch.extraRoles`.
193
+
- Should **not** define titles, descriptions, defaults, or examples unless they are universally applicable.
194
+
- Else it will not be possible to override this metadata when referenced.
195
+
196
+
#### Imports
197
+
198
+
Imports here refers to the use of `$defs` to define schemas fetched from upstream sources.
199
+
The same guidelines for defines are applicable here as well.
200
+
201
+
- Must include a comment under the key `$comment` in the schema with the stanza "Schema imported from \[\<upstream-name\>\]\(\<upstream-link\>\).".
202
+
- Must include a reference to upstream documentation.
203
+
204
+
#### Compositions and Conditions
205
+
206
+
Compositions and conditions here refers to the use of `allOf`, `anyOf`, and `oneOf`, etc. to define schema compositions and conditions.
207
+
208
+
- Schemas with compositions and conditions must set defaults because otherwise they cannot be fully resolved.
209
+
- Schemas with compositions and conditions should set examples because otherwise they cannot be fully resolved.
210
+
- Should not use `if`-`then`-`else` as it has less support in tooling, and has a semantic that is generally different from other schema constructs.
0 commit comments