Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/users/fbc_autorelease.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ catalog_templates:
replaces: aqua.0.0.1
- template_name: semver.yaml
channels: [Fast, Stable]
defaultChannel: Stable
```
The example above shows a release configuration where operator bundle is going to be
released to the `my-channel` channel in the `basic.yaml` catalog template and to the
Expand All @@ -54,6 +55,9 @@ released to the `my-channel` channel in the `basic.yaml` catalog template and to
The `replaces` field is optional and it specifies the bundle that the new bundle
replaces in the update graph.

The `defaultChannel` field is optional and it specifies which channel should be
the default for installing an operator.

### File structure
The schema of the file is available here: [release-config.yaml schema](https://github.com/redhat-openshift-ecosystem/operator-pipelines/blob/main/operatorcert/schemas/release-config-schema.json).
The schema is validated automatically in the pipeline and the PR will fail with explanations if the file is not valid.
Expand All @@ -65,6 +69,7 @@ Here is a summary of the file structure:
* `template_name` - the name of the catalog template file in the `catalog-templates` directory.
* `channels` - a list of channels where the bundle should be released.
* In case of using `SemVer` a user can pick from allowed values: `Fast`, `Stable` and `Candidate`.
* `defaultChannel` - the default channel for the operator package (**Optional**). If not specified, defaults to the first channel listed in the channels list.
* `replaces` - the bundle that the new bundle replaces in the update graph. (**Optional**, only for the basic templates)
* `skips` - a list of bundles that should be skipped in the update graph. (**Optional**, only for the basic templates)
* `skipRange` - a range of bundles that should be skipped in the update graph. (**Optional**, only for the basic templates)
9 changes: 8 additions & 1 deletion operatorcert/entrypoints/add_bundle_to_fbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ def create(
package = {
"schema": "olm.package",
"name": self.operator.operator_name,
"defaultChannel": channels[0]["name"],
"defaultChannel": release_config.get("defaultChannel", channels[0]["name"]),
}
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
bundle_obj = {"schema": "olm.bundle", "image": bundle_pullspec}

Expand Down Expand Up @@ -466,6 +466,13 @@ def release_bundle_to_fbc(args: argparse.Namespace, bundle: Bundle) -> None:
for release_config_template in bundle.release_config["catalog_templates"]:
template_name = release_config_template["template_name"]
template_mapping = get_catalog_mapping(bundle.operator.config, template_name)
default_channel = release_config_template.get("defaultChannel")
template_channels = release_config_template["channels"]
if default_channel and default_channel not in template_channels:
raise ValueError(
f"defaultChannel '{default_channel}' not found in '{template_name}'. "
f"Available channels: {template_channels}"
)
if not template_mapping:
raise ValueError(
f"Template mapping not found for '{template_name}' in ci.yaml."
Expand Down
4 changes: 4 additions & 0 deletions operatorcert/schemas/release-config-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
"minItems": 1,
"uniqueItems": true
},
"defaultChannel": {
"description": "default channel for this template (optional, defaults to first channel)",
"type": "string"
},
"replaces": {
"description": "operator version which this PR replaces (optional)",
"type": "string"
Expand Down
27 changes: 24 additions & 3 deletions tests/entrypoints/test_add_bundle_to_fbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,9 @@ def test_release_bundle_to_fbc(
add_bundle_to_fbc.release_bundle_to_fbc(args, bundle)

bundle.release_config = {
"catalog_templates": [{"template_name": "fake-template.yaml"}]
"catalog_templates": [
{"template_name": "fake-template.yaml", "channels": ["alpha"]},
]
}
mock_catalog_mapping.return_value = None
with pytest.raises(ValueError):
Expand All @@ -434,8 +436,27 @@ def test_release_bundle_to_fbc(

bundle.release_config = {
"catalog_templates": [
{"template_name": "fake-basic.yaml"},
{"template_name": "fake-semver.yaml"},
{
"template_name": "fake-template.yaml",
"channels": ["alpha"],
"defaultChannel": "stable",
},
]
}
mock_catalog_mapping.side_effect = [
{
"template_name": "fake-template.yaml",
"catalog_names": ["v4.12-fake"],
"type": "olm.template.basic",
}
]
with pytest.raises(ValueError, match="defaultChannel 'stable' not found"):
add_bundle_to_fbc.release_bundle_to_fbc(args, bundle)

bundle.release_config = {
"catalog_templates": [
{"template_name": "fake-basic.yaml", "channels": ["alpha"]},
{"template_name": "fake-semver.yaml", "channels": ["Fast", "Candidate"]},
]
}
mock_catalog_mapping.side_effect = [
Expand Down
Loading