Skip to content

Commit

Permalink
Do fixup on empty annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
lnsp committed Feb 24, 2020
1 parent 6286fc0 commit 66ccffc
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ const (
)

func (c *Controller) hasValidAnnotation(pod *v1.Pod) bool {
podAnnotations := pod.GetObjectMeta().GetAnnotations()
podAnnotations := pod.ObjectMeta.Annotations
if podAnnotations == nil {
podAnnotations = make(map[string]string)
}
if podAnnotations[annotationEnableMattermost] == annotationEnableMattermostInform {
return true
}
Expand All @@ -65,7 +68,10 @@ func (c *Controller) hasValidAnnotation(pod *v1.Pod) bool {
klog.Infof("Failed to get replicaset: %v", err)
return false
}
rsAnnotations := rs.GetObjectMeta().GetAnnotations()
rsAnnotations := rs.ObjectMeta.Annotations
if rsAnnotations == nil {
rsAnnotations = make(map[string]string)
}
podAnnotations[annotationMattermostBackoff] = rsAnnotations[annotationMattermostBackoff]
if rsAnnotations[annotationEnableMattermost] == annotationEnableMattermostInform {
return true
Expand All @@ -75,7 +81,10 @@ func (c *Controller) hasValidAnnotation(pod *v1.Pod) bool {
klog.Infof("Failed to get deployment: %v", err)
return false
}
depAnnotations := dep.GetObjectMeta().GetAnnotations()
depAnnotations := dep.ObjectMeta.Annotations
if depAnnotations == nil {
depAnnotations = make(map[string]string)
}
podAnnotations[annotationMattermostBackoff] = depAnnotations[annotationMattermostBackoff]
return depAnnotations[annotationEnableMattermost] == annotationEnableMattermostInform
}
Expand Down

0 comments on commit 66ccffc

Please sign in to comment.