Skip to content

Commit 95713a2

Browse files
committed
update the formulary to reflect the new schema for basic catalog templates
Signed-off-by: Jordan Keister <[email protected]>
1 parent 372a697 commit 95713a2

File tree

1 file changed

+204
-66
lines changed

1 file changed

+204
-66
lines changed

content/en/docs/advanced-tasks/catalog-update-formulary.md

Lines changed: 204 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,12 @@ weight: 5
88
[File-based-catalogs][file-based-catalog-spec] (FBC) and [catalog templates][templates-doc] (templates) provide operator authors with standardized schemas to express operator upgrade graphs. However, without explicit tooling users require clear examples of how to achieve routine goals. This document is an attempt to establish a formulary of common operations, specifically with the intention of making these pieces automatable. This is in no way an exhaustive list.
99

1010
## Conventions
11-
Formulae will be identified as pertaining to either FBC or [semver catalog template][semver-template-doc] (semver template). Since FBC and the [basic catalog template][basic-template-doc] (basic template) both represent the upgrade graph in the set of `olm.channel` objects, instructions for FBC will also be applicable to the `basic template`. Manipulations of `olm.bundle` attributes are limited to FBC representation only.
11+
Formulae will be identified as FBC, [basic catalog template][basic-template-doc] (basic template), or [semver catalog template][semver-template-doc] (semver template).
1212
Schema manipulations will be modeled using YAML and [yq][yq]. Wherever possible, example input will be limited to the relevant object hierarchies. Truncation is indicated by elipses (...) before and after the text.
1313

14-
1514
## Examples
1615
For brevity, all formulae will refer to the same example, for semver template and FBC. For convenience, all semver bundle image pullspecs will express versions which match the bundle version (instead of SHAs).
1716

18-
### semver template example
19-
Formulae presume the following content is saved to the file `semver.yaml`
20-
```yaml
21-
schema: olm.semver
22-
generateMajorChannels: false
23-
generateMinorChannels: true
24-
candidate:
25-
bundles:
26-
- image: quay.io/organization/testoperator:v1.0.0
27-
- image: quay.io/organization/testoperator:v1.0.1
28-
- image: quay.io/organization/testoperator:v1.1.0
29-
fast:
30-
bundles:
31-
- image: quay.io/organization/testoperator:v1.0.1
32-
- image: quay.io/organization/testoperator:v1.1.0
33-
stable:
34-
bundles:
35-
- image: quay.io/organization/testoperator:v1.0.1
36-
```
37-
38-
3917
### FBC example
4018
Formulae presume the following content is saved to the file `fbc.yaml`
4119

@@ -84,28 +62,54 @@ schema: olm.channel
8462
```
8563
8664
87-
## Formulae
88-
89-
### Adding a new bundle to an existing channel
90-
#### semver
91-
Add a new `testoperatorv1.1.1` bundle pullspec to the `Candidate` channel archetype
92-
93-
```bash
94-
yq eval '.candidate.bundles += [{"image" : "quay.io/organization/testoperator:v1.1.1"}]' semver.yaml
65+
### basic template example
66+
Formulae presume the following context is saved to the file `basic.yaml`
67+
```yaml
68+
schema: olm.template.basic
69+
entries:
70+
- schema: olm.package
71+
name: testoperator
72+
defaultChannel: stable
73+
- schema: olm.channel
74+
package: testoperator
75+
name: stable
76+
entries:
77+
- name: testoperator.v0.1.0
78+
- name: testoperator.v0.2.0
79+
replaces: testoperator.v0.1.0
80+
- schema: olm.bundle
81+
image: quay.io/organization/testoperator:v0.1.0
82+
- schema: olm.bundle
83+
image: quay.io/organization/testoperator:v0.2.0
9584
```
9685

