mirror of
https://github.com/rancher/rke.git
synced 2025-08-09 10:48:10 +00:00
Vendor Update
This commit is contained in:
parent
e21bf80950
commit
c77d3b51be
14
vendor/github.com/rancher/norman/clientbase/common.go
generated
vendored
14
vendor/github.com/rancher/norman/clientbase/common.go
generated
vendored
@ -55,7 +55,7 @@ func IsNotFound(err error) bool {
|
|||||||
return apiError.StatusCode == http.StatusNotFound
|
return apiError.StatusCode == http.StatusNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
func newApiError(resp *http.Response, url string) *APIError {
|
func newAPIError(resp *http.Response, url string) *APIError {
|
||||||
contents, err := ioutil.ReadAll(resp.Body)
|
contents, err := ioutil.ReadAll(resp.Body)
|
||||||
var body string
|
var body string
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -161,7 +161,7 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return result, newApiError(resp, opts.URL)
|
return result, newAPIError(resp, opts.URL)
|
||||||
}
|
}
|
||||||
|
|
||||||
schemasURLs := resp.Header.Get("X-API-Schemas")
|
schemasURLs := resp.Header.Get("X-API-Schemas")
|
||||||
@ -184,7 +184,7 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) {
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return result, newApiError(resp, opts.URL)
|
return result, newAPIError(resp, opts.URL)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -244,7 +244,7 @@ func (a *APIBaseClient) Post(url string, createObj interface{}, respObject inter
|
|||||||
func (a *APIBaseClient) GetLink(resource types.Resource, link string, respObject interface{}) error {
|
func (a *APIBaseClient) GetLink(resource types.Resource, link string, respObject interface{}) error {
|
||||||
url := resource.Links[link]
|
url := resource.Links[link]
|
||||||
if url == "" {
|
if url == "" {
|
||||||
return fmt.Errorf("Failed to find link: %s", link)
|
return fmt.Errorf("failed to find link: %s", link)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.Ops.DoGet(url, &types.ListOpts{}, respObject)
|
return a.Ops.DoGet(url, &types.ListOpts{}, respObject)
|
||||||
@ -270,12 +270,12 @@ func (a *APIBaseClient) Delete(existing *types.Resource) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIBaseClient) Reload(existing *types.Resource, output interface{}) error {
|
func (a *APIBaseClient) Reload(existing *types.Resource, output interface{}) error {
|
||||||
selfUrl, ok := existing.Links[SELF]
|
selfURL, ok := existing.Links[SELF]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
return fmt.Errorf("failed to find self URL of [%v]", existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.Ops.DoGet(selfUrl, NewListOpts(), output)
|
return a.Ops.DoGet(selfURL, NewListOpts(), output)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIBaseClient) Action(schemaType string, action string,
|
func (a *APIBaseClient) Action(schemaType string, action string,
|
||||||
|
21
vendor/github.com/rancher/norman/clientbase/object_client.go
generated
vendored
21
vendor/github.com/rancher/norman/clientbase/object_client.go
generated
vendored
@ -35,6 +35,13 @@ func NewObjectClient(namespace string, restClient rest.Interface, apiResource *m
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *ObjectClient) getAPIPrefix() string {
|
||||||
|
if p.gvk.Group == "" {
|
||||||
|
return "api"
|
||||||
|
}
|
||||||
|
return "apis"
|
||||||
|
}
|
||||||
|
|
||||||
func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
||||||
ns := p.ns
|
ns := p.ns
|
||||||
if obj, ok := o.(metav1.Object); ok && obj.GetNamespace() != "" {
|
if obj, ok := o.(metav1.Object); ok && obj.GetNamespace() != "" {
|
||||||
@ -42,7 +49,7 @@ func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
|||||||
}
|
}
|
||||||
result := p.Factory.Object()
|
result := p.Factory.Object()
|
||||||
err := p.restClient.Post().
|
err := p.restClient.Post().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(ns, p.resource.Namespaced).
|
NamespaceIfScoped(ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
Body(o).
|
Body(o).
|
||||||
@ -54,7 +61,7 @@ func (p *ObjectClient) Create(o runtime.Object) (runtime.Object, error) {
|
|||||||
func (p *ObjectClient) Get(name string, opts metav1.GetOptions) (runtime.Object, error) {
|
func (p *ObjectClient) Get(name string, opts metav1.GetOptions) (runtime.Object, error) {
|
||||||
result := p.Factory.Object()
|
result := p.Factory.Object()
|
||||||
err := p.restClient.Get().
|
err := p.restClient.Get().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
||||||
@ -74,7 +81,7 @@ func (p *ObjectClient) Update(name string, o runtime.Object) (runtime.Object, er
|
|||||||
return result, errors.New("object missing name")
|
return result, errors.New("object missing name")
|
||||||
}
|
}
|
||||||
err := p.restClient.Put().
|
err := p.restClient.Put().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(ns, p.resource.Namespaced).
|
NamespaceIfScoped(ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -86,7 +93,7 @@ func (p *ObjectClient) Update(name string, o runtime.Object) (runtime.Object, er
|
|||||||
|
|
||||||
func (p *ObjectClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
func (p *ObjectClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
||||||
return p.restClient.Delete().
|
return p.restClient.Delete().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
Name(name).
|
Name(name).
|
||||||
@ -98,7 +105,7 @@ func (p *ObjectClient) Delete(name string, opts *metav1.DeleteOptions) error {
|
|||||||
func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
||||||
result := p.Factory.List()
|
result := p.Factory.List()
|
||||||
return result, p.restClient.Get().
|
return result, p.restClient.Get().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
VersionedParams(&opts, dynamic.VersionedParameterEncoderWithV1Fallback).
|
||||||
@ -108,7 +115,7 @@ func (p *ObjectClient) List(opts metav1.ListOptions) (runtime.Object, error) {
|
|||||||
|
|
||||||
func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
||||||
r, err := p.restClient.Get().
|
r, err := p.restClient.Get().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
Prefix("watch").
|
Prefix("watch").
|
||||||
Namespace(p.ns).
|
Namespace(p.ns).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
@ -127,7 +134,7 @@ func (p *ObjectClient) Watch(opts metav1.ListOptions) (watch.Interface, error) {
|
|||||||
|
|
||||||
func (p *ObjectClient) DeleteCollection(deleteOptions *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
|
func (p *ObjectClient) DeleteCollection(deleteOptions *metav1.DeleteOptions, listOptions metav1.ListOptions) error {
|
||||||
return p.restClient.Delete().
|
return p.restClient.Delete().
|
||||||
Prefix("apis", p.gvk.Group, p.gvk.Version).
|
Prefix(p.getAPIPrefix(), p.gvk.Group, p.gvk.Version).
|
||||||
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
NamespaceIfScoped(p.ns, p.resource.Namespaced).
|
||||||
Resource(p.resource.Name).
|
Resource(p.resource.Name).
|
||||||
VersionedParams(&listOptions, dynamic.VersionedParameterEncoderWithV1Fallback).
|
VersionedParams(&listOptions, dynamic.VersionedParameterEncoderWithV1Fallback).
|
||||||
|
46
vendor/github.com/rancher/norman/clientbase/ops.go
generated
vendored
46
vendor/github.com/rancher/norman/clientbase/ops.go
generated
vendored
@ -34,7 +34,7 @@ func (a *APIOperations) DoDelete(url string) error {
|
|||||||
io.Copy(ioutil.Discard, resp.Body)
|
io.Copy(ioutil.Discard, resp.Body)
|
||||||
|
|
||||||
if resp.StatusCode >= 300 {
|
if resp.StatusCode >= 300 {
|
||||||
return newApiError(resp, url)
|
return newAPIError(resp, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -68,7 +68,7 @@ func (a *APIOperations) DoGet(url string, opts *types.ListOpts, respObject inter
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode != 200 {
|
if resp.StatusCode != 200 {
|
||||||
return newApiError(resp, url)
|
return newAPIError(resp, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||||
@ -97,16 +97,16 @@ func (a *APIOperations) DoList(schemaType string, opts *types.ListOpts, respObje
|
|||||||
return errors.New("Resource type [" + schemaType + "] is not listable")
|
return errors.New("Resource type [" + schemaType + "] is not listable")
|
||||||
}
|
}
|
||||||
|
|
||||||
collectionUrl, ok := schema.Links[COLLECTION]
|
collectionURL, ok := schema.Links[COLLECTION]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoGet(collectionUrl, opts, respObject)
|
return a.DoGet(collectionURL, opts, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoNext(nextUrl string, respObject interface{}) error {
|
func (a *APIOperations) DoNext(nextURL string, respObject interface{}) error {
|
||||||
return a.DoGet(nextUrl, nil, respObject)
|
return a.DoGet(nextURL, nil, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoModify(method string, url string, createObj interface{}, respObject interface{}) error {
|
func (a *APIOperations) DoModify(method string, url string, createObj interface{}, respObject interface{}) error {
|
||||||
@ -136,7 +136,7 @@ func (a *APIOperations) DoModify(method string, url string, createObj interface{
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode >= 300 {
|
if resp.StatusCode >= 300 {
|
||||||
return newApiError(resp, url)
|
return newAPIError(resp, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||||
@ -170,16 +170,16 @@ func (a *APIOperations) DoCreate(schemaType string, createObj interface{}, respO
|
|||||||
return errors.New("Resource type [" + schemaType + "] is not creatable")
|
return errors.New("Resource type [" + schemaType + "] is not creatable")
|
||||||
}
|
}
|
||||||
|
|
||||||
var collectionUrl string
|
var collectionURL string
|
||||||
collectionUrl, ok = schema.Links[COLLECTION]
|
collectionURL, ok = schema.Links[COLLECTION]
|
||||||
if !ok {
|
if !ok {
|
||||||
// return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
// return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||||
// This is a hack to address https://github.com/rancher/cattle/issues/254
|
// This is a hack to address https://github.com/rancher/cattle/issues/254
|
||||||
re := regexp.MustCompile("schemas.*")
|
re := regexp.MustCompile("schemas.*")
|
||||||
collectionUrl = re.ReplaceAllString(schema.Links[SELF], schema.PluralName)
|
collectionURL = re.ReplaceAllString(schema.Links[SELF], schema.PluralName)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoModify("POST", collectionUrl, createObj, respObject)
|
return a.DoModify("POST", collectionURL, createObj, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error {
|
func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error {
|
||||||
@ -187,9 +187,9 @@ func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, up
|
|||||||
return errors.New("Existing object is nil")
|
return errors.New("Existing object is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
selfUrl, ok := existing.Links[SELF]
|
selfURL, ok := existing.Links[SELF]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
return fmt.Errorf("failed to find self URL of [%v]", existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
if updates == nil {
|
if updates == nil {
|
||||||
@ -209,7 +209,7 @@ func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, up
|
|||||||
return errors.New("Resource type [" + schemaType + "] is not updatable")
|
return errors.New("Resource type [" + schemaType + "] is not updatable")
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoModify("PUT", selfUrl, updates, respObject)
|
return a.DoModify("PUT", selfURL, updates, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoByID(schemaType string, id string, respObject interface{}) error {
|
func (a *APIOperations) DoByID(schemaType string, id string, respObject interface{}) error {
|
||||||
@ -222,12 +222,12 @@ func (a *APIOperations) DoByID(schemaType string, id string, respObject interfac
|
|||||||
return errors.New("Resource type [" + schemaType + "] can not be looked up by ID")
|
return errors.New("Resource type [" + schemaType + "] can not be looked up by ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
collectionUrl, ok := schema.Links[COLLECTION]
|
collectionURL, ok := schema.Links[COLLECTION]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
return errors.New("Failed to find collection URL for [" + schemaType + "]")
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoGet(collectionUrl+"/"+id, nil, respObject)
|
return a.DoGet(collectionURL+"/"+id, nil, respObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoResourceDelete(schemaType string, existing *types.Resource) error {
|
func (a *APIOperations) DoResourceDelete(schemaType string, existing *types.Resource) error {
|
||||||
@ -240,12 +240,12 @@ func (a *APIOperations) DoResourceDelete(schemaType string, existing *types.Reso
|
|||||||
return errors.New("Resource type [" + schemaType + "] can not be deleted")
|
return errors.New("Resource type [" + schemaType + "] can not be deleted")
|
||||||
}
|
}
|
||||||
|
|
||||||
selfUrl, ok := existing.Links[SELF]
|
selfURL, ok := existing.Links[SELF]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Failed to find self URL of [%v]", existing))
|
return fmt.Errorf("failed to find self URL of [%v]", existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
return a.DoDelete(selfUrl)
|
return a.DoDelete(selfURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *APIOperations) DoAction(schemaType string, action string,
|
func (a *APIOperations) DoAction(schemaType string, action string,
|
||||||
@ -255,9 +255,9 @@ func (a *APIOperations) DoAction(schemaType string, action string,
|
|||||||
return errors.New("Existing object is nil")
|
return errors.New("Existing object is nil")
|
||||||
}
|
}
|
||||||
|
|
||||||
actionUrl, ok := existing.Actions[action]
|
actionURL, ok := existing.Actions[action]
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New(fmt.Sprintf("Action [%v] not available on [%v]", action, existing))
|
return fmt.Errorf("action [%v] not available on [%v]", action, existing)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, ok = a.Types[schemaType]
|
_, ok = a.Types[schemaType]
|
||||||
@ -278,7 +278,7 @@ func (a *APIOperations) DoAction(schemaType string, action string,
|
|||||||
input = bytes.NewBuffer(bodyContent)
|
input = bytes.NewBuffer(bodyContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
req, err := http.NewRequest("POST", actionUrl, input)
|
req, err := http.NewRequest("POST", actionURL, input)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -295,7 +295,7 @@ func (a *APIOperations) DoAction(schemaType string, action string,
|
|||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
if resp.StatusCode >= 300 {
|
if resp.StatusCode >= 300 {
|
||||||
return newApiError(resp, actionUrl)
|
return newAPIError(resp, actionURL)
|
||||||
}
|
}
|
||||||
|
|
||||||
byteContent, err := ioutil.ReadAll(resp.Body)
|
byteContent, err := ioutil.ReadAll(resp.Body)
|
||||||
|
8
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
8
vendor/github.com/rancher/norman/controller/generic_controller.go
generated
vendored
@ -25,7 +25,7 @@ type GenericController interface {
|
|||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
AddHandler(handler HandlerFunc)
|
AddHandler(handler HandlerFunc)
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
Start(threadiness int, ctx context.Context) error
|
Start(ctx context.Context, threadiness int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type genericController struct {
|
type genericController struct {
|
||||||
@ -69,12 +69,12 @@ func (g *genericController) AddHandler(handler HandlerFunc) {
|
|||||||
g.handlers = append(g.handlers, handler)
|
g.handlers = append(g.handlers, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *genericController) Start(threadiness int, ctx context.Context) error {
|
func (g *genericController) Start(ctx context.Context, threadiness int) error {
|
||||||
g.Lock()
|
g.Lock()
|
||||||
defer g.Unlock()
|
defer g.Unlock()
|
||||||
|
|
||||||
if !g.running {
|
if !g.running {
|
||||||
go g.run(threadiness, ctx)
|
go g.run(ctx, threadiness)
|
||||||
}
|
}
|
||||||
|
|
||||||
g.running = true
|
g.running = true
|
||||||
@ -88,7 +88,7 @@ func (g *genericController) queueObject(obj interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *genericController) run(threadiness int, ctx context.Context) {
|
func (g *genericController) run(ctx context.Context, threadiness int) {
|
||||||
defer utilruntime.HandleCrash()
|
defer utilruntime.HandleCrash()
|
||||||
defer g.queue.ShutDown()
|
defer g.queue.ShutDown()
|
||||||
|
|
||||||
|
142
vendor/github.com/rancher/norman/types/condition.go
generated
vendored
142
vendor/github.com/rancher/norman/types/condition.go
generated
vendored
@ -1,108 +1,108 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
var (
|
import (
|
||||||
COND_EQ = QueryConditionType{"eq", 1}
|
"github.com/rancher/norman/types/convert"
|
||||||
COND_NE = QueryConditionType{"ne", 1}
|
)
|
||||||
COND_NULL = QueryConditionType{"null", 0}
|
|
||||||
COND_NOTNULL = QueryConditionType{"notnull", 0}
|
|
||||||
COND_IN = QueryConditionType{"in", -1}
|
|
||||||
COND_NOTIN = QueryConditionType{"notin", -1}
|
|
||||||
COND_OR = QueryConditionType{"or", 1}
|
|
||||||
COND_AND = QueryConditionType{"and", 1}
|
|
||||||
|
|
||||||
mods = map[string]QueryConditionType{
|
var (
|
||||||
COND_EQ.Name: COND_EQ,
|
CondEQ = QueryConditionType{ModifierEQ, 1}
|
||||||
COND_NE.Name: COND_NE,
|
CondNE = QueryConditionType{ModifierNE, 1}
|
||||||
COND_NULL.Name: COND_NULL,
|
CondNull = QueryConditionType{ModifierNull, 0}
|
||||||
COND_NOTNULL.Name: COND_NOTNULL,
|
CondNotNull = QueryConditionType{ModifierNotNull, 0}
|
||||||
COND_IN.Name: COND_IN,
|
CondIn = QueryConditionType{ModifierIn, -1}
|
||||||
COND_NOTIN.Name: COND_NOTIN,
|
CondNotIn = QueryConditionType{ModifierNotIn, -1}
|
||||||
COND_OR.Name: COND_OR,
|
CondOr = QueryConditionType{ModifierType("or"), 1}
|
||||||
COND_AND.Name: COND_AND,
|
CondAnd = QueryConditionType{ModifierType("and"), 1}
|
||||||
|
|
||||||
|
mods = map[ModifierType]QueryConditionType{
|
||||||
|
CondEQ.Name: CondEQ,
|
||||||
|
CondNE.Name: CondNE,
|
||||||
|
CondNull.Name: CondNull,
|
||||||
|
CondNotNull.Name: CondNotNull,
|
||||||
|
CondIn.Name: CondIn,
|
||||||
|
CondNotIn.Name: CondNotIn,
|
||||||
|
CondOr.Name: CondOr,
|
||||||
|
CondAnd.Name: CondAnd,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
type QueryConditionType struct {
|
type QueryConditionType struct {
|
||||||
Name string
|
Name ModifierType
|
||||||
Args int
|
Args int
|
||||||
}
|
}
|
||||||
|
|
||||||
type QueryCondition struct {
|
type QueryCondition struct {
|
||||||
Field string
|
Field string
|
||||||
Values []interface{}
|
Value string
|
||||||
|
Values map[string]bool
|
||||||
conditionType QueryConditionType
|
conditionType QueryConditionType
|
||||||
left, right *QueryCondition
|
left, right *QueryCondition
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (q *QueryCondition) Valid(data map[string]interface{}) bool {
|
||||||
|
switch q.conditionType {
|
||||||
|
case CondAnd:
|
||||||
|
if q.left == nil || q.right == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return q.left.Valid(data) && q.right.Valid(data)
|
||||||
|
case CondOr:
|
||||||
|
if q.left == nil || q.right == nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return q.left.Valid(data) || q.right.Valid(data)
|
||||||
|
case CondEQ:
|
||||||
|
return q.Value == convert.ToString(data[q.Field])
|
||||||
|
case CondNE:
|
||||||
|
return q.Value != convert.ToString(data[q.Field])
|
||||||
|
case CondIn:
|
||||||
|
return q.Values[convert.ToString(data[q.Field])]
|
||||||
|
case CondNotIn:
|
||||||
|
return !q.Values[convert.ToString(data[q.Field])]
|
||||||
|
case CondNotNull:
|
||||||
|
return convert.ToString(data[q.Field]) != ""
|
||||||
|
case CondNull:
|
||||||
|
return convert.ToString(data[q.Field]) == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func (q *QueryCondition) ToCondition() Condition {
|
func (q *QueryCondition) ToCondition() Condition {
|
||||||
cond := Condition{
|
cond := Condition{
|
||||||
Modifier: q.conditionType.Name,
|
Modifier: q.conditionType.Name,
|
||||||
}
|
}
|
||||||
if q.conditionType.Args == 1 && len(q.Values) > 0 {
|
if q.conditionType.Args == 1 {
|
||||||
cond.Value = q.Values[0]
|
cond.Value = q.Value
|
||||||
} else if q.conditionType.Args == -1 {
|
} else if q.conditionType.Args == -1 {
|
||||||
cond.Value = q.Values
|
stringValues := []string{}
|
||||||
|
for val := range q.Values {
|
||||||
|
stringValues = append(stringValues, val)
|
||||||
|
}
|
||||||
|
cond.Value = stringValues
|
||||||
}
|
}
|
||||||
|
|
||||||
return cond
|
return cond
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidMod(mod string) bool {
|
func ValidMod(mod ModifierType) bool {
|
||||||
_, ok := mods[mod]
|
_, ok := mods[mod]
|
||||||
return ok
|
return ok
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewConditionFromString(field, mod string, values ...interface{}) *QueryCondition {
|
func NewConditionFromString(field string, mod ModifierType, values ...string) *QueryCondition {
|
||||||
return &QueryCondition{
|
q := &QueryCondition{
|
||||||
Field: field,
|
Field: field,
|
||||||
Values: values,
|
|
||||||
conditionType: mods[mod],
|
conditionType: mods[mod],
|
||||||
|
Values: map[string]bool{},
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func NewCondition(mod QueryConditionType, values ...interface{}) *QueryCondition {
|
for i, value := range values {
|
||||||
return &QueryCondition{
|
if i == 0 {
|
||||||
Values: values,
|
q.Value = value
|
||||||
conditionType: mod,
|
}
|
||||||
|
q.Values[value] = true
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
func NE(value interface{}) *QueryCondition {
|
return q
|
||||||
return NewCondition(COND_NE, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func EQ(value interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_EQ, value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NULL(value interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_NULL)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NOTNULL(value interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_NOTNULL)
|
|
||||||
}
|
|
||||||
|
|
||||||
func IN(values ...interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_IN, values...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NOTIN(values ...interface{}) *QueryCondition {
|
|
||||||
return NewCondition(COND_NOTIN, values...)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *QueryCondition) AND(right *QueryCondition) *QueryCondition {
|
|
||||||
return &QueryCondition{
|
|
||||||
conditionType: COND_AND,
|
|
||||||
left: c,
|
|
||||||
right: right,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *QueryCondition) OR(right *QueryCondition) *QueryCondition {
|
|
||||||
return &QueryCondition{
|
|
||||||
conditionType: COND_OR,
|
|
||||||
left: c,
|
|
||||||
right: right,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
4
vendor/github.com/rancher/norman/types/convert/convert.go
generated
vendored
4
vendor/github.com/rancher/norman/types/convert/convert.go
generated
vendored
@ -132,12 +132,12 @@ func ToStringSlice(data interface{}) []string {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ToObj(data interface{}, obj interface{}) error {
|
func ToObj(data interface{}, into interface{}) error {
|
||||||
bytes, err := json.Marshal(data)
|
bytes, err := json.Marshal(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return json.Unmarshal(bytes, obj)
|
return json.Unmarshal(bytes, into)
|
||||||
}
|
}
|
||||||
|
|
||||||
func EncodeToMap(obj interface{}) (map[string]interface{}, error) {
|
func EncodeToMap(obj interface{}) (map[string]interface{}, error) {
|
||||||
|
11
vendor/github.com/rancher/norman/types/convert/ref.go
generated
vendored
Normal file
11
vendor/github.com/rancher/norman/types/convert/ref.go
generated
vendored
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
package convert
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func ToReference(typeName string) string {
|
||||||
|
return fmt.Sprintf("reference[%s]", typeName)
|
||||||
|
}
|
||||||
|
|
||||||
|
func ToFullReference(path, typeName string) string {
|
||||||
|
return fmt.Sprintf("reference[%s/schemas/%s]", path, typeName)
|
||||||
|
}
|
3
vendor/github.com/rancher/norman/types/convert/value_set_string.go
generated
vendored
3
vendor/github.com/rancher/norman/types/convert/value_set_string.go
generated
vendored
@ -13,7 +13,6 @@ func ToValuesSlice(value string) []string {
|
|||||||
value = strings.TrimSpace(value)
|
value = strings.TrimSpace(value)
|
||||||
if strings.HasPrefix(value, "(") && strings.HasSuffix(value, ")") {
|
if strings.HasPrefix(value, "(") && strings.HasSuffix(value, ")") {
|
||||||
return splitRegexp.Split(value[1:len(value)-1], -1)
|
return splitRegexp.Split(value[1:len(value)-1], -1)
|
||||||
} else {
|
|
||||||
return []string{value}
|
|
||||||
}
|
}
|
||||||
|
return []string{value}
|
||||||
}
|
}
|
||||||
|
64
vendor/github.com/rancher/norman/types/mapper.go
generated
vendored
64
vendor/github.com/rancher/norman/types/mapper.go
generated
vendored
@ -1,7 +1,6 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/pkg/errors"
|
|
||||||
"github.com/rancher/norman/types/definition"
|
"github.com/rancher/norman/types/definition"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,14 +10,37 @@ type Mapper interface {
|
|||||||
ModifySchema(schema *Schema, schemas *Schemas) error
|
ModifySchema(schema *Schema, schemas *Schemas) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type TypeMapper struct {
|
type Mappers []Mapper
|
||||||
|
|
||||||
|
func (m Mappers) FromInternal(data map[string]interface{}) {
|
||||||
|
for _, mapper := range m {
|
||||||
|
mapper.FromInternal(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Mappers) ToInternal(data map[string]interface{}) {
|
||||||
|
for i := len(m) - 1; i >= 0; i-- {
|
||||||
|
m[i].ToInternal(data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m Mappers) ModifySchema(schema *Schema, schemas *Schemas) error {
|
||||||
|
for _, mapper := range m {
|
||||||
|
if err := mapper.ModifySchema(schema, schemas); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type typeMapper struct {
|
||||||
Mappers []Mapper
|
Mappers []Mapper
|
||||||
typeName string
|
typeName string
|
||||||
subSchemas map[string]*Schema
|
subSchemas map[string]*Schema
|
||||||
subArraySchemas map[string]*Schema
|
subArraySchemas map[string]*Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeMapper) FromInternal(data map[string]interface{}) {
|
func (t *typeMapper) FromInternal(data map[string]interface{}) {
|
||||||
for fieldName, schema := range t.subSchemas {
|
for fieldName, schema := range t.subSchemas {
|
||||||
if schema.Mapper == nil {
|
if schema.Mapper == nil {
|
||||||
continue
|
continue
|
||||||
@ -38,19 +60,29 @@ func (t *TypeMapper) FromInternal(data map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, mapper := range t.Mappers {
|
Mappers(t.Mappers).FromInternal(data)
|
||||||
mapper.FromInternal(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
if data != nil {
|
if data != nil {
|
||||||
data["type"] = t.typeName
|
if _, ok := data["type"]; !ok {
|
||||||
|
data["type"] = t.typeName
|
||||||
|
}
|
||||||
|
name, _ := data["name"].(string)
|
||||||
|
namespace, _ := data["namespace"].(string)
|
||||||
|
|
||||||
|
if _, ok := data["id"]; !ok {
|
||||||
|
if name != "" {
|
||||||
|
if namespace == "" {
|
||||||
|
data["id"] = name
|
||||||
|
} else {
|
||||||
|
data["id"] = namespace + ":" + name
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeMapper) ToInternal(data map[string]interface{}) {
|
func (t *typeMapper) ToInternal(data map[string]interface{}) {
|
||||||
for i := len(t.Mappers) - 1; i >= 0; i-- {
|
Mappers(t.Mappers).ToInternal(data)
|
||||||
t.Mappers[i].ToInternal(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
for fieldName, schema := range t.subArraySchemas {
|
for fieldName, schema := range t.subArraySchemas {
|
||||||
if schema.Mapper == nil {
|
if schema.Mapper == nil {
|
||||||
@ -71,7 +103,7 @@ func (t *TypeMapper) ToInternal(data map[string]interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *TypeMapper) ModifySchema(schema *Schema, schemas *Schemas) error {
|
func (t *typeMapper) ModifySchema(schema *Schema, schemas *Schemas) error {
|
||||||
t.subSchemas = map[string]*Schema{}
|
t.subSchemas = map[string]*Schema{}
|
||||||
t.subArraySchemas = map[string]*Schema{}
|
t.subArraySchemas = map[string]*Schema{}
|
||||||
t.typeName = schema.ID
|
t.typeName = schema.ID
|
||||||
@ -94,11 +126,5 @@ func (t *TypeMapper) ModifySchema(schema *Schema, schemas *Schemas) error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, mapper := range t.Mappers {
|
return Mappers(t.Mappers).ModifySchema(schema, schemas)
|
||||||
if err := mapper.ModifySchema(schema, schemas); err != nil {
|
|
||||||
return errors.Wrapf(err, "mapping type %s", schema.ID)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
115
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
115
vendor/github.com/rancher/norman/types/reflection.go
generated
vendored
@ -6,13 +6,19 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"github.com/rancher/norman/types/convert"
|
"github.com/rancher/norman/types/convert"
|
||||||
|
"github.com/rancher/norman/types/definition"
|
||||||
|
"github.com/rancher/norman/types/slice"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
namespacedType = reflect.TypeOf(Namespaced{})
|
||||||
resourceType = reflect.TypeOf(Resource{})
|
resourceType = reflect.TypeOf(Resource{})
|
||||||
|
typeType = reflect.TypeOf(metav1.TypeMeta{})
|
||||||
metaType = reflect.TypeOf(metav1.ObjectMeta{})
|
metaType = reflect.TypeOf(metav1.ObjectMeta{})
|
||||||
blacklistNames = map[string]bool{
|
blacklistNames = map[string]bool{
|
||||||
"links": true,
|
"links": true,
|
||||||
@ -20,10 +26,17 @@ var (
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (s *Schemas) AddMapperForType(version *APIVersion, obj interface{}, mapper Mapper) *Schemas {
|
func (s *Schemas) AddMapperForType(version *APIVersion, obj interface{}, mapper ...Mapper) *Schemas {
|
||||||
|
if len(mapper) == 0 {
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
t := reflect.TypeOf(obj)
|
t := reflect.TypeOf(obj)
|
||||||
typeName := convert.LowerTitle(t.Name())
|
typeName := convert.LowerTitle(t.Name())
|
||||||
return s.AddMapper(version, typeName, mapper)
|
if len(mapper) == 1 {
|
||||||
|
return s.AddMapper(version, typeName, mapper[0])
|
||||||
|
}
|
||||||
|
return s.AddMapper(version, typeName, Mappers(mapper))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) MustImport(version *APIVersion, obj interface{}, externalOverrides ...interface{}) *Schemas {
|
func (s *Schemas) MustImport(version *APIVersion, obj interface{}, externalOverrides ...interface{}) *Schemas {
|
||||||
@ -35,8 +48,13 @@ func (s *Schemas) MustImport(version *APIVersion, obj interface{}, externalOverr
|
|||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) MustImportAndCustomize(version *APIVersion, obj interface{}, f func(*Schema), externalOverrides ...interface{}) *Schemas {
|
||||||
|
return s.MustImport(version, obj, externalOverrides...).
|
||||||
|
MustCustomizeType(version, obj, f)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) Import(version *APIVersion, obj interface{}, externalOverrides ...interface{}) (*Schema, error) {
|
func (s *Schemas) Import(version *APIVersion, obj interface{}, externalOverrides ...interface{}) (*Schema, error) {
|
||||||
types := []reflect.Type{}
|
var types []reflect.Type
|
||||||
for _, override := range externalOverrides {
|
for _, override := range externalOverrides {
|
||||||
types = append(types, reflect.TypeOf(override))
|
types = append(types, reflect.TypeOf(override))
|
||||||
}
|
}
|
||||||
@ -60,6 +78,54 @@ func (s *Schemas) newSchemaFromType(version *APIVersion, t reflect.Type, typeNam
|
|||||||
return schema, nil
|
return schema, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) setupFilters(schema *Schema) {
|
||||||
|
if !slice.ContainsString(schema.CollectionMethods, http.MethodGet) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
for fieldName, field := range schema.ResourceFields {
|
||||||
|
var mods []ModifierType
|
||||||
|
switch field.Type {
|
||||||
|
case "enum":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
case "string":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
case "int":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
case "boolean":
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE}
|
||||||
|
default:
|
||||||
|
if definition.IsReferenceType(field.Type) {
|
||||||
|
mods = []ModifierType{ModifierEQ, ModifierNE, ModifierIn, ModifierNotIn}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(mods) > 0 {
|
||||||
|
if schema.CollectionFilters == nil {
|
||||||
|
schema.CollectionFilters = map[string]Filter{}
|
||||||
|
}
|
||||||
|
schema.CollectionFilters[fieldName] = Filter{
|
||||||
|
Modifiers: mods,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) MustCustomizeType(version *APIVersion, obj interface{}, f func(*Schema)) *Schemas {
|
||||||
|
name := convert.LowerTitle(reflect.TypeOf(obj).Name())
|
||||||
|
schema := s.Schema(version, name)
|
||||||
|
if schema == nil {
|
||||||
|
panic("Failed to find schema " + name)
|
||||||
|
}
|
||||||
|
|
||||||
|
f(schema)
|
||||||
|
|
||||||
|
if schema.SubContext != "" {
|
||||||
|
s.schemasBySubContext[schema.SubContext] = schema
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...reflect.Type) (*Schema, error) {
|
func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...reflect.Type) (*Schema, error) {
|
||||||
typeName := convert.LowerTitle(t.Name())
|
typeName := convert.LowerTitle(t.Name())
|
||||||
|
|
||||||
@ -75,8 +141,13 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
mapper := s.mapper(&schema.Version, schema.ID)
|
mappers := s.mapper(&schema.Version, schema.ID)
|
||||||
if mapper != nil {
|
if schema.CanList() {
|
||||||
|
mappers = append(s.DefaultMappers, mappers...)
|
||||||
|
}
|
||||||
|
mappers = append(mappers, s.DefaultPostMappers...)
|
||||||
|
|
||||||
|
if len(mappers) > 0 {
|
||||||
copy, err := s.newSchemaFromType(version, t, typeName)
|
copy, err := s.newSchemaFromType(version, t, typeName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -90,14 +161,16 @@ func (s *Schemas) importType(version *APIVersion, t reflect.Type, overrides ...r
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if mapper == nil {
|
mapper := &typeMapper{
|
||||||
mapper = &TypeMapper{}
|
Mappers: mappers,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := mapper.ModifySchema(schema, s); err != nil {
|
if err := mapper.ModifySchema(schema, s); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.setupFilters(schema)
|
||||||
|
|
||||||
schema.Mapper = mapper
|
schema.Mapper = mapper
|
||||||
s.AddSchema(schema)
|
s.AddSchema(schema)
|
||||||
|
|
||||||
@ -114,6 +187,9 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasType := false
|
||||||
|
hasMeta := false
|
||||||
|
|
||||||
for i := 0; i < t.NumField(); i++ {
|
for i := 0; i < t.NumField(); i++ {
|
||||||
field := t.Field(i)
|
field := t.Field(i)
|
||||||
|
|
||||||
@ -128,12 +204,23 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if field.Anonymous && jsonName == "" && field.Type == typeType {
|
||||||
|
hasType = true
|
||||||
|
}
|
||||||
|
|
||||||
|
if field.Anonymous && jsonName == "metadata" && field.Type == metaType {
|
||||||
|
hasMeta = true
|
||||||
|
}
|
||||||
|
|
||||||
if field.Anonymous && jsonName == "" {
|
if field.Anonymous && jsonName == "" {
|
||||||
t := field.Type
|
t := field.Type
|
||||||
if t.Kind() == reflect.Ptr {
|
if t.Kind() == reflect.Ptr {
|
||||||
t = t.Elem()
|
t = t.Elem()
|
||||||
}
|
}
|
||||||
if t.Kind() == reflect.Struct {
|
if t.Kind() == reflect.Struct {
|
||||||
|
if t == namespacedType {
|
||||||
|
schema.Scope = NamespaceScope
|
||||||
|
}
|
||||||
if err := s.readFields(schema, t); err != nil {
|
if err := s.readFields(schema, t); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -144,6 +231,9 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
fieldName := jsonName
|
fieldName := jsonName
|
||||||
if fieldName == "" {
|
if fieldName == "" {
|
||||||
fieldName = convert.LowerTitle(field.Name)
|
fieldName = convert.LowerTitle(field.Name)
|
||||||
|
if strings.HasSuffix(fieldName, "ID") {
|
||||||
|
fieldName = strings.TrimSuffix(fieldName, "ID") + "Id"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if blacklistNames[fieldName] {
|
if blacklistNames[fieldName] {
|
||||||
@ -156,6 +246,7 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
schemaField := Field{
|
schemaField := Field{
|
||||||
Create: true,
|
Create: true,
|
||||||
Update: true,
|
Update: true,
|
||||||
|
Nullable: true,
|
||||||
CodeName: field.Name,
|
CodeName: field.Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,15 +268,15 @@ func (s *Schemas) readFields(schema *Schema, t reflect.Type) error {
|
|||||||
schemaField.Type = inferedType
|
schemaField.Type = inferedType
|
||||||
}
|
}
|
||||||
|
|
||||||
if field.Type == metaType {
|
|
||||||
schema.CollectionMethods = []string{"GET", "POST"}
|
|
||||||
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
|
||||||
}
|
|
||||||
|
|
||||||
logrus.Debugf("Setting field %s.%s: %#v", schema.ID, fieldName, schemaField)
|
logrus.Debugf("Setting field %s.%s: %#v", schema.ID, fieldName, schemaField)
|
||||||
schema.ResourceFields[fieldName] = schemaField
|
schema.ResourceFields[fieldName] = schemaField
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if hasType && hasMeta {
|
||||||
|
schema.CollectionMethods = []string{"GET", "POST"}
|
||||||
|
schema.ResourceMethods = []string{"GET", "PUT", "DELETE"}
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
vendor/github.com/rancher/norman/types/schema_funcs.go
generated
vendored
Normal file
26
vendor/github.com/rancher/norman/types/schema_funcs.go
generated
vendored
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package types
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/rancher/norman/types/slice"
|
||||||
|
)
|
||||||
|
|
||||||
|
func (s *Schema) MustCustomizeField(name string, f func(f Field) Field) *Schema {
|
||||||
|
field, ok := s.ResourceFields[name]
|
||||||
|
if !ok {
|
||||||
|
panic("Failed to find field " + name + " on schema " + s.ID)
|
||||||
|
}
|
||||||
|
s.ResourceFields[name] = f(field)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
func (v *APIVersion) Equals(other *APIVersion) bool {
|
||||||
|
return v.Version == other.Version &&
|
||||||
|
v.Group == other.Group &&
|
||||||
|
v.Path == other.Path
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schema) CanList() bool {
|
||||||
|
return slice.ContainsString(s.CollectionMethods, http.MethodGet)
|
||||||
|
}
|
58
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
58
vendor/github.com/rancher/norman/types/schemas.go
generated
vendored
@ -13,25 +13,43 @@ type SchemaCollection struct {
|
|||||||
Data []Schema
|
Data []Schema
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SchemaInitFunc func(*Schemas) *Schemas
|
||||||
|
|
||||||
type Schemas struct {
|
type Schemas struct {
|
||||||
schemasByPath map[string]map[string]*Schema
|
schemasByPath map[string]map[string]*Schema
|
||||||
mappers map[string]map[string]Mapper
|
schemasBySubContext map[string]*Schema
|
||||||
versions []APIVersion
|
mappers map[string]map[string][]Mapper
|
||||||
schemas []*Schema
|
DefaultMappers []Mapper
|
||||||
errors []error
|
DefaultPostMappers []Mapper
|
||||||
|
versions []APIVersion
|
||||||
|
schemas []*Schema
|
||||||
|
errors []error
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSchemas() *Schemas {
|
func NewSchemas() *Schemas {
|
||||||
return &Schemas{
|
return &Schemas{
|
||||||
schemasByPath: map[string]map[string]*Schema{},
|
schemasByPath: map[string]map[string]*Schema{},
|
||||||
mappers: map[string]map[string]Mapper{},
|
schemasBySubContext: map[string]*Schema{},
|
||||||
|
mappers: map[string]map[string][]Mapper{},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) Init(initFunc SchemaInitFunc) *Schemas {
|
||||||
|
return initFunc(s)
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) Err() error {
|
func (s *Schemas) Err() error {
|
||||||
return NewErrors(s.errors)
|
return NewErrors(s.errors)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) SubContext(subContext string) *Schema {
|
||||||
|
return s.schemasBySubContext[subContext]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (s *Schemas) SubContextSchemas() map[string]*Schema {
|
||||||
|
return s.schemasBySubContext
|
||||||
|
}
|
||||||
|
|
||||||
func (s *Schemas) AddSchemas(schema *Schemas) *Schemas {
|
func (s *Schemas) AddSchemas(schema *Schemas) *Schemas {
|
||||||
for _, schema := range schema.Schemas() {
|
for _, schema := range schema.Schemas() {
|
||||||
s.AddSchema(schema)
|
s.AddSchema(schema)
|
||||||
@ -40,7 +58,7 @@ func (s *Schemas) AddSchemas(schema *Schemas) *Schemas {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
||||||
schema.Type = "schema"
|
schema.Type = "/v1-meta/schemas/schema"
|
||||||
if schema.ID == "" {
|
if schema.ID == "" {
|
||||||
s.errors = append(s.errors, fmt.Errorf("ID is not set on schema: %v", schema))
|
s.errors = append(s.errors, fmt.Errorf("ID is not set on schema: %v", schema))
|
||||||
return s
|
return s
|
||||||
@ -58,6 +76,9 @@ func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
|||||||
if schema.CodeNamePlural == "" {
|
if schema.CodeNamePlural == "" {
|
||||||
schema.CodeNamePlural = name.GuessPluralName(schema.CodeName)
|
schema.CodeNamePlural = name.GuessPluralName(schema.CodeName)
|
||||||
}
|
}
|
||||||
|
if schema.BaseType == "" {
|
||||||
|
schema.BaseType = schema.ID
|
||||||
|
}
|
||||||
|
|
||||||
schemas, ok := s.schemasByPath[schema.Version.Path]
|
schemas, ok := s.schemasByPath[schema.Version.Path]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -71,20 +92,21 @@ func (s *Schemas) AddSchema(schema *Schema) *Schemas {
|
|||||||
s.schemas = append(s.schemas, schema)
|
s.schemas = append(s.schemas, schema)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if schema.SubContext != "" {
|
||||||
|
s.schemasBySubContext[schema.SubContext] = schema
|
||||||
|
}
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) AddMapper(version *APIVersion, schemaID string, mapper Mapper) *Schemas {
|
func (s *Schemas) AddMapper(version *APIVersion, schemaID string, mapper Mapper) *Schemas {
|
||||||
mappers, ok := s.mappers[version.Path]
|
mappers, ok := s.mappers[version.Path]
|
||||||
if !ok {
|
if !ok {
|
||||||
mappers = map[string]Mapper{}
|
mappers = map[string][]Mapper{}
|
||||||
s.mappers[version.Path] = mappers
|
s.mappers[version.Path] = mappers
|
||||||
}
|
}
|
||||||
|
|
||||||
if _, ok := mappers[schemaID]; !ok {
|
mappers[schemaID] = append(mappers[schemaID], mapper)
|
||||||
mappers[schemaID] = mapper
|
|
||||||
}
|
|
||||||
|
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +122,7 @@ func (s *Schemas) Schemas() []*Schema {
|
|||||||
return s.schemas
|
return s.schemas
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Schemas) mapper(version *APIVersion, name string) Mapper {
|
func (s *Schemas) mapper(version *APIVersion, name string) []Mapper {
|
||||||
var (
|
var (
|
||||||
path string
|
path string
|
||||||
)
|
)
|
||||||
@ -133,10 +155,10 @@ func (s *Schemas) Schema(version *APIVersion, name string) *Schema {
|
|||||||
path string
|
path string
|
||||||
)
|
)
|
||||||
|
|
||||||
if strings.Contains(name, "/") {
|
if strings.Contains(name, "/schemas/") {
|
||||||
idx := strings.LastIndex(name, "/")
|
parts := strings.SplitN(name, "/schemas/", 2)
|
||||||
path = name[0:idx]
|
path = parts[0]
|
||||||
name = name[idx+1:]
|
name = parts[1]
|
||||||
} else if version != nil {
|
} else if version != nil {
|
||||||
path = version.Path
|
path = version.Path
|
||||||
} else {
|
} else {
|
||||||
|
82
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
82
vendor/github.com/rancher/norman/types/server_types.go
generated
vendored
@ -27,12 +27,14 @@ func (r *RawResource) MarshalJSON() ([]byte, error) {
|
|||||||
if r.ID != "" {
|
if r.ID != "" {
|
||||||
data["id"] = r.ID
|
data["id"] = r.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
data["type"] = r.Type
|
data["type"] = r.Type
|
||||||
|
data["baseType"] = r.Schema.BaseType
|
||||||
data["links"] = r.Links
|
data["links"] = r.Links
|
||||||
if r.ActionLinks {
|
if r.ActionLinks {
|
||||||
data["actionLinks"] = r.Actions
|
data["actionLinks"] = r.Actions
|
||||||
} else {
|
} else {
|
||||||
data["action"] = r.Actions
|
data["actions"] = r.Actions
|
||||||
}
|
}
|
||||||
return json.Marshal(data)
|
return json.Marshal(data)
|
||||||
}
|
}
|
||||||
@ -41,12 +43,19 @@ type ActionHandler func(actionName string, action *Action, request *APIContext)
|
|||||||
|
|
||||||
type RequestHandler func(request *APIContext) error
|
type RequestHandler func(request *APIContext) error
|
||||||
|
|
||||||
|
type QueryFilter func(opts QueryOptions, data []map[string]interface{}) []map[string]interface{}
|
||||||
|
|
||||||
type Validator func(request *APIContext, data map[string]interface{}) error
|
type Validator func(request *APIContext, data map[string]interface{}) error
|
||||||
|
|
||||||
type Formatter func(request *APIContext, resource *RawResource)
|
type Formatter func(request *APIContext, resource *RawResource)
|
||||||
|
|
||||||
type ErrorHandler func(request *APIContext, err error)
|
type ErrorHandler func(request *APIContext, err error)
|
||||||
|
|
||||||
|
type SubContextAttributeProvider interface {
|
||||||
|
Query(apiContext *APIContext, schema *Schema) []*QueryCondition
|
||||||
|
Create(apiContext *APIContext, schema *Schema) map[string]interface{}
|
||||||
|
}
|
||||||
|
|
||||||
type ResponseWriter interface {
|
type ResponseWriter interface {
|
||||||
Write(apiContext *APIContext, code int, obj interface{})
|
Write(apiContext *APIContext, code int, obj interface{})
|
||||||
}
|
}
|
||||||
@ -57,22 +66,24 @@ type AccessControl interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type APIContext struct {
|
type APIContext struct {
|
||||||
Action string
|
Action string
|
||||||
ID string
|
ID string
|
||||||
Type string
|
Type string
|
||||||
Link string
|
Link string
|
||||||
Method string
|
Method string
|
||||||
Schema *Schema
|
Schema *Schema
|
||||||
Schemas *Schemas
|
Schemas *Schemas
|
||||||
Version *APIVersion
|
Version *APIVersion
|
||||||
ResponseFormat string
|
ResponseFormat string
|
||||||
ReferenceValidator ReferenceValidator
|
ReferenceValidator ReferenceValidator
|
||||||
ResponseWriter ResponseWriter
|
ResponseWriter ResponseWriter
|
||||||
QueryOptions *QueryOptions
|
QueryFilter QueryFilter
|
||||||
Body map[string]interface{}
|
SubContextAttributeProvider SubContextAttributeProvider
|
||||||
URLBuilder URLBuilder
|
//QueryOptions *QueryOptions
|
||||||
AccessControl AccessControl
|
URLBuilder URLBuilder
|
||||||
SubContext map[string]interface{}
|
AccessControl AccessControl
|
||||||
|
SubContext map[string]string
|
||||||
|
Attributes map[string]interface{}
|
||||||
|
|
||||||
Request *http.Request
|
Request *http.Request
|
||||||
Response http.ResponseWriter
|
Response http.ResponseWriter
|
||||||
@ -82,6 +93,30 @@ func (r *APIContext) WriteResponse(code int, obj interface{}) {
|
|||||||
r.ResponseWriter.Write(r, code, obj)
|
r.ResponseWriter.Write(r, code, obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (r *APIContext) FilterList(opts QueryOptions, obj []map[string]interface{}) []map[string]interface{} {
|
||||||
|
return r.QueryFilter(opts, obj)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *APIContext) FilterObject(opts QueryOptions, obj map[string]interface{}) map[string]interface{} {
|
||||||
|
opts.Pagination = nil
|
||||||
|
result := r.QueryFilter(opts, []map[string]interface{}{obj})
|
||||||
|
if len(result) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return result[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *APIContext) Filter(opts QueryOptions, obj interface{}) interface{} {
|
||||||
|
switch v := obj.(type) {
|
||||||
|
case []map[string]interface{}:
|
||||||
|
return r.FilterList(opts, v)
|
||||||
|
case map[string]interface{}:
|
||||||
|
return r.FilterObject(opts, v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ASC = SortOrder("asc")
|
ASC = SortOrder("asc")
|
||||||
DESC = SortOrder("desc")
|
DESC = SortOrder("desc")
|
||||||
@ -100,20 +135,21 @@ type ReferenceValidator interface {
|
|||||||
|
|
||||||
type URLBuilder interface {
|
type URLBuilder interface {
|
||||||
Current() string
|
Current() string
|
||||||
Collection(schema *Schema) string
|
Collection(schema *Schema, versionOverride *APIVersion) string
|
||||||
|
SubContextCollection(subContext *Schema, contextName string, schema *Schema) string
|
||||||
|
SchemaLink(schema *Schema) string
|
||||||
ResourceLink(resource *RawResource) string
|
ResourceLink(resource *RawResource) string
|
||||||
RelativeToRoot(path string) string
|
RelativeToRoot(path string) string
|
||||||
//Link(resource Resource, name string) string
|
Version(version APIVersion) string
|
||||||
//ReferenceLink(resource Resource) string
|
Marker(marker string) string
|
||||||
//ReferenceByIdLink(resourceType string, id string) string
|
|
||||||
Version(version string) string
|
|
||||||
ReverseSort(order SortOrder) string
|
ReverseSort(order SortOrder) string
|
||||||
|
Sort(field string) string
|
||||||
SetSubContext(subContext string)
|
SetSubContext(subContext string)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Store interface {
|
type Store interface {
|
||||||
ByID(apiContext *APIContext, schema *Schema, id string) (map[string]interface{}, error)
|
ByID(apiContext *APIContext, schema *Schema, id string) (map[string]interface{}, error)
|
||||||
List(apiContext *APIContext, schema *Schema, opt *QueryOptions) ([]map[string]interface{}, error)
|
List(apiContext *APIContext, schema *Schema, opt QueryOptions) ([]map[string]interface{}, error)
|
||||||
Create(apiContext *APIContext, schema *Schema, data map[string]interface{}) (map[string]interface{}, error)
|
Create(apiContext *APIContext, schema *Schema, data map[string]interface{}) (map[string]interface{}, error)
|
||||||
Update(apiContext *APIContext, schema *Schema, data map[string]interface{}, id string) (map[string]interface{}, error)
|
Update(apiContext *APIContext, schema *Schema, data map[string]interface{}, id string) (map[string]interface{}, error)
|
||||||
Delete(apiContext *APIContext, schema *Schema, id string) error
|
Delete(apiContext *APIContext, schema *Schema, id string) error
|
||||||
|
10
vendor/github.com/rancher/norman/types/slice/contains.go
generated
vendored
Normal file
10
vendor/github.com/rancher/norman/types/slice/contains.go
generated
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
package slice
|
||||||
|
|
||||||
|
func ContainsString(slice []string, item string) bool {
|
||||||
|
for _, j := range slice {
|
||||||
|
if j == item {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
29
vendor/github.com/rancher/norman/types/types.go
generated
vendored
29
vendor/github.com/rancher/norman/types/types.go
generated
vendored
@ -27,12 +27,23 @@ type Sort struct {
|
|||||||
Name string `json:"name,omitempty"`
|
Name string `json:"name,omitempty"`
|
||||||
Order SortOrder `json:"order,omitempty"`
|
Order SortOrder `json:"order,omitempty"`
|
||||||
Reverse string `json:"reverse,omitempty"`
|
Reverse string `json:"reverse,omitempty"`
|
||||||
Links map[string]string `json:"sortLinks,omitempty"`
|
Links map[string]string `json:"links,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
ModifierEQ ModifierType = "eq"
|
||||||
|
ModifierNE ModifierType = "ne"
|
||||||
|
ModifierNull ModifierType = "null"
|
||||||
|
ModifierNotNull ModifierType = "notnull"
|
||||||
|
ModifierIn ModifierType = "in"
|
||||||
|
ModifierNotIn ModifierType = "notin"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ModifierType string
|
||||||
|
|
||||||
type Condition struct {
|
type Condition struct {
|
||||||
Modifier string `json:"modifier,omitempty"`
|
Modifier ModifierType `json:"modifier,omitempty"`
|
||||||
Value interface{} `json:"value,omitempty"`
|
Value interface{} `json:"value,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Pagination struct {
|
type Pagination struct {
|
||||||
@ -40,6 +51,7 @@ type Pagination struct {
|
|||||||
First string `json:"first,omitempty"`
|
First string `json:"first,omitempty"`
|
||||||
Previous string `json:"previous,omitempty"`
|
Previous string `json:"previous,omitempty"`
|
||||||
Next string `json:"next,omitempty"`
|
Next string `json:"next,omitempty"`
|
||||||
|
Last string `json:"last,omitempty"`
|
||||||
Limit *int64 `json:"limit,omitempty"`
|
Limit *int64 `json:"limit,omitempty"`
|
||||||
Total *int64 `json:"total,omitempty"`
|
Total *int64 `json:"total,omitempty"`
|
||||||
Partial bool `json:"partial,omitempty"`
|
Partial bool `json:"partial,omitempty"`
|
||||||
@ -59,12 +71,20 @@ type APIVersion struct {
|
|||||||
SubContexts map[string]bool `json:"subContext,omitempty"`
|
SubContexts map[string]bool `json:"subContext,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Namespaced struct{}
|
||||||
|
|
||||||
|
var NamespaceScope TypeScope = "namespace"
|
||||||
|
|
||||||
|
type TypeScope string
|
||||||
|
|
||||||
type Schema struct {
|
type Schema struct {
|
||||||
ID string `json:"id,omitempty"`
|
ID string `json:"id,omitempty"`
|
||||||
CodeName string `json:"-"`
|
CodeName string `json:"-"`
|
||||||
CodeNamePlural string `json:"-"`
|
CodeNamePlural string `json:"-"`
|
||||||
PkgName string `json:"-"`
|
PkgName string `json:"-"`
|
||||||
Type string `json:"type,omitempty"`
|
Type string `json:"type,omitempty"`
|
||||||
|
BaseType string `json:"baseType,omitempty"`
|
||||||
|
SubContext string `json:"-,omitempty"`
|
||||||
Links map[string]string `json:"links"`
|
Links map[string]string `json:"links"`
|
||||||
Version APIVersion `json:"version"`
|
Version APIVersion `json:"version"`
|
||||||
PluralName string `json:"pluralName,omitempty"`
|
PluralName string `json:"pluralName,omitempty"`
|
||||||
@ -75,6 +95,7 @@ type Schema struct {
|
|||||||
CollectionFields map[string]Field `json:"collectionFields,omitempty"`
|
CollectionFields map[string]Field `json:"collectionFields,omitempty"`
|
||||||
CollectionActions map[string]Action `json:"collectionActions,omitempty"`
|
CollectionActions map[string]Action `json:"collectionActions,omitempty"`
|
||||||
CollectionFilters map[string]Filter `json:"collectionFilters,omitempty"`
|
CollectionFilters map[string]Filter `json:"collectionFilters,omitempty"`
|
||||||
|
Scope TypeScope `json:"-"`
|
||||||
|
|
||||||
InternalSchema *Schema `json:"-"`
|
InternalSchema *Schema `json:"-"`
|
||||||
Mapper Mapper `json:"-"`
|
Mapper Mapper `json:"-"`
|
||||||
@ -115,7 +136,7 @@ type Action struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Filter struct {
|
type Filter struct {
|
||||||
Modifiers []string `json:"modifiers,omitempty"`
|
Modifiers []ModifierType `json:"modifiers,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ListOpts struct {
|
type ListOpts struct {
|
||||||
|
20
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
20
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/types.go
generated
vendored
@ -107,7 +107,7 @@ type AzureKubernetesServiceConfig struct {
|
|||||||
|
|
||||||
type RancherKubernetesEngineConfig struct {
|
type RancherKubernetesEngineConfig struct {
|
||||||
// Kubernetes nodes
|
// Kubernetes nodes
|
||||||
Hosts []RKEConfigHost `yaml:"hosts" json:"hosts,omitempty"`
|
Nodes []RKEConfigNode `yaml:"nodes" json:"nodes,omitempty"`
|
||||||
// Kubernetes components
|
// Kubernetes components
|
||||||
Services RKEConfigServices `yaml:"services" json:"services,omitempty"`
|
Services RKEConfigServices `yaml:"services" json:"services,omitempty"`
|
||||||
// Network configuration used in the kubernetes cluster (flannel, calico)
|
// Network configuration used in the kubernetes cluster (flannel, calico)
|
||||||
@ -120,18 +120,18 @@ type RancherKubernetesEngineConfig struct {
|
|||||||
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
|
SSHKeyPath string `yaml:"ssh_key_path" json:"sshKeyPath,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RKEConfigHost struct {
|
type RKEConfigNode struct {
|
||||||
// SSH IP address of the host
|
// IP or FQDN that is fully resolvable and used for SSH communication
|
||||||
IP string `yaml:"ip" json:"ip,omitempty"`
|
Address string `yaml:"address" json:"address,omitempty"`
|
||||||
// Advertised address that will be used for components communication
|
// Optional - Internal address that will be used for components communication
|
||||||
AdvertiseAddress string `yaml:"advertise_address" json:"advertiseAddress,omitempty"`
|
InternalAddress string `yaml:"internal_address" json:"internalAddress,omitempty"`
|
||||||
// Host role in kubernetes cluster (controlplane, worker, or etcd)
|
// Node role in kubernetes cluster (controlplane, worker, or etcd)
|
||||||
Role []string `yaml:"role" json:"role,omitempty"`
|
Role []string `yaml:"role" json:"role,omitempty"`
|
||||||
// Hostname of the host
|
// Optional - Hostname of the node
|
||||||
AdvertisedHostname string `yaml:"advertised_hostname" json:"advertisedHostname,omitempty"`
|
HostnameOverride string `yaml:"hostname_override" json:"hostnameOverride,omitempty"`
|
||||||
// SSH usesr that will be used by RKE
|
// SSH usesr that will be used by RKE
|
||||||
User string `yaml:"user" json:"user,omitempty"`
|
User string `yaml:"user" json:"user,omitempty"`
|
||||||
// Docker socket on the host that will be used in tunneling
|
// Optional - Docker socket on the node that will be used in tunneling
|
||||||
DockerSocket string `yaml:"docker_socket" json:"dockerSocket,omitempty"`
|
DockerSocket string `yaml:"docker_socket" json:"dockerSocket,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ type ClusterController interface {
|
|||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
AddHandler(handler ClusterHandlerFunc)
|
AddHandler(handler ClusterHandlerFunc)
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
Start(threadiness int, ctx context.Context) error
|
Start(ctx context.Context, threadiness int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterInterface interface {
|
type ClusterInterface interface {
|
||||||
|
@ -38,7 +38,7 @@ type ClusterNodeController interface {
|
|||||||
Informer() cache.SharedIndexInformer
|
Informer() cache.SharedIndexInformer
|
||||||
AddHandler(handler ClusterNodeHandlerFunc)
|
AddHandler(handler ClusterNodeHandlerFunc)
|
||||||
Enqueue(namespace, name string)
|
Enqueue(namespace, name string)
|
||||||
Start(threadiness int, ctx context.Context) error
|
Start(ctx context.Context, threadiness int) error
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClusterNodeInterface interface {
|
type ClusterNodeInterface interface {
|
||||||
|
14
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_deepcopy.go
generated
vendored
14
vendor/github.com/rancher/types/apis/cluster.cattle.io/v1/zz_generated_deepcopy.go
generated
vendored
@ -445,7 +445,7 @@ func (in *NetworkConfig) DeepCopy() *NetworkConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *RKEConfigHost) DeepCopyInto(out *RKEConfigHost) {
|
func (in *RKEConfigNode) DeepCopyInto(out *RKEConfigNode) {
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Role != nil {
|
if in.Role != nil {
|
||||||
in, out := &in.Role, &out.Role
|
in, out := &in.Role, &out.Role
|
||||||
@ -455,12 +455,12 @@ func (in *RKEConfigHost) DeepCopyInto(out *RKEConfigHost) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RKEConfigHost.
|
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RKEConfigNode.
|
||||||
func (in *RKEConfigHost) DeepCopy() *RKEConfigHost {
|
func (in *RKEConfigNode) DeepCopy() *RKEConfigNode {
|
||||||
if in == nil {
|
if in == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
out := new(RKEConfigHost)
|
out := new(RKEConfigNode)
|
||||||
in.DeepCopyInto(out)
|
in.DeepCopyInto(out)
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
@ -490,9 +490,9 @@ func (in *RKEConfigServices) DeepCopy() *RKEConfigServices {
|
|||||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||||
func (in *RancherKubernetesEngineConfig) DeepCopyInto(out *RancherKubernetesEngineConfig) {
|
func (in *RancherKubernetesEngineConfig) DeepCopyInto(out *RancherKubernetesEngineConfig) {
|
||||||
*out = *in
|
*out = *in
|
||||||
if in.Hosts != nil {
|
if in.Nodes != nil {
|
||||||
in, out := &in.Hosts, &out.Hosts
|
in, out := &in.Nodes, &out.Nodes
|
||||||
*out = make([]RKEConfigHost, len(*in))
|
*out = make([]RKEConfigNode, len(*in))
|
||||||
for i := range *in {
|
for i := range *in {
|
||||||
(*in)[i].DeepCopyInto(&(*out)[i])
|
(*in)[i].DeepCopyInto(&(*out)[i])
|
||||||
}
|
}
|
||||||
|
2
vendor/github.com/rancher/types/vendor.conf
generated
vendored
2
vendor/github.com/rancher/types/vendor.conf
generated
vendored
@ -3,4 +3,4 @@ github.com/rancher/types
|
|||||||
|
|
||||||
k8s.io/kubernetes v1.8.3 transitive=true,staging=true
|
k8s.io/kubernetes v1.8.3 transitive=true,staging=true
|
||||||
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
|
bitbucket.org/ww/goautoneg a547fc61f48d567d5b4ec6f8aee5573d8efce11d https://github.com/rancher/goautoneg.git
|
||||||
github.com/rancher/norman 80024df69414f7cce0847ea72b0557f14edbc852
|
github.com/rancher/norman faa1fb2148211044253fc2f6403008958c72b1f0
|
||||||
|
Loading…
Reference in New Issue
Block a user