Skip to content

Commit 6a2d8b1

Browse files
committed
package inside reconcile cli
1 parent df1732b commit 6a2d8b1

5 files changed

Lines changed: 33 additions & 3 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ tmp/
1111
bin/
1212
dist/
1313
ocp-cluster/
14+
*.pyc
1415

1516
# IDE folders
1617
.vscode/

ansible_pip_requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ rsa==4.9.1 --hash=sha256:68635866661c6836b8d39430f97a996acbd61bfa49406748ea24353
1111
oauthlib==3.2.2 --hash=sha256:8139f29aac13e25d502680e9e19963e83f16838d48a0d71c287fe40e7067fbca
1212
jsonschema==4.26.0 --hash=sha256:d489f15263b8d200f8387e64b4c3a75f06629559fb73deb8fdfb525f2dab50ce
1313
rpds-py==0.30.0 --hash=sha256:47f236970bccb2233267d89173d3ad2703cd36a0e2a6e92d0560d333871a3d23
14+
click==8.3.3 --hash=sha256:398329ad4837b2ff7cbe1dd166a4c0f8900c3ca3a218de04466f38f6497f18a2

playbooks/tasks/configure_operator.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
- r_sub_check.resources | length == 0
144144
- operator.namespace != "openshift-operators"
145145
ansible.builtin.shell: |
146-
python ../reconcile/operator_versions.py "{{ [operator] }}" "False"
146+
python ../reconcile/cli.py operator-versions --operators "{{ [operator] }}" --dry-run "False"
147147
register: operator_update_result
148148

149149
- name: Print the output

reconcile/cli.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import click
2+
import sys
3+
4+
from operator_versions import reconcile as operator_versions_reconcile
5+
6+
7+
@click.group()
8+
def cli():
9+
pass
10+
11+
12+
@cli.command()
13+
@click.option("--operators", default="[]")
14+
@click.option("--dry-run", default="False")
15+
def operator_versions(operators, dry_run):
16+
# rebuild sys.argv for the standalone script
17+
sys.argv = ["operator_versions.py", operators, dry_run]
18+
19+
operator_versions_reconcile()
20+
21+
22+
@cli.command()
23+
def mgmt_cluster_version():
24+
raise NotImplementedError("mgmt-cluster-version")
25+
26+
27+
if __name__ == "__main__":
28+
cli()

reconcile/operator_versions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ def init_ns_op_version_map(
149149
return ns_op_version_map
150150

151151

152-
def main():
152+
def reconcile():
153153
try:
154154
operators = ast.literal_eval(sys.argv[1])
155155
except (IndexError, ValueError, SyntaxError) as e:
@@ -180,4 +180,4 @@ def main():
180180

181181

182182
if __name__ == "__main__":
183-
main()
183+
reconcile()

0 commit comments

Comments
 (0)