1
0
mirror of https://github.com/rancher/norman.git synced 2025-09-02 07:44:51 +00:00

Add label to objects created through norman

This commit is contained in:
Dan Ramich
2018-08-29 11:58:46 -07:00
committed by Craig Jellick
parent 1d3cf7aee8
commit 27ebab5e48
2 changed files with 13 additions and 1 deletions

View File

@@ -94,9 +94,20 @@ func (p *ObjectClient) getAPIPrefix() string {
func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
ns := p.ns
if obj, ok := o.(metav1.Object); ok && obj.GetNamespace() != "" {
obj, ok := o.(metav1.Object)
if ok && obj.GetNamespace() != "" {
ns = obj.GetNamespace()
}
if ok {
labels := obj.GetLabels()
if labels == nil {
labels = make(map[string]string)
}
labels["cattle.io/creator"] = "norman"
obj.SetLabels(labels)
}
if t, err := meta.TypeAccessor(o); err == nil {
if t.GetKind() == "" {
t.SetKind(p.gvk.Kind)