Skip to content

Commit 6bdfd01

Browse files
authored
Add image mirror conditional input (#242)
Signed-off-by: Sergio Arroutbi <[email protected]>
1 parent cccaf2f commit 6bdfd01

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

tools/cluster_tools/mirror_image.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def get_image_path(image):
9797
"""
9898
This function returns the image path
9999
"""
100-
return image.split('/', 1)[1]
100+
return 'openshift/' + image.split('/', 1)[1].split('/',1)[1]
101101

102102
def get_user_password_from_file(file_name):
103103
"""
@@ -128,7 +128,11 @@ def launch_node_commands(node, api_server, args):
128128
send_pexpect_command(child, '\n', '#')
129129
send_pexpect_command(child, 'oc login -u kubeadmin -p ' + args.cluster_password +
130130
' ' + api_server, ': ')
131-
send_pexpect_command(child, '\n', '#')
131+
index = child.expect([":", "#", pexpect.TIMEOUT])
132+
if index == 0:
133+
send_pexpect_command(child, 'yes', '#')
134+
else:
135+
send_pexpect_command(child, '\n', '#')
132136
send_pexpect_command(child, 'podman login -u kubeadmin -p $(oc whoami -t) ' +
133137
LOCAL_REGISTRY, '#')
134138
send_pexpect_command(child, 'echo', '#')
@@ -140,6 +144,7 @@ def launch_node_commands(node, api_server, args):
140144
send_pexpect_command(child, 'podman tag ' + args.original_image + ' ' + LOCAL_REGISTRY +
141145
'/' + get_image_path(args.original_image), '#')
142146
send_pexpect_command(child, 'podman images | grep ' + LOCAL_REGISTRY, '#')
147+
send_pexpect_command(child, 'podman push ' + LOCAL_REGISTRY + '/' + get_image_path(args.original_image), '#')
143148
send_pexpect_command(child, 'exit', '#')
144149
sys.stdout.flush()
145150
child.close()

0 commit comments

Comments
 (0)