Add a common label to all resources on `kube apply'

Yeah


> On Oct 2, 2014, at 9:26 AM, Vojtech Vitek <notifications@github.com> wrote:
> 
> In pkg/config/config.go:
> 
> > +			obj = obj.Elem()
> > +		}
> > +		if obj.Kind() != reflect.Struct {
> > +			return fmt.Errorf("Template.Items[%v]: Invalid object kind. Expected: Struct, got:", i, obj.Kind())
> > +		}
> > +
> > +		// Try to merge labels into the Template.Items[i].Labels field.
> > +		dst := obj.FieldByName("Labels")
> > +		if dst.IsValid() {
> > +			if err := mergeMaps(dst, src, ErrorOnDifferentDstKeyValue); err != nil {
> > +				return fmt.Errorf("Unable to add labels into Template.Items[%v].Labels: %v", i, err)
> > +			}
> > +		}
> > +
> > +		// Hack for the ReplicationController's nested labels.
> > +		if obj.Type().Name() == "ReplicationController" {
> Ok, so basically I will do:
> 
> switch t := obj.(type) {
> case *api.Pod:
>   if err := mergeMaps(t.Labels, src); err != nil {  }
> case *api.Service:
>   if err := mergeMaps(t.Labels, src); err != nil {  }
> case *api.ReplicationController:
>   if err := mergeMaps(t.Labels, src); err != nil {  }
>   if err := mergeMaps(t.DesiredState.PodTemplate.Labels, src); err != nil {  }
> default:
>   // Unknown generic objects
>   // ..use Reflection to find t.Labels
> }
> Do I understand correctly?
> 
> —
> Reply to this email directly or view it on GitHub.