Created
April 19, 2020 13:37
-
-
Save developer-guy/6e934cb11a315b63969299964389075d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func (p *patches) addContainers(pod *corev1.Pod, containers []corev1.Container) { | |
first := len(pod.Spec.Containers) == 0 | |
path := "/spec/containers" | |
var value interface{} | |
for _, c := range containers { | |
value = c | |
tempPath := path | |
if first { | |
first = false | |
value = []corev1.Container{c} | |
} else { | |
tempPath = path + "/-" | |
} | |
*p = append(*p, patchOperation{ | |
Op: "add", | |
Path: tempPath, | |
Value: value, | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment