1
0
mirror of https://github.com/rancher/types.git synced 2025-06-29 23:16:48 +00:00

Update vendor

This commit is contained in:
Darren Shepherd 2018-04-03 14:31:59 -07:00
parent 9128f42dfb
commit 3f10c10b30
7 changed files with 26 additions and 21 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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
}

View File

@ -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,

View File

@ -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,

View File

@ -1,4 +1,4 @@
package clientbase
package objectclient
import (
"encoding/json"

View File

@ -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
}