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:
committed by
Craig Jellick
parent
1d3cf7aee8
commit
27ebab5e48
@@ -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)
|
||||
|
Reference in New Issue
Block a user