Conditionally populate labels
@@ -47,10 +47,12 @@ func FromCluster(in *redskyv1beta1.Experiment) (redskyapi.ExperimentName, *redsk
out.ExperimentMeta.SelfURL = in.Annotations[redskyv1beta1.AnnotationExperimentURL]
out.ExperimentMeta.NextTrialURL = in.Annotations[redskyv1beta1.AnnotationNextTrialURL]
- out.Labels = make(map[string]string, len(in.ObjectMeta.Labels))
+ if l := len(in.ObjectMeta.Labels); l > 0 {
+ out.Labels = make(map[string]string, l)
for k, v := range in.ObjectMeta.Labels {
out.Labels[strings.TrimPrefix(k, "redskyops.dev/")] = v
}
+ }
out.Optimization = nil
for _, o := range in.Spec.Optimization {
