Add Template-ability check to Kubernetes API Fields

This commit is contained in:
Daniel Tomcej 2018-10-04 02:58:03 -05:00 committed by Traefiker Bot
parent d69977c229
commit 31f92001e2
3 changed files with 79 additions and 6 deletions

View file

@ -1,6 +1,8 @@
package kubernetes
import (
"strconv"
"github.com/containous/traefik/provider/label"
)
@ -106,6 +108,13 @@ func getStringValue(annotations map[string]string, annotation string, defaultVal
return label.GetStringValue(annotations, annotationName, defaultValue)
}
func getStringSafeValue(annotations map[string]string, annotation string, defaultValue string) (string, error) {
annotationName := getAnnotationName(annotations, annotation)
value := label.GetStringValue(annotations, annotationName, defaultValue)
_, err := strconv.Unquote(`"` + value + `"`)
return value, err
}
func getBoolValue(annotations map[string]string, annotation string, defaultValue bool) bool {
annotationName := getAnnotationName(annotations, annotation)
return label.GetBoolValue(annotations, annotationName, defaultValue)