Skip to content

Commit f8a49e4

Browse files
committed
consistent handling of image tag reset with useChartVersion: true
1 parent 8cf9380 commit f8a49e4

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

chartpress.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,7 +1138,13 @@ def main(args=None):
11381138
# tag specified, use that version
11391139
forced_version = args.tag
11401140

1141-
if not args.list_images:
1141+
if args.list_images:
1142+
# skip build_chart when listing images,
1143+
# instead read the current version from Chart.yaml
1144+
chart_file = os.path.join(chart["name"], "Chart.yaml")
1145+
with open(chart_file) as f:
1146+
chart_version = yaml.load(f)["version"]
1147+
else:
11421148
# update Chart.yaml with a version
11431149
chart_version = build_chart(
11441150
chart["name"],
@@ -1156,13 +1162,22 @@ def main(args=None):
11561162
base_version = _trim_version_suffix(chart_version)
11571163
else:
11581164
base_version = None
1165+
1166+
# set common image tag if `--tag` specified _or_ resetting
1167+
common_image_tag = None
1168+
if args.tag:
1169+
common_image_tag = args.tag
1170+
elif args.reset:
1171+
if use_chart_version:
1172+
common_image_tag = chart_version
1173+
else:
1174+
common_image_tag = chart.get("resetTag", "set-by-chartpress")
1175+
11591176
# build images
11601177
values_file_modifications = build_images(
11611178
prefix=args.image_prefix or chart.get("imagePrefix", ""),
11621179
images=chart["images"],
1163-
tag=args.tag
1164-
if not args.reset
1165-
else chart.get("resetTag", "set-by-chartpress"),
1180+
tag=common_image_tag,
11661181
push=args.push,
11671182
force_push=args.force_push,
11681183
force_build=args.force_build,

0 commit comments

Comments
 (0)