Initialize the label and annotation maps if they are nil

This commit is contained in:
Finn Herzfeld
2020-03-24 16:04:33 -07:00
committed by stefanprodan
parent 9d907deece
commit 5c48430ed2

View File

@@ -113,6 +113,13 @@ func (c *KubernetesDefaultRouter) reconcileService(canary *flaggerv1.Canary, nam
svcSpec.Ports = append(svcSpec.Ports, cp)
}
if metadata.Labels == nil {
metadata.Labels = make(map[string]string)
}
if metadata.Annotations == nil {
metadata.Annotations = make(map[string]string)
}
metadata.Labels[c.labelSelector] = name
for k, v := range c.annotations {
metadata.Annotations[k] = v