-
Notifications
You must be signed in to change notification settings - Fork 63
composite template deprecation #664
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ | |
# OPM allows for the generation of catalogs using different templates. | ||
# - basic: generates a basic catalog | ||
# - semver: generates a catalog with semver versioning | ||
# - composite: generates a catalog using a composite template | ||
|
||
PDW=$(shell pwd) | ||
OPERATOR_NAME=$(shell basename $(PDW)) | ||
|
@@ -47,9 +46,7 @@ fbc-onboarding: fbc-onboarding-deps clean | |
# | ||
# --- SEMVER TEMPLATE --- | ||
#catalog: semver | ||
# | ||
# --- COMPOSITE TEMPLATE --- | ||
catalog: composite | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With the removal of the composite as a default target for |
||
|
||
|
||
# basic target provides an example FBC generation from a `basic` template type. | ||
# this example takes a single file as input and generates a well-formed FBC operator contribution as an output | ||
|
@@ -70,13 +67,6 @@ semver: ${BINDIR}/opm clean | |
${BINDIR}/opm alpha render-template semver -o yaml ${OPERATOR_CATALOG_TEMPLATE_DIR}/$${version}.yaml > ${CATALOG_DIR}/$${version}/${OPERATOR_NAME}/catalog.yaml; \ | ||
done | ||
|
||
# composite target processes a composite template to generate the FBC contributions | ||
# `render-template composite` has `--validate` option enabled by default, | ||
# so no subsequent validation is required | ||
.PHONY: composite | ||
composite: ${BINDIR}/opm clean | ||
${BINDIR}/opm alpha render-template composite -f ${PDW}/catalogs.yaml -c ${PDW}/composite-config.yaml | ||
|
||
# | ||
# validate target illustrates FBC validation | ||
# all FBC must pass opm validation in order to be able to be used in a catalog | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,6 @@ | |
|
||
LOGGER = logging.getLogger("operator-cert") | ||
|
||
COMPOSITE_TEMPLATE_CATALOGS = "catalogs.yaml" | ||
COMPOSITE_TEMPLATE_CONTRIBUTIONS = "composite-config.yaml" | ||
CATALOG_TEMPLATES_DIR = "catalog-templates" | ||
|
||
|
||
|
@@ -96,7 +94,7 @@ def opm_cache(image: str) -> bytes: | |
bytes: An output of the opm command | ||
""" | ||
LOGGER.debug("Building cache for %s", image) | ||
output = run_command(["opm", "render", "-o", "yaml", "--migrate", image]) | ||
output = run_command(["opm", "render", "-o", "yaml", image]) | ||
return output.stdout | ||
|
||
|
||
|
@@ -205,81 +203,6 @@ def generate_and_save_base_templates( | |
LOGGER.info("Template for %s saved to %s", version, template_path) | ||
|
||
|
||
def generate_composite_templates( | ||
operator: Operator, catalog_versions: List[str] | ||
) -> Tuple[Dict[str, Any], Dict[str, Any]]: | ||
""" | ||
Generate a composite template for given operator and all supported versions | ||
|
||
Args: | ||
operator (Operator): A operator object | ||
catalog_versions (List[str]): List of supported catalog versions | ||
|
||
Returns: | ||
Tuple[Dict, Dict]: catalog and contributions templates | ||
""" | ||
catalogs = [ | ||
{ | ||
"name": f"v{version}", | ||
"destination": { | ||
"workingDir": f"../../catalogs/v{version}", | ||
}, | ||
"builders": ["olm.builder.basic", "olm.builder.semver"], | ||
} | ||
for version in catalog_versions | ||
] | ||
composite_catalogs = { | ||
"schema": "olm.composite.catalogs", | ||
"catalogs": catalogs, | ||
} | ||
|
||
components = [ | ||
{ | ||
"name": f"v{version}", | ||
"destination": { | ||
"path": operator.operator_name, | ||
}, | ||
"strategy": { | ||
"name": "basic", | ||
"template": { | ||
"schema": "olm.builder.basic", | ||
"config": { | ||
"input": f"{CATALOG_TEMPLATES_DIR}/v{version}.yaml", | ||
"output": "catalog.yaml", | ||
}, | ||
}, | ||
}, | ||
} | ||
for version in catalog_versions | ||
] | ||
|
||
contributions = {"schema": "olm.composite", "components": components} | ||
return composite_catalogs, contributions | ||
|
||
|
||
def generate_and_save_composite_templates( | ||
operator: Operator, catalog_versions: List[str] | ||
) -> None: | ||
""" | ||
Generate and save composite templates for given operator and all supported versions | ||
|
||
Args: | ||
operator (Operator): A operator object | ||
catalog_versions (List[str]): List of supported catalog versions | ||
""" | ||
catalog, contributions = generate_composite_templates(operator, catalog_versions) | ||
with open( | ||
os.path.join(operator.root, COMPOSITE_TEMPLATE_CATALOGS), "w", encoding="utf8" | ||
) as f: | ||
yaml.safe_dump(catalog, f, explicit_start=True) | ||
with open( | ||
os.path.join(operator.root, COMPOSITE_TEMPLATE_CONTRIBUTIONS), | ||
"w", | ||
encoding="utf8", | ||
) as f: | ||
yaml.safe_dump(contributions, f, explicit_start=True) | ||
|
||
|
||
def update_operator_config(operator: Operator) -> None: | ||
""" | ||
Switch operator config to FBC | ||
|
@@ -299,7 +222,7 @@ def update_operator_config(operator: Operator) -> None: | |
yaml.safe_dump(config, f, explicit_start=True) | ||
|
||
|
||
def render_fbc_from_template(operator: Operator) -> None: | ||
def render_fbc_from_template(operator: Operator, version: str) -> None: | ||
""" | ||
Render catalog from templates | ||
|
||
|
@@ -311,11 +234,12 @@ def render_fbc_from_template(operator: Operator) -> None: | |
"opm", | ||
"alpha", | ||
"render-template", | ||
"composite", | ||
"-f", | ||
COMPOSITE_TEMPLATE_CATALOGS, | ||
"-c", | ||
COMPOSITE_TEMPLATE_CONTRIBUTIONS, | ||
"basic", | ||
"-o", | ||
"yaml", | ||
os.path.join(operator.root, CATALOG_TEMPLATES_DIR, f"v{version}.yaml"), | ||
">", | ||
f"../../catalogs/v{version}/catalog.yaml" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think you're missing an operator name in the output path. Based on the design it should be |
||
], | ||
cwd=operator.root, | ||
) | ||
|
@@ -356,11 +280,8 @@ def onboard_operator_to_fbc( | |
version, operator_name, cache_dir, template_dir | ||
) | ||
|
||
LOGGER.info("Generating composite templates") | ||
generate_and_save_composite_templates(operator, supported_versions) | ||
|
||
LOGGER.info("Rendering FBC from templates") | ||
render_fbc_from_template(operator) | ||
LOGGER.info("Rendering FBC from templates") | ||
render_fbc_from_template(operator, version) | ||
|
||
LOGGER.info("Updating operator config") | ||
update_operator_config(operator) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the specific call-out here. I don't know if you're the right person @Allda. I got distracted from working on this a couple of times today, so I put the note in here so I wouldn't lose it. 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have a tracker for it and we will consolidate the documentation and the tooling (makefile) to provide a single way of interacting with catalogs and onboardings.
Could you please remove the comment so we can potentially merge it without the notes?