Hello, I'm following your fantastic article about mutating webhook and I'm trying to understand what happens underground, unfortunately I'm struggling to understand what add Container func does.
Can you please explain to me what you are doing in this block
first := len(target) == 0
for _, add := range added {
value = add
path := basePath
if first {
first = false
value = []corev1.Container{add}
} else {
path = path + "/-"
}
original function:
func addContainer(target, added []corev1.Container, basePath string) (patch []patchOperation) {
first := len(target) == 0
var value interface{}
for _, add := range added {
value = add
path := basePath
if first {
first = false
value = []corev1.Container{add}
} else {
path = path + "/-"
}
patch = append(patch, patchOperation{
Op: "add",
Path: path,
Value: value,
})
}
return patch
}
Hello, I'm following your fantastic article about mutating webhook and I'm trying to understand what happens underground, unfortunately I'm struggling to understand what
add Container
func does. Can you please explain to me what you are doing in this blockoriginal function:
Thanks for your help!