97-
produces updated `Candidate` archetype contents:
98-
86+
### semver template example
87+
Formulae presume the following content is saved to the file `semver.yaml`
9988
```yaml
100-
...
89+
schema: olm.semver
90+
generateMajorChannels: false
91+
generateMinorChannels: true
10192
candidate:
10293
bundles:
10394
- image: quay.io/organization/testoperator:v1.0.0
10495
- image: quay.io/organization/testoperator:v1.0.1
10596
- image: quay.io/organization/testoperator:v1.1.0
106-
- image: quay.io/organization/testoperator:v1.1.1
107-
...
108-
```
97+
fast:
98+
bundles:
99+
- image: quay.io/organization/testoperator:v1.0.1
100+
- image: quay.io/organization/testoperator:v1.1.0
101+
stable:
102+
bundles:
103+
- image: quay.io/organization/testoperator:v1.0.1
104+
```
105+
106+
107+
108+
109+
110+
## Formulae
111+
112+
### Adding a new bundle to an existing channel
109113

110114
#### FBC
111115
Add a new `testoperator.v1.1.1` edge to an existing `candidate-v1.1` channel
@@ -129,19 +133,65 @@ package: testoperator
129133
schema: olm.channel
130134
...
131135
```
132-
{{% alert title="Warning" color="warning" %}}
133-
This example illustrates how it is possible to inadvertently create multiple channel heads
134-
{{% /alert %}}
135-
`opm validate` result for this output would be:
136+
> [!CAUTION]
137+
> This example illustrates how it is possible to inadvertently create multiple channel heads
138+
>
139+
> `opm validate` result for this output would be:
140+
>
141+
> ```bash
142+
> FATA[0000] invalid index:
143+
> └── invalid package "testoperator":
144+
> └── invalid channel "candidate-v1.1":
145+
> ├── multiple channel heads found in graph: testoperator.v1.1.0, testoperator.v1.1.1
146+
> ```
147+
148+
#### basic
149+
Add a new `testoperator.v0.2.1` bundle pullspec to the existing `stable` channel
150+
151+
```bash
152+
yq eval 'select(.schema == "olm.template.basic").entries[] |= select(.schema == "olm.channel" and .name == "stable").entries += [{"name" : "testoperator.v0.2.1", "replaces": "testoperator.v0.2.0"}]' basic.yaml
153+
```
154+
155+
produces updated `stable` channel:
156+
157+
```yaml
158+
...
159+
- schema: olm.channel
160+
package: testoperator
161+
name: stable
162+
entries:
163+
- name: testoperator.v0.1.0
164+
- name: testoperator.v0.2.0
165+
replaces: testoperator.v0.1.0
166+
- name: testoperator.v0.2.1
167+
replaces: testoperator.v0.2.0
168+
...
169+
```
170+
171+
#### semver
172+
Add a new `testoperator.v1.1.1` bundle pullspec to the `Candidate` channel archetype
136173

137174
```bash
138-
FATA[0000] invalid index:
139-
└── invalid package "testoperator":
140-
└── invalid channel "candidate-v1.1":
141-
├── multiple channel heads found in graph: testoperator.v1.1.0, testoperator.v1.1.1
175+
yq eval '.candidate.bundles += [{"image" : "quay.io/organization/testoperator:v1.1.1"}]' semver.yaml
176+
```
177+
178+
produces updated `Candidate` archetype contents:
179+
180+
```yaml
181+
...
182+
candidate:
183+
bundles:
184+
- image: quay.io/organization/testoperator:v1.0.0
185+
- image: quay.io/organization/testoperator:v1.0.1
186+
- image: quay.io/organization/testoperator:v1.1.0
187+
- image: quay.io/organization/testoperator:v1.1.1
188+
...
142189
```
143190

191+
144192
### Adding a new 'replaces' link between two existing bundles
193+
> [!NOTE]
194+
> This operation is not possible for the semver template, which exclusively leverages semver ordering to generate an opinonated upgrade graph.
145195

146196
#### FBC
147197
Adding a new `testoperator.v1.1.1` bundle version edge with a replaces link to its predecessor `testoperator.v1.1.0` version which already exists in the channel.
@@ -166,8 +216,33 @@ schema: olm.channel
166216
...
167217
```
168218

219+
#### basic
220+
Adding a new `testoperator.v0.1.1` bundle version edge with a replaces link to its predecessor `testoperator.v0.1.0` version which already exists in the channel.
221+
222+
```bash
223+
yq eval 'select(.schema == "olm.template.basic").entries[] |= select(.schema == "olm.channel" and .name == "stable").entries += [{"name" : "testoperator:v0.1.1", "replaces": "testoperator:v0.1.0"}]' basic.yaml
224+
```
225+
226+
produces updated `stable` channel:
227+
228+
```yaml
229+
...
230+
- schema: olm.channel
231+
package: testoperator
232+
name: stable
233+
entries:
234+
- name: testoperator.v0.1.0
235+
- name: testoperator.v0.2.0
236+
replaces: testoperator.v0.1.0
237+
- name: testoperator:v0.1.1
238+
replaces: testoperator:v0.1.0
239+
...
240+
```
241+
169242

170243
### Removing a specific bundle version
244+
> [!NOTE]
245+
> This operation is not possible for the semver template, which exclusively leverages semver ordering to generate an opinonated upgrade graph.
171246

172247
#### FBC
173248
Remove the upgrade edge from the example `candidate-v1.1` channel which refers to bundle version `testoperator.v1.1.0`.
@@ -190,34 +265,27 @@ schema: olm.channel
190265
Please note that removing the only edge for a channel as in this example will yield an explicitly empty array. This will produce an error in `opm validate`.
191266
{{% /alert %}}
192267

193-
### Substituting a bundle version in the upgrade graph
194-
195-
#### semver
196-
For all channels, replace instances of `quay.io/organization/testoperator:v1.1.0` with `quay.io/organization/testoperator:v1.1.0-CVE`
268+
#### basic
269+
Remove the upgrade edge from the example `stable` channel which refers to bundle version `testoperator.v0.2.0`.
197270

198271
```bash
199-
yq '(..| select(has("image") and .image == "quay.io/organization/testoperator:v1.1.0")).image = "quay.io/organization/testoperator:v1.1.0-cve"' semver.yaml
272+
yq eval 'select(.schema == "olm.template.basic").entries[] |= del(select(.schema == "olm.channel" and .name == "stable").entries[]| select(.name == "testoperator.v0.2.0"))' basic.yaml
200273
```
201-
produces updated template:
274+
275+
produces updated `stable` channel:
202276

203277
```yaml
204-
schema: olm.semver
205-
generatemajorchannels: false
206-
generateminorchannels: true
207-
candidate:
208-
bundles:
209-
- image: quay.io/organization/testoperator:v1.0.0
210-
- image: quay.io/organization/testoperator:v1.0.1
211-
- image: quay.io/organization/testoperator:v1.1.0-cve
212-
fast:
213-
bundles:
214-
- image: quay.io/organization/testoperator:v1.0.1
215-
- image: quay.io/organization/testoperator:v1.1.0-cve
216-
stable:
217-
bundles:
218-
- image: quay.io/organization/testoperator:v1.0.1
278+
...
279+
- schema: olm.channel
280+
package: testoperator
281+
name: stable
282+
entries:
283+
- name: testoperator.v0.1.0
284+
...
219285
```
220286

287+
### Substituting a bundle version in the upgrade graph
288+
221289
#### FBC
222290
For all graph edges, replaces instances of `testoperator.v1.1.0` with a different bundle version `testoperator.v1.1.0-CVE`
223291

@@ -271,7 +339,59 @@ package: testoperator
271339
schema: olm.channel
272340
```
273341

