Skip to content

Commit 810fa3c

Browse files
authored
fix: add validation for tf-client container injection (#74)
1 parent bfb6c5e commit 810fa3c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

internal/webhook/v1/pod_webhook.go

+6
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ func (m *TensorFusionPodMutator) patchTFClient(
201201
}
202202
}
203203

204+
contianerPatched := false
204205
// Patch to Container
205206
for _, name := range containerNames {
206207
for i := range pod.Spec.Containers {
@@ -241,11 +242,16 @@ func (m *TensorFusionPodMutator) patchTFClient(
241242
Name: constants.GetConnectionURLEnv,
242243
Value: fmt.Sprintf("%s/api/connection?name=%s&namespace=%s", clientConfig.OperatorEndpoint, connectionName, connectionNamespace),
243244
})
245+
contianerPatched = true
244246
}
245247
pod.Spec.Containers[i] = *container
246248
}
247249
}
248250

251+
if !contianerPatched {
252+
return nil, fmt.Errorf("no container found that needs tf-client injection")
253+
}
254+
249255
containerPatchedJSON, err := json.Marshal(pod)
250256
if err != nil {
251257
return nil, fmt.Errorf("marshal current pod: %w", err)

0 commit comments

Comments
 (0)