annotation helpers

pull/26/head
Karolis Rusenas 2017-07-03 22:42:12 +01:00
parent 3d8eb41d4a
commit 5402cd9236
1 changed files with 30 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package kubernetes
import (
"strings"
)
func addImageToPull(annotations map[string]string, image string) map[string]string {
existing, ok := annotations[forceUpdateImageAnnotation]
if ok {
annotations[forceUpdateImageAnnotation] = existing + "," + image
return annotations
}
annotations[forceUpdateImageAnnotation] = image
return annotations
}
func shouldPullImage(annotations map[string]string, image string) bool {
imagesStr, ok := annotations[forceUpdateImageAnnotation]
if !ok {
return false
}
images := strings.Split(imagesStr, ",")
for _, img := range images {
if img == image {
return true
}
}
return false
}