Skip to content

Commit f3158f6

Browse files
committed
refactor: refactor update_image_pull_secrets
1 parent 7ba5dc3 commit f3158f6

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/codeflare_sdk/utils/generate_yaml.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,11 +142,10 @@ def update_image(spec, image):
142142

143143

144144
def update_image_pull_secrets(spec, image_pull_secrets):
145-
if image_pull_secrets:
146-
if "imagePullSecrets" not in spec:
147-
spec["imagePullSecrets"] = []
148-
for image_pull_secret in image_pull_secrets:
149-
spec["imagePullSecrets"].append({"name": image_pull_secret})
145+
template_secrets = spec.get("imagePullSecrets", [])
146+
spec["imagePullSecrets"] = template_secrets + [
147+
{"name": x} for x in image_pull_secrets
148+
]
150149

151150

152151
def update_env(spec, env):

tests/test-case-cmd.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ spec:
9696
cpu: 2
9797
memory: 8G
9898
nvidia.com/gpu: 0
99+
imagePullSecrets: []
99100
rayVersion: 2.1.0
100101
workerGroupSpecs:
101102
- groupName: small-group-unit-cmd-cluster
@@ -144,6 +145,7 @@ spec:
144145
cpu: 1
145146
memory: 2G
146147
nvidia.com/gpu: 1
148+
imagePullSecrets: []
147149
initContainers:
148150
- command:
149151
- sh

0 commit comments

Comments
 (0)