Skip to content

Commit ad26b1e

Browse files
author
James Oliver
committed
parameterize catalog url and add error handling
1 parent 57f345c commit ad26b1e

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

scripts/print-catalog-images/print-catalog-images.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@
2222

2323
parser = argparse.ArgumentParser(description=description)
2424

25+
parser.add_argument('-u', '--url',
26+
default='https://git.rancher.io/rancher-catalog',
27+
help='Rancher catalog URL accessible in airgap environment')
28+
parser.add_argument('-b', '--branch',
29+
help='Rancher catalog branch accessible in airgap environment')
2530
parser.add_argument('-v', '--version',
2631
required=True,
2732
help='Rancher Server version')
@@ -149,17 +154,24 @@ def version_images(service_version_dir):
149154

150155
return images
151156

157+
152158
version = args.version.lstrip('v')
153-
branch = get_catalog_branch(version)
159+
if args.branch is None:
160+
args.branch = get_catalog_branch(version)
154161

155162
print 'Rancher Version: ' + version
156-
print 'Catalog Branch: ' + branch
163+
print 'Catalog URL: ' + args.url
164+
print 'Catalog Branch: ' + args.branch
157165
print
158166

159167
catalog_dir = str(uuid.uuid4())
160-
subprocess.call(["git", "clone", "https://git.rancher.io/rancher-catalog",
161-
"--quiet", "--single-branch", "--branch", branch,
162-
catalog_dir])
168+
try:
169+
subprocess.check_call(["git", "clone", args.url,
170+
"--quiet", "--single-branch", "--branch", args.branch,
171+
catalog_dir])
172+
except subprocess.CalledProcessError:
173+
sys.exit(1)
174+
163175

164176
infra_dir = catalog_dir + "/infra-templates"
165177
for infra_service in os.listdir(infra_dir):

0 commit comments

Comments
 (0)