Skip to content

Commit d802012

Browse files
grokspawnAllda
authored andcommitted
composite template deprecation
Signed-off-by: Jordan Keister <[email protected]>
1 parent 59b8f11 commit d802012

File tree

4 files changed

+17
-113
lines changed

4 files changed

+17
-113
lines changed

docs/users/fbc_onboarding.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,17 @@ $ tree operators/aqua
5656
operators/aqua
5757
├── 0.0.1
5858
...
59-
├── catalogs.yaml
6059
├── catalog-templates
6160
│   ├── v4.12.yaml
6261
│   ├── v4.13.yaml
6362
│   ├── v4.14.yaml
6463
│   ├── v4.15.yaml
6564
│   └── v4.16.yaml
6665
├── ci.yaml
67-
└── composite-config.yaml
6866
```
6967
... and File-based catalog in `catalogs` directory
7068
```bash
71-
$ tree catalogs
69+
$ tree (repository root)/catalogs
7270
catalogs
7371
├── v4.12
7472
│   └── aqua
@@ -92,20 +90,19 @@ catalogs
9290
Artifacts generated in the previous step need to be added to a git and submitted via pull request. The operator pipeline validates the content of the catalogs and releases changes into ocp catalogs.
9391

9492
```bash
95-
$ git add operators/aqua/{catalog-templates,catalogs.yaml,composite-config.yaml,ci.yaml}
93+
$ git add operators/aqua/{catalog-templates,ci.yaml}
9694

97-
$ git add
9895
$ git add catalogs/{v4.12,v4.13,v4.14,v4.15,v4.16}/aqua
9996

10097
$ git commit --signoff -m "Add FBC resources for aqua operator"
10198
```
10299

103100
## Generating catalogs from templates
104-
Catalog templates are used to simplify a view of a catalog and allow easier manipulation of catalogs. The automated conversion pre-generates a basic + composite template that can be turned into full FBC using the following command:
101+
Catalog templates are used to simplify a view of a catalog and allow easier manipulation of catalogs. The automated conversion pre-generates a basic template that can be turned into full FBC using the following command:
105102

106103
```bash
107104
make catalog
108105
```
109106

