in patch.go [187:224]
func createInitContainerPatch(config agentConfig, createArray bool) (patchOperation, error) {
bp := filepath.Base(config.Image)
name := strings.Split(bp, ":")
allowPrivilegeEscalation := false
agentInitContainer := corev1.Container{
Name: name[0],
Image: config.Image,
VolumeMounts: []corev1.VolumeMount{volumeMounts},
// TODO: should this be a default, and then users can modify it
// *if needed*?
Command: []string{"cp", "-v", "-r", config.ArtifactPath, mountPath},
SecurityContext: &corev1.SecurityContext{
AllowPrivilegeEscalation: &allowPrivilegeEscalation,
Capabilities: &corev1.Capabilities{
Drop: []corev1.Capability{"ALL"},
},
},
}
if errs := validation.IsDNS1123Label(agentInitContainer.Name); len(errs) != 0 {
return patchOperation{}, fmt.Errorf("failed to extract container name from image (%s): init container name (%s) is not a valid DNS_LABEL: %v",
config.Image, agentInitContainer.Name, errs,
)
}
if createArray {
return patchOperation{
Op: "add",
Path: "/spec/initContainers",
Value: []corev1.Container{agentInitContainer},
}, nil
}
return patchOperation{
Op: "add",
Path: "/spec/initContainers/-",
Value: agentInitContainer,
}, nil
}