Skip to content

Instantly share code, notes, and snippets.

@developer-guy
Created April 19, 2020 13:37
Show Gist options
  • Save developer-guy/6e934cb11a315b63969299964389075d to your computer and use it in GitHub Desktop.
Save developer-guy/6e934cb11a315b63969299964389075d to your computer and use it in GitHub Desktop.
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