// Sets the name of the profile to use with the container. func SetProfileName(pod *v1.Pod, containerName, profileName string) error { if pod.Annotations == nil { pod.Annotations = map[string]string{} } pod.Annotations[ContainerAnnotationKeyPrefix+containerName] = profileName return nil }
// updateAnnotations returns an Annotation map containing the api annotation map plus // locally managed annotations func updateAnnotations(existing, ref *v1.Pod) { annotations := make(map[string]string, len(ref.Annotations)+len(localAnnotations)) for k, v := range ref.Annotations { annotations[k] = v } for _, k := range localAnnotations { if v, ok := existing.Annotations[k]; ok { annotations[k] = v } } existing.Annotations = annotations }
// TODO: remove this function when init containers becomes a stable feature func SetInitContainersAnnotations(pod *v1.Pod) error { if len(pod.Spec.InitContainers) > 0 { value, err := json.Marshal(pod.Spec.InitContainers) if err != nil { return err } if pod.Annotations == nil { pod.Annotations = make(map[string]string) } pod.Annotations[v1.PodInitContainersAnnotationKey] = string(value) pod.Annotations[v1.PodInitContainersBetaAnnotationKey] = string(value) } return nil }