diff --git a/vendor.conf b/vendor.conf index 0cf81729..0f0e9994 100644 --- a/vendor.conf +++ b/vendor.conf @@ -5,4 +5,4 @@ k8s.io/kubernetes v1.8.3 bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git golang.org/x/sync fd80eb99c8f653c847d294a001bdf2a3a6f768f5 -github.com/rancher/norman 17c297e703d6988ac126b054ad5795606b31d344 +github.com/rancher/norman ff60298f31f081b06d198815b4c178a578664f7d diff --git a/vendor/github.com/rancher/norman/controller/generic_controller.go b/vendor/github.com/rancher/norman/controller/generic_controller.go index bc3cdfa9..37cead8e 100644 --- a/vendor/github.com/rancher/norman/controller/generic_controller.go +++ b/vendor/github.com/rancher/norman/controller/generic_controller.go @@ -9,7 +9,7 @@ import ( "github.com/juju/ratelimit" errors2 "github.com/pkg/errors" - "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/objectclient" "github.com/rancher/norman/types" "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/api/errors" @@ -40,7 +40,7 @@ type GenericController interface { type Backend interface { List(opts metav1.ListOptions) (runtime.Object, error) Watch(opts metav1.ListOptions) (watch.Interface, error) - ObjectFactory() clientbase.ObjectFactory + ObjectFactory() objectclient.ObjectFactory } type handlerDef struct { diff --git a/vendor/github.com/rancher/norman/generator/controller_template.go b/vendor/github.com/rancher/norman/generator/controller_template.go index 62dd20ea..65efc848 100644 --- a/vendor/github.com/rancher/norman/generator/controller_template.go +++ b/vendor/github.com/rancher/norman/generator/controller_template.go @@ -6,7 +6,7 @@ import ( "context" {{.importPackage}} - "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/objectclient" "github.com/rancher/norman/controller" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -59,7 +59,7 @@ type {{.schema.CodeName}}Controller interface { } type {{.schema.CodeName}}Interface interface { - ObjectClient() *clientbase.ObjectClient + ObjectClient() *objectclient.ObjectClient Create(*{{.prefix}}{{.schema.CodeName}}) (*{{.prefix}}{{.schema.CodeName}}, error) GetNamespaced(namespace, name string, opts metav1.GetOptions) (*{{.prefix}}{{.schema.CodeName}}, error) Get(name string, opts metav1.GetOptions) (*{{.prefix}}{{.schema.CodeName}}, error) @@ -185,11 +185,11 @@ func (s *{{.schema.ID}}Client) Controller() {{.schema.CodeName}}Controller { type {{.schema.ID}}Client struct { client *Client ns string - objectClient *clientbase.ObjectClient + objectClient *objectclient.ObjectClient controller {{.schema.CodeName}}Controller } -func (s *{{.schema.ID}}Client) ObjectClient() *clientbase.ObjectClient { +func (s *{{.schema.ID}}Client) ObjectClient() *objectclient.ObjectClient { return s.objectClient } diff --git a/vendor/github.com/rancher/norman/generator/k8s_client_template.go b/vendor/github.com/rancher/norman/generator/k8s_client_template.go index 0e4f1290..323823b3 100644 --- a/vendor/github.com/rancher/norman/generator/k8s_client_template.go +++ b/vendor/github.com/rancher/norman/generator/k8s_client_template.go @@ -6,7 +6,7 @@ import ( "sync" "context" - "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/objectclient" "github.com/rancher/norman/controller" "github.com/rancher/norman/restwatch" "k8s.io/client-go/dynamic" @@ -64,7 +64,7 @@ type {{.CodeNamePlural}}Getter interface { } func (c *Client) {{.CodeNamePlural}}(namespace string) {{.CodeName}}Interface { - objectClient := clientbase.NewObjectClient(namespace, c.restClient, &{{.CodeName}}Resource, {{.CodeName}}GroupVersionKind, {{.ID}}Factory{}) + objectClient := objectclient.NewObjectClient(namespace, c.restClient, &{{.CodeName}}Resource, {{.CodeName}}GroupVersionKind, {{.ID}}Factory{}) return &{{.ID}}Client{ ns: namespace, client: c, diff --git a/vendor/github.com/rancher/norman/lifecycle/object.go b/vendor/github.com/rancher/norman/lifecycle/object.go index 725bd7d6..120f341f 100644 --- a/vendor/github.com/rancher/norman/lifecycle/object.go +++ b/vendor/github.com/rancher/norman/lifecycle/object.go @@ -4,7 +4,7 @@ import ( "fmt" "reflect" - "github.com/rancher/norman/clientbase" + "github.com/rancher/norman/objectclient" "github.com/rancher/norman/types/slice" "k8s.io/apimachinery/pkg/api/meta" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -27,10 +27,10 @@ type objectLifecycleAdapter struct { name string clusterScoped bool lifecycle ObjectLifecycle - objectClient *clientbase.ObjectClient + objectClient *objectclient.ObjectClient } -func NewObjectLifecycleAdapter(name string, clusterScoped bool, lifecycle ObjectLifecycle, objectClient *clientbase.ObjectClient) func(key string, obj runtime.Object) error { +func NewObjectLifecycleAdapter(name string, clusterScoped bool, lifecycle ObjectLifecycle, objectClient *objectclient.ObjectClient) func(key string, obj runtime.Object) error { o := objectLifecycleAdapter{ name: name, clusterScoped: clusterScoped, diff --git a/vendor/github.com/rancher/norman/clientbase/object_client.go b/vendor/github.com/rancher/norman/objectclient/object_client.go similarity index 99% rename from vendor/github.com/rancher/norman/clientbase/object_client.go rename to vendor/github.com/rancher/norman/objectclient/object_client.go index 19102f2d..80a565d9 100644 --- a/vendor/github.com/rancher/norman/clientbase/object_client.go +++ b/vendor/github.com/rancher/norman/objectclient/object_client.go @@ -1,4 +1,4 @@ -package clientbase +package objectclient import ( "encoding/json" diff --git a/vendor/github.com/rancher/norman/types/reflection.go b/vendor/github.com/rancher/norman/types/reflection.go index 263566b0..dcb82592 100644 --- a/vendor/github.com/rancher/norman/types/reflection.go +++ b/vendor/github.com/rancher/norman/types/reflection.go @@ -2,24 +2,20 @@ package types import ( "fmt" + "net/http" "reflect" "strconv" "strings" - "net/http" - "github.com/rancher/norman/types/convert" "github.com/rancher/norman/types/definition" "github.com/rancher/norman/types/slice" "github.com/sirupsen/logrus" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) var ( namespacedType = reflect.TypeOf(Namespaced{}) resourceType = reflect.TypeOf(Resource{}) - typeType = reflect.TypeOf(metav1.TypeMeta{}) - metaType = reflect.TypeOf(metav1.ObjectMeta{}) blacklistNames = map[string]bool{ "links": true, "actions": true, @@ -194,6 +190,16 @@ func jsonName(f reflect.StructField) string { return strings.SplitN(f.Tag.Get("json"), ",", 2)[0] } +func k8sType(field reflect.StructField) bool { + return field.Type.Name() == "TypeMeta" && + strings.HasSuffix(field.Type.PkgPath(), "k8s.io/apimachinery/pkg/apis/meta/v1") +} + +func k8sObject(field reflect.StructField) bool { + return field.Type.Name() == "ObjectMeta" && + strings.HasSuffix(field.Type.PkgPath(), "k8s.io/apimachinery/pkg/apis/meta/v1") +} + func (s *Schemas) readFields(schema *Schema, t reflect.Type) error { if t == resourceType { schema.CollectionMethods = []string{"GET", "POST"} @@ -212,16 +218,15 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error { } jsonName := jsonName(field) - if jsonName == "-" { continue } - if field.Anonymous && jsonName == "" && field.Type == typeType { + if field.Anonymous && jsonName == "" && k8sType(field) { hasType = true } - if field.Anonymous && jsonName == "metadata" && field.Type == metaType { + if field.Anonymous && jsonName == "metadata" && k8sObject(field) { hasMeta = true }