Skip to content

Commit 1ea9417

Browse files
committed
Use container in fbc-onboarding target
To minimize a need of installing dependencies the fbc-onboarding target in the Makefile uses podman to run a container instead of running Python scripts on the system. JIRA: ISV-5229 Signed-off-by: Ales Raszka <[email protected]>
1 parent e5f3804 commit 1ea9417

File tree

5 files changed

+47
-35
lines changed

5 files changed

+47
-35
lines changed

docs/users/fbc_onboarding.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ We want to help with this process and we prepared a tooling that helps with this
2121
As a prerequisite to this process, you need to download a `Makefile` that
2222
automates the migration process.
2323

24+
An initial system requirement is to have following dependencies installed:
25+
- [podman](https://podman.io/docs/installation)
26+
- [make](https://www.gnu.org/software/make/)
27+
2428
```bash
2529
# Go to the operator repo directory (certified-operators, marketplace-operators, community-operators-prod)
2630
cd <operator-repo>/operators/<operator-name>
@@ -33,6 +37,8 @@ a local cache is generated during a run.
3337
> **Note**
3438
> A user executing the conversion script needs to be authenticated to registries used by OLM catalog.
3539
> Use `podman login` to log in into all registries.
40+
> A conversion script assumes you have `$(XDG_RUNTIME_DIR)/containers/auth.json` or `~/.docker/config.json` present
41+
> with valid registry tokens.
3642
3743
To convert existing operator to `FBC` format you need to execute following command:
3844

@@ -109,7 +115,7 @@ $ git commit --signoff -m "Add FBC resources for aqua operator"
109115
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:
110116

111117
```bash
112-
make catalog
118+
make catalogs
113119
```
114120

115121
Of course, you can choose any type of template that you prefer by modifying the Makefile target.

docs/users/fbc_workflow.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The right place for the Makefile is in the operator's root directory
5151

5252
```
5353
54-
You can modify the Makefile based on your needs and use it to generate catalogs by running `make catalog`.
54+
You can modify the Makefile based on your needs and use it to generate catalogs by running `make catalogs`.
5555
5656
> [!IMPORTANT]
5757
> In case an operator isn't shipped to all OCP catalog versions manually update `OCP_VERSIONS`
@@ -167,5 +167,5 @@ of operator releases. This allows any post-release modification of the catalogs.
167167
If you want to change the order of updates, remove an invalid bundle, or do any other modification
168168
you are free to do that.
169169

170-
After updating catalog templates don't forget to run `make catalog` to generate a catalog
170+
After updating catalog templates don't forget to run `make catalogs` to generate a catalog
171171
from templates and submit the resulting catalog using PR workflow.

fbc/Makefile

Lines changed: 37 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -23,33 +23,54 @@ CATALOG_DIR=${TOPDIR}/catalogs
2323
# A place to store the operator catalog templates
2424
OPERATOR_CATALOG_TEMPLATE_DIR = ${PDW}/catalog-templates
2525

26+
# The operator pipeline image to use for the fbc-onboarding target
27+
OPERATOR_PIPELINE_IMAGE ?= quay.io/redhat-isv/operator-pipelines-images:released
28+
29+
# Define the paths for both auth files
30+
DOCKER_CONFIG := $(HOME)/.docker/config.json
31+
CONTAINERS_AUTH := $(XDG_RUNTIME_DIR)/containers/auth.json
32+
2633
# A list of OCP versions to generate catalogs for
2734
# This list can be customized to include the versions that are relevant to the operator
2835
# DO NOT change this line (except for the versions) if you want to take advantage
2936
# of the automated catalog promotion
30-
OCP_VERSIONS=$(shell echo "v4.12 v4.13 v4.14 v4.15 v4.16" )
37+
OCP_VERSIONS=$(shell echo "v4.12 v4.13 v4.14 v4.15 v4.16 v4.17" )
3138

3239

33-
#
3440
.PHONY: fbc-onboarding
35-
fbc-onboarding: fbc-onboarding-deps ${BINDIR}/opm clean
36-
fbc-onboarding \
37-
--repo-root $(TOPDIR) \
38-
--operator-name $(OPERATOR_NAME) \
39-
--cache-dir $(TOPDIR)/.catalog_cache \
40-
--verbose
41-
42-
.PHONY: catalog
41+
fbc-onboarding: clean
42+
@if [ -f $(DOCKER_CONFIG) ]; then \
43+
echo "Using Docker config file: $(DOCKER_CONFIG)"; \
44+
CONFIG_VOLUME="-v $(DOCKER_CONFIG):/root/.docker/config.json"; \
45+
elif [ -f $(CONTAINERS_AUTH) ]; then \
46+
echo "Using containers auth file: $(CONTAINERS_AUTH)"; \
47+
CONFIG_VOLUME="-v $(CONTAINERS_AUTH):/root/.docker/config.json"; \
48+
else \
49+
echo "No authentication file found."; \
50+
fi; \
51+
podman run \
52+
--rm \
53+
--user $(id -u):$(id -g) \
54+
--security-opt label=disable \
55+
--pull always \
56+
-v $(TOPDIR):/workspace \
57+
$$CONFIG_VOLUME \
58+
$(OPERATOR_PIPELINE_IMAGE) fbc-onboarding \
59+
--repo-root /workspace \
60+
--operator-name $(OPERATOR_NAME) \
61+
--cache-dir /workspace/.catalog_cache
62+
63+
.PHONY: catalogs
4364
# replace this stub with one customized to serve your needs ... some examples below
4465

4566
# here are a few examples of different approaches to fulfilling this target
4667
# comment out / customize the one that makes the most sense, or use them as examples in defining your own
4768
#
4869
# --- BASIC TEMPLATE ---
49-
catalog: basic
70+
catalogs: basic
5071
#
5172
# --- SEMVER TEMPLATE ---
52-
#catalog: semver
73+
#catalogs: semver
5374

5475

5576
# basic target provides an example FBC generation from a `basic` template type.
@@ -71,11 +92,11 @@ semver: ${BINDIR}/opm clean
7192
${BINDIR}/opm alpha render-template semver -o yaml ${OPERATOR_CATALOG_TEMPLATE_DIR}/$${version}.yaml > ${CATALOG_DIR}/$${version}/${OPERATOR_NAME}/catalog.yaml; \
7293
done
7394

74-
#
75-
# validate target illustrates FBC validation
95+
96+
# validate-catalogs target illustrates FBC validation
7697
# all FBC must pass opm validation in order to be able to be used in a catalog
77-
.PHONY: validate
78-
validate: ${BINDIR}/opm
98+
.PHONY: validate-catalogs
99+
validate-catalogs: ${BINDIR}/opm
79100
${BINDIR}/opm validate $(CATALOG_DIR) && echo "catalog validation passed" || echo "catalog validation failed"
80101

81102
.PHONY: create-catalog-dir
@@ -86,10 +107,6 @@ create-catalog-dir:
86107
clean: create-catalog-dir
87108
find $(CATALOG_DIR) -type d -name ${OPERATOR_NAME} -exec rm -rf {} +
88109

89-
# fbc-onboarding-deps installs the fbc-onboarding tool using pip
90-
.PHONY: fbc-onboarding-deps
91-
fbc-onboarding-deps:
92-
pip install git+https://github.com/redhat-openshift-ecosystem/operator-pipelines.git
93110

94111
OS=$(shell uname -s | tr '[:upper:]' '[:lower:]')
95112
ARCH=$(shell uname -m | sed 's/x86_64/amd64/')

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import argparse
44
import logging
55
import os
6-
import sys
76
from typing import Any, Dict, Optional
87

98
import requests
@@ -168,11 +167,7 @@ def create_catalog_template_dir_if_not_exists(operator: Any) -> str:
168167
str: Path to the template directory
169168
"""
170169
template_dir = os.path.join(operator.root, CATALOG_TEMPLATES_DIR)
171-
if os.path.exists(template_dir):
172-
LOGGER.info("FBC template directory already exists at %s", template_dir)
173-
user_input = input("FBC template directory already exists. Overwrite? [y/n]: ")
174-
if user_input.lower() != "y":
175-
sys.exit(0)
170+
176171
if not os.path.exists(template_dir):
177172
LOGGER.info("Creating template directory at %s", template_dir)
178173
os.makedirs(template_dir)

operator-pipeline-images/tests/entrypoints/test_fbc_onboarding.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -126,12 +126,6 @@ def test_create_catalog_template_dir_if_not_exists(
126126
fbc_onboarding.create_catalog_template_dir_if_not_exists(operator)
127127
mock_makedir.assert_called_once_with("/tmp/catalog-templates")
128128

129-
mock_makedir.reset_mock()
130-
mock_exists.return_value = True
131-
mock_input.return_value = "n"
132-
with pytest.raises(SystemExit):
133-
fbc_onboarding.create_catalog_template_dir_if_not_exists(operator)
134-
135129

136130
@patch("operatorcert.entrypoints.fbc_onboarding.get_base_template_from_catalog")
137131
@patch("operatorcert.entrypoints.fbc_onboarding.yaml.safe_dump")

0 commit comments

Comments
 (0)