Skip to content

Commit 26d0fa0

Browse files
fix image list in private registry helper utils (#50)
1 parent 90a3bd5 commit 26d0fa0

File tree

5 files changed

+25
-16
lines changed

5 files changed

+25
-16
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ output
99

1010
# only ignore the values.yaml file at the root of the repo
1111
/values.yaml
12+
.devcontainer

charts/gitops-runtime/Chart.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: 0.1.29
33
description: A Helm chart for Codefresh gitops runtime
44
name: gitops-runtime
5-
version: 0.2.8-alpha
5+
version: 0.2.8-alpha.1
66
home: https://github.com/codefresh-io/gitops-runtime-helm
77
icon: https://avatars1.githubusercontent.com/u/11412079?v=3
88
keywords:
@@ -16,7 +16,7 @@ annotations:
1616
artifacthub.io/prerelease: "true"
1717
artifacthub.io/changes: |
1818
- kind: fixed
19-
description: rollout-reporter and workflow-reporter trigger values were wrong (resulting in event not reaching the platform)
19+
description: Fix image list generation in private registry helper utility
2020
dependencies:
2121
- name: argo-cd
2222
repository: https://codefresh-io.github.io/argo-helm

charts/gitops-runtime/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
## Codefresh gitops runtime
2-
![Version: 0.2.8-alpha](https://img.shields.io/badge/Version-0.2.8--alpha-informational?style=flat-square) ![AppVersion: 0.1.29](https://img.shields.io/badge/AppVersion-0.1.29-informational?style=flat-square)
2+
![Version: 0.2.8-alpha.1](https://img.shields.io/badge/Version-0.2.8--alpha.1-informational?style=flat-square) ![AppVersion: 0.1.29](https://img.shields.io/badge/AppVersion-0.1.29-informational?style=flat-square)
33

44
## Codefresh official documentation:
55
Prior to running the installation please see the official documentation at: https://codefresh.io/docs/docs/installation/gitops/hybrid-gitops-helm-installation/
@@ -15,7 +15,7 @@ We have created a helper utility to resolve this issue:
1515
The utility is packaged in a container image. Below are instructions on executing the utility using Docker:
1616

1717
```
18-
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:0.2.7-alpha <local_registry>
18+
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:0.2.8-alpha.1 <local_registry>
1919
```
2020
`output_dir` - is a local directory where the utility will output files. <br>
2121
`local_registry` - is your local registry where you want to mirror the images to

charts/gitops-runtime/README.md.gotmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ We have created a helper utility to resolve this issue:
1515
The utility is packaged in a container image. Below are instructions on executing the utility using Docker:
1616

1717
```
18-
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:0.2.7-alpha <local_registry>
18+
docker run -v <output_dir>:/output quay.io/codefresh/gitops-runtime-private-registry-utils:{{ template "chart.version" . }} <local_registry>
1919
```
2020
`output_dir` - is a local directory where the utility will output files. <br>
2121
`local_registry` - is your local registry where you want to mirror the images to

scripts/private-registry-utils/private-registry-utils.py

+19-11
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,15 @@ def recurse_replace_registry(currValue,new_registry):
4444
currValue[key] = replace_registry_in_image(currValue[key],new_registry)
4545
else:
4646
recurse_replace_registry(currValue[key],new_registry)
47+
4748
elif type(currValue) is list:
48-
for item in currValue:
49-
recurse_replace_registry(item,new_registry)
49+
for index,item in enumerate(currValue):
50+
if type(item) is dict or type(item) is list:
51+
recurse_replace_registry(item,new_registry)
52+
elif type(item) is str:
53+
if is_docker_image(item):
54+
currValue[index] = replace_registry_in_image(item,new_registry)
55+
5056

5157
def recurse_remove_tags(currValue):
5258
if type(currValue) is dict:
@@ -70,20 +76,17 @@ def recurse_get_source_target(currValue,new_registry,lstSourceTarget):
7076
sourceImage += currValue[key]
7177
if key == "tag":
7278
sourceImage += ":" + currValue[key]
73-
74-
elif type(currValue[key]) is str:
75-
if is_docker_image(currValue[key]):
76-
sourceImage = currValue[key]
77-
78-
recurse_get_source_target(currValue[key],new_registry,lstSourceTarget)
79-
79+
else:
80+
recurse_get_source_target(currValue[key],new_registry,lstSourceTarget)
8081
if len(sourceImage) > 0:
8182
lstSourceTarget.append({"source_image": sourceImage, "target_image": replace_registry_in_image(sourceImage,new_registry)})
82-
8383

8484
elif type(currValue) is list:
8585
for item in currValue:
8686
recurse_get_source_target(item,new_registry,lstSourceTarget)
87+
elif type(currValue) is str:
88+
if is_docker_image(currValue):
89+
lstSourceTarget.append({"source_image": currValue, "target_image": replace_registry_in_image(sourceImage,new_registry)})
8790

8891
def generate_file_from_field(list_of_dicts, field_name, output_file):
8992
with open(output_file, 'w+') as file:
@@ -107,7 +110,6 @@ def generate_image_list():
107110
print("Generating image list")
108111

109112
def generate_mirror_csv(lstSourceTarget, outputDir):
110-
111113
fields = ['source_image', 'target_image']
112114

113115
with open(f"{outputDir}/image-mirror.csv", 'w+') as csvfile:
@@ -138,13 +140,19 @@ def main():
138140

139141

140142
if args.action == "generate-mirror-csv" or args.action is None:
143+
print("Creating image-mirror.csv..")
141144
generate_mirror_csv(lstSourceTarget,args.output_dir)
145+
print("Done!")
142146

143147
if args.action == "generate-image-list" or args.action is None:
148+
print("Creating image-list.txt...")
144149
generate_file_from_field(lstSourceTarget,"source_image", f"{args.output_dir}/image-list.txt")
150+
print("Done!")
145151

146152
if args.action == "generate-image-values" or args.action is None:
153+
print("Creating values files...")
147154
generate_image_values(dictImageValues,args.output_dir)
155+
print("Done!")
148156

149157
if __name__ == "__main__":
150158
main()

0 commit comments

Comments
 (0)