342+
#### basic
343+
For all channels, replace instances of `testoperator:v0.1.0` with `testoperator:v0.1.0-CVE`
344+
345+
```bash
346+
yq '(..| select(. == "testoperator.v0.1.0")) |="testoperator.v0.1.0-CVE"' basic.yaml
347+
```
348+
349+
produces updated channels:
350+
351+
```yaml
352+
...
353+
- schema: olm.channel
354+
package: testoperator
355+
name: stable
356+
entries:
357+
- name: testoperator.v0.1.0-CVE
358+
- name: testoperator.v0.2.0
359+
replaces: testoperator.v0.1.0-CVE
360+
...
361+
```
362+
363+
#### semver
364+
For all channels, replace instances of `quay.io/organization/testoperator:v1.1.0` with `quay.io/organization/testoperator:v1.1.0-CVE`
365+
366+
```bash
367+
yq '(..| select(has("image") and .image == "quay.io/organization/testoperator:v1.1.0")).image = "quay.io/organization/testoperator:v1.1.0-cve"' semver.yaml
368+
```
369+
produces updated template:
370+
371+
```yaml
372+
schema: olm.semver
373+
generatemajorchannels: false
374+
generateminorchannels: true
375+
candidate:
376+
bundles:
377+
- image: quay.io/organization/testoperator:v1.0.0
378+
- image: quay.io/organization/testoperator:v1.0.1
379+
- image: quay.io/organization/testoperator:v1.1.0-cve
380+
fast:
381+
bundles:
382+
- image: quay.io/organization/testoperator:v1.0.1
383+
- image: quay.io/organization/testoperator:v1.1.0-cve
384+
stable:
385+
bundles:
386+
- image: quay.io/organization/testoperator:v1.0.1
387+
```
388+
389+
390+
274391
### Introducing a new replacement relationship in the upgrade graph
392+
> [!NOTE]
393+
> This operation is not possible for the semver template, which exclusively leverages semver ordering to generate an opinonated upgrade graph.
394+
275395
#### FBC
276396
Substitute an existing 'replaces' link target for `testoperator.v1.1.0` with a different bundle version `testoperator.v1.0.0`.
277397

@@ -292,6 +412,24 @@ schema: olm.channel
292412
...
293413
```
294414

415+
#### basic
416+
Substitute an existing 'replaces' link target for `testoperator.v0.2.0` with a different bundle version `testoperator.v0.1.5`.
417+
418+
```bash
419+
yq eval '.entries[] |= select(.schema == "olm.channel" and .name == "stable").entries |= [{"name" : "testoperator:v0.2.0", "replaces": "testoperator:v0.1.5"}]' basic.yaml
420+
```
421+
produces updated `stable` channel:
422+
423+
```yaml
424+
...
425+
- schema: olm.channel
426+
package: testoperator
427+
name: stable
428+
entries:
429+
- name: testoperator:v0.2.0
430+
replaces: testoperator:v0.1.5
431+
...
432+
```
295433

296434

297435

0 commit comments

Comments
 (0)