Skip to content

Commit 9753ef6

Browse files
authored
[ISV-1280] Add developer flag to enable/disable the query-publishing-checklist task (#190)
* [ISV-1280] Add developer flag to enable/disable the query-publishing-checklist task * Update the flag name and add test case * Update the flag name and add test case * Update the flag name and add test case * Update the flag name and add test case * Fix up the yaml format * Add the description in README file * Add the description in README file * Add the description in README file * Add the description in README file * Remove unused code Co-authored-by: haripate <>
1 parent c5188d0 commit 9753ef6

File tree

5 files changed

+44
-7
lines changed

5 files changed

+44
-7
lines changed

README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,13 @@ tkn pipeline start operator-hosted-pipeline \
127127
--showlog
128128
```
129129

130-
> :warning: Only quay-based registries are supported by the hosted pipeline.
130+
To ignore the results of the publishing checklist, pass the following argument:
131+
132+
```bash
133+
--param ignore_publishing_checklist=true
134+
```
135+
136+
:warning: Only quay-based registries are supported by the hosted pipeline.
131137
There are some quay specific tasks for configuring the repositories where
132138
the bundle and index images are pushed.
133139

ansible/roles/operator-pipeline/templates/openshift/pipelines/operator-hosted-pipeline.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ spec:
4141
default: quay-oauth-token
4242
- name: quay_oauth_secret_key
4343
default: token
44+
- name: ignore_publishing_checklist
45+
default: "false"
46+
description: Ignore the results of the publishing checklist
4447
workspaces:
4548
- name: repository
4649
- name: results
@@ -766,6 +769,8 @@ spec:
766769
value: "$(tasks.certification-project-check.results.certification_project_id)"
767770
- name: connect_url
768771
value: "$(tasks.set-env.results.connect_url)"
772+
- name: ignore_publishing_checklist
773+
value: "$(params.ignore_publishing_checklist)"
769774
workspaces:
770775
- name: hydra-credentials
771776
workspace: hydra-credentials

ansible/roles/operator-pipeline/templates/openshift/tasks/query-publishing-checklist.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ spec:
1010
description: ID of the bundle Certification Project
1111
- name: connect_url
1212
description: URL to Red Hat Connect
13+
- name: ignore_publishing_checklist
14+
default: "false"
15+
description: Ignore the results of the publishing checklist
1316
workspaces:
1417
- name: hydra-credentials
1518
steps:
@@ -32,4 +35,5 @@ spec:
3235
3336
hydra-checklist \
3437
--cert-project-id "$(params.cert_project_id)" \
35-
--hydra-url $HYDRA_URL
38+
--hydra-url $HYDRA_URL \
39+
--ignore-publishing-checklist "$(params.ignore_publishing_checklist)"

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,18 @@ def setup_argparser() -> Any: # pragma: no cover
2525
default="https://connect.redhat.com/hydra/prm",
2626
help="URL to the Hydra API",
2727
)
28+
parser.add_argument(
29+
"--ignore-publishing-checklist",
30+
default="false",
31+
help="Ignore the results of the publishing checklist",
32+
)
2833
parser.add_argument("--verbose", action="store_true", help="Verbose output")
2934
return parser
3035

3136

32-
def check_hydra_checklist_status(cert_project_id: str, hydra_url: str) -> Any:
37+
def check_hydra_checklist_status(
38+
cert_project_id: str, hydra_url: str, ignore_publishing_checklist: bool
39+
) -> Any:
3340
# query hydra checklist API
3441
# Not using urljoin because for some reason it will eat up the prm at the end if
3542
# url doesn't end with a /
@@ -59,6 +66,8 @@ def check_hydra_checklist_status(cert_project_id: str, hydra_url: str) -> Any:
5966
f"Pre-certification checklist is not completed for cert project with id "
6067
f"{cert_project_id}."
6168
)
69+
if ignore_publishing_checklist:
70+
return
6271
sys.exit(1)
6372

6473

@@ -74,7 +83,9 @@ def main() -> None:
7483
log_level = "DEBUG"
7584
logging.basicConfig(level=log_level)
7685

77-
check_hydra_checklist_status(args.cert_project_id, args.hydra_url)
86+
check_hydra_checklist_status(
87+
args.cert_project_id, args.hydra_url, args.ignore_publishing_checklist == "true"
88+
)
7889

7990

8091
if __name__ == "__main__": # pragma: no cover

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

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def test_main(mock_check: MagicMock, mock_arg_parser: MagicMock) -> None:
1313
@patch("operatorcert.entrypoints.hydra_checklist.hydra.get")
1414
def test_check_hydra_checklist_status_overall_completed(mock_get: MagicMock) -> None:
1515
mock_get.return_value = {"completed": True}
16-
hydra_checklist.check_hydra_checklist_status("foo", "fake-hydra.url")
16+
hydra_checklist.check_hydra_checklist_status("foo", "fake-hydra.url", False)
1717

1818

1919
@patch("operatorcert.entrypoints.hydra_checklist.hydra.get")
@@ -26,7 +26,7 @@ def test_check_hydra_checklist_status_items_completed(mock_get: MagicMock) -> No
2626
],
2727
"completed": False,
2828
}
29-
hydra_checklist.check_hydra_checklist_status("foo", "fake-hydra.url")
29+
hydra_checklist.check_hydra_checklist_status("foo", "fake-hydra.url", False)
3030

3131

3232
@patch("sys.exit")
@@ -42,5 +42,16 @@ def test_check_hydra_checklist_status_incomplete(
4242
],
4343
"completed": False,
4444
}
45-
hydra_checklist.check_hydra_checklist_status("foo", "fake-hydra.url")
45+
hydra_checklist.check_hydra_checklist_status("foo", "fake-hydra.url", False)
4646
mock_exit.assert_called_once_with(1)
47+
48+
# If the developer flag is on
49+
mock_get.return_value = {
50+
"checklistItems": [
51+
{"title": "Test1", "completed": False},
52+
{"title": "Test2", "completed": True},
53+
{"title": "Test3", "completed": False},
54+
],
55+
"completed": False,
56+
}
57+
hydra_checklist.check_hydra_checklist_status("foo", "fake-hydra.url", True)

0 commit comments

Comments
 (0)