mirror of
https://github.com/rancher/norman.git
synced 2025-09-01 07:08:59 +00:00
Updates
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
@@ -47,6 +48,15 @@ func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
||||
if obj, ok := o.(metav1.Object); ok && obj.GetNamespace() != "" {
|
||||
ns = obj.GetNamespace()
|
||||
}
|
||||
if t, err := meta.TypeAccessor(o); err == nil {
|
||||
if t.GetKind() == "" {
|
||||
t.SetKind(p.gvk.Kind)
|
||||
}
|
||||
if t.GetAPIVersion() == "" {
|
||||
apiVersion, _ := p.gvk.ToAPIVersionAndKind()
|
||||
t.SetAPIVersion(apiVersion)
|
||||
}
|
||||
}
|
||||
result := p.Factory.Object()
|
||||
err := p.restClient.Post().
|
||||
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||
|
Reference in New Issue
Block a user