Files
dsk-version-management/main.py
minchulahn 6210f45d0e Clean Code
2023-05-25 17:36:20 +09:00

27 lines
707 B
Python

import json, sys, traceback
def get_service_index():
for index, value in enumerate(json_data['service']):
if(value['name'] == sys.argv[2]):
return index
exit(traceback.print_exc())
def set_latest_version():
service_index = get_service_index()
json_data["service"][service_index]["latest_version"] = sys.argv[1]
if __name__ == '__main__':
if len(sys.argv) != 3:
exit(traceback.print_exc())
file_path = "./candidate-version.json"
with open(file_path, 'r') as json_file:
json_data = json.load(json_file)
set_latest_version()
with open(file_path, 'w') as file:
json.dump(json_data, file, indent=4)