110107
Of course, you can choose any type of template that you prefer by modifying the Makefile target.
111-
More information about catalog templates can be found [here](https://olm.operatorframework.io/docs/reference/catalog-templates/)
108+
More information about catalog templates can be found [here](https://olm.operatorframework.io/docs/reference/catalog-templates/)

docs/users/fbc_workflow.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,10 @@ template the operator will be using.
2424
2525
* Basic template
2626
* SemVer template
27-
* Composite template
2827
2928
More information about each template can be found at [opm doc](https://olm.operatorframework.io/docs/reference/catalog-templates/).
3029
31-
The recommended template from the maintainability point of view is `SemVer` or `Composite` with
32-
`SemVer`integration.
30+
The recommended template from the maintainability point of view is `SemVer`.
3331

3432
## Generate catalogs using templates
3533
To generate a final catalog for an operator a user needs to execute different `opm`
@@ -51,10 +49,8 @@ The right place for the Makefile is in the operator's root directory
5149
├── 0.0.1
5250
│   ├── manifests
5351
│   └── metadata
54-
├── catalogs.yaml
5552
├── catalog-templates
5653
├── ci.yaml
57-
├── composite-config.yaml
5854
└── Makefile
5955

6056
```
@@ -65,7 +61,7 @@ can be submitted as a PR in Github and once the PR is processed changes will be
6561
OCP index.
6662
6763
```bash
68-
$ tree catalogs
64+
$ tree (repository-root)/catalogs
6965
catalogs
7066
├── v4.12
7167
│   └── aqua

fbc/Makefile

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
# OPM allows for the generation of catalogs using different templates.
1010
# - basic: generates a basic catalog
1111
# - semver: generates a catalog with semver versioning
12-
# - composite: generates a catalog using a composite template
1312

1413
PDW=$(shell pwd)
1514
OPERATOR_NAME=$(shell basename $(PDW))
@@ -49,9 +48,7 @@ fbc-onboarding: fbc-onboarding-deps ${BINDIR}/opm clean
4948
#
5049
# --- SEMVER TEMPLATE ---
5150
#catalog: semver
52-
#
53-
# --- COMPOSITE TEMPLATE ---
54-
catalog: composite
51+
5552

5653
# basic target provides an example FBC generation from a `basic` template type.
5754
# this example takes a single file as input and generates a well-formed FBC operator contribution as an output
@@ -72,13 +69,6 @@ semver: ${BINDIR}/opm clean
7269
${BINDIR}/opm alpha render-template semver -o yaml ${OPERATOR_CATALOG_TEMPLATE_DIR}/$${version}.yaml > ${CATALOG_DIR}/$${version}/${OPERATOR_NAME}/catalog.yaml; \
7370
done
7471

75-
# composite target processes a composite template to generate the FBC contributions
76-
# `render-template composite` has `--validate` option enabled by default,
77-
# so no subsequent validation is required
78-
.PHONY: composite
79-
composite: ${BINDIR}/opm clean
80-
${BINDIR}/opm alpha render-template composite -f ${PDW}/catalogs.yaml -c ${PDW}/composite-config.yaml
81-
8272
#
8373
# validate target illustrates FBC validation
8474
# all FBC must pass opm validation in order to be able to be used in a catalog

operator-pipeline-images/operatorcert/entrypoints/fbc_onboarding.py

Lines changed: 10 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
LOGGER = logging.getLogger("operator-cert")
1616

17-
COMPOSITE_TEMPLATE_CATALOGS = "catalogs.yaml"
18-
COMPOSITE_TEMPLATE_CONTRIBUTIONS = "composite-config.yaml"
1917
CATALOG_TEMPLATES_DIR = "catalog-templates"
2018

2119

@@ -96,7 +94,7 @@ def opm_cache(image: str) -> bytes:
9694
bytes: An output of the opm command
9795
"""
9896
LOGGER.debug("Building cache for %s", image)
99-
output = run_command(["opm", "render", "-o", "yaml", "--migrate", image])
97+
output = run_command(["opm", "render", "-o", "yaml", image])
10098
return output.stdout
10199

102100

@@ -205,81 +203,6 @@ def generate_and_save_base_templates(
205203
LOGGER.info("Template for %s saved to %s", version, template_path)
206204

207205

208-
def generate_composite_templates(
209-
operator: Operator, catalog_versions: List[str]
210-
) -> Tuple[Dict[str, Any], Dict[str, Any]]:
211-
"""
212-
Generate a composite template for given operator and all supported versions
213-
214-
Args:
215-
operator (Operator): A operator object
216-
catalog_versions (List[str]): List of supported catalog versions
217-
218-
Returns:
219-
Tuple[Dict, Dict]: catalog and contributions templates
220-
"""
221-
catalogs = [
222-
{
223-
"name": f"v{version}",
224-
"destination": {
225-
"workingDir": f"../../catalogs/v{version}",
226-
},
227-
"builders": ["olm.builder.basic", "olm.builder.semver"],
228-
}
229-
for version in catalog_versions
230-
]
231-
composite_catalogs = {
232-
"schema": "olm.composite.catalogs",
233-
"catalogs": catalogs,
234-
}
235-
236-
components = [
237-
{
238-
"name": f"v{version}",
239-
"destination": {
240-
"path": operator.operator_name,
241-
},
242-
"strategy": {
243-
"name": "basic",
244-
"template": {
245-
"schema": "olm.builder.basic",
246-
"config": {
247-
"input": f"{CATALOG_TEMPLATES_DIR}/v{version}.yaml",
248-
"output": "catalog.yaml",
249-
},
250-
},
251-
},
252-
}
253-
for version in catalog_versions
254-
]
255-
256-
contributions = {"schema": "olm.composite", "components": components}
257-
return composite_catalogs, contributions
258-
259-
260-
def generate_and_save_composite_templates(
261-
operator: Operator, catalog_versions: List[str]
262-
) -> None:
263-
"""
264-
Generate and save composite templates for given operator and all supported versions
265-
266-
Args:
267-
operator (Operator): A operator object
268-
catalog_versions (List[str]): List of supported catalog versions
269-
"""
270-
catalog, contributions = generate_composite_templates(operator, catalog_versions)
271-
with open(
272-
os.path.join(operator.root, COMPOSITE_TEMPLATE_CATALOGS), "w", encoding="utf8"
273-
) as f:
274-
yaml.safe_dump(catalog, f, explicit_start=True)
275-
with open(
276-
os.path.join(operator.root, COMPOSITE_TEMPLATE_CONTRIBUTIONS),
277-
"w",
278-
encoding="utf8",
279-
) as f:
280-
yaml.safe_dump(contributions, f, explicit_start=True)
281-
282-
283206
def update_operator_config(operator: Operator) -> None:
284207
"""
285208
Switch operator config to FBC
@@ -299,7 +222,7 @@ def update_operator_config(operator: Operator) -> None:
299222
yaml.safe_dump(config, f, explicit_start=True)
300223

301224

302-
def render_fbc_from_template(operator: Operator) -> None:
225+
def render_fbc_from_template(operator: Operator, version: str) -> None:
303226
"""
304227
Render catalog from templates
305228
@@ -311,11 +234,12 @@ def render_fbc_from_template(operator: Operator) -> None:
311234
"opm",
312235
"alpha",
313236
"render-template",
314-
"composite",
315-
"-f",
316-
COMPOSITE_TEMPLATE_CATALOGS,
317-
"-c",
318-
COMPOSITE_TEMPLATE_CONTRIBUTIONS,
237+
"basic",
238+
"-o",
239+
"yaml",
240+
os.path.join(operator.root, CATALOG_TEMPLATES_DIR, f"v{version}.yaml"),
241+
">",
242+
f"../../catalogs/v{version}/catalog.yaml"
319243
],
320244
cwd=operator.root,
321245
)
@@ -356,11 +280,8 @@ def onboard_operator_to_fbc(
356280
version, operator_name, cache_dir, template_dir
357281
)
358282

359-
LOGGER.info("Generating composite templates")
360-
generate_and_save_composite_templates(operator, supported_versions)
361-
362-
LOGGER.info("Rendering FBC from templates")
363-
render_fbc_from_template(operator)
283+
LOGGER.info("Rendering FBC from templates")
284+
render_fbc_from_template(operator, version)
364285

365286
LOGGER.info("Updating operator config")
366287
update_operator_config(operator)

0 commit comments

Comments
 (0)