Skip to content

Commit

Permalink
tag
Browse files Browse the repository at this point in the history
  • Loading branch information
shyam-ks committed Nov 18, 2021
1 parent b5c2aeb commit 940b078
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions utils/update-image-tag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys
import ruamel.yaml

print ("File name: %s" % (sys.argv[1]))
print ("Image Name: %s" % (sys.argv[2]))
print ("Tag: %s" % (sys.argv[3]))
fname = sys.argv[1]
imageName = str(sys.argv[2])
tag = str(sys.argv[3])

# Check if file exists
from pathlib import Path
if Path(fname).is_file():
print ("File exist")
else:
raise ValueError('File not found.')

stream = open(fname, 'r')
yaml = ruamel.yaml.YAML() # defaults to round-trip if no parameters given
code = yaml.load(stream)
code[imageName]['image']['tag'] = tag
yaml.dump(code, sys.stdout)
with open(fname, "w") as f:
yaml.dump(code, f)


# paramLength = len(code['spec']['source']['helm']['parameters'])
# paramName = imageName + ".image.tag"

# for x in range(paramLength):
# for key, value in code['spec']['source']['helm']['parameters'][x].items():
# if code['spec']['source']['helm']['parameters'][x]['name'] == paramName:
# code['spec']['source']['helm']['parameters'][x]['value'] = tag

0 comments on commit 940b078

Please sign in to comment.