Reduce logs with new Kubernetes security annotations
This commit is contained in:
parent
c228e73b26
commit
aaf120f263
1 changed files with 22 additions and 13 deletions
|
@ -19,7 +19,7 @@ func getBoolAnnotation(meta *v1beta1.Ingress, name string, defaultValue bool) bo
|
|||
case annotationStringValue == "true":
|
||||
annotationValue = true
|
||||
default:
|
||||
log.Warnf("Unknown value %q for %q, falling back to %q", annotationStringValue, name, defaultValue)
|
||||
log.Warnf("Unknown value %q for %q, falling back to %v", annotationStringValue, name, defaultValue)
|
||||
}
|
||||
return annotationValue
|
||||
}
|
||||
|
@ -41,21 +41,30 @@ func getSliceAnnotation(meta *v1beta1.Ingress, name string) []string {
|
|||
return value
|
||||
}
|
||||
|
||||
func getMapAnnotation(meta *v1beta1.Ingress, name string) map[string]string {
|
||||
value := make(map[string]string)
|
||||
if annotation := meta.Annotations[name]; annotation != "" {
|
||||
for _, v := range strings.Split(annotation, ",") {
|
||||
pair := strings.Split(v, ":")
|
||||
if len(pair) != 2 {
|
||||
log.Debugf("Could not load annotation (%v) with value: %v, skipping...", name, pair)
|
||||
} else {
|
||||
value[pair[0]] = pair[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
if len(value) == 0 {
|
||||
log.Debugf("Could not load %v annotation, skipping...", name)
|
||||
func getMapAnnotation(meta *v1beta1.Ingress, annotName string) map[string]string {
|
||||
if values, ok := meta.Annotations[annotName]; ok {
|
||||
|
||||
if len(values) == 0 {
|
||||
log.Errorf("Missing value for annotation %q", annotName)
|
||||
return nil
|
||||
}
|
||||
return value
|
||||
|
||||
mapValue := make(map[string]string)
|
||||
for _, parts := range strings.Split(values, ",") {
|
||||
pair := strings.Split(parts, ":")
|
||||
if len(pair) != 2 {
|
||||
log.Warnf("Could not load %q: %v, skipping...", annotName, pair)
|
||||
} else {
|
||||
mapValue[pair[0]] = pair[1]
|
||||
}
|
||||
}
|
||||
|
||||
if len(mapValue) == 0 {
|
||||
log.Errorf("Could not load %q, skipping...", annotName)
|
||||
return nil
|
||||
}
|
||||
return mapValue
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue