From 19d128e156f8c05ad145e91c924f2ac26bc3e22d Mon Sep 17 00:00:00 2001 From: Dan Ramich Date: Tue, 3 Apr 2018 13:05:21 -0700 Subject: [PATCH] Vendor update --- vendor.conf | 2 +- .../rancher/norman/clientbase/ops.go | 27 ++++++++++++++++++- .../rancher/norman/generator/type_template.go | 24 ++++++++--------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/vendor.conf b/vendor.conf index 6a45ccc0..0cf81729 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 510ed570d2e29a00e6bc1bcd18bdcad6c6860a13 +github.com/rancher/norman 17c297e703d6988ac126b054ad5795606b31d344 diff --git a/vendor/github.com/rancher/norman/clientbase/ops.go b/vendor/github.com/rancher/norman/clientbase/ops.go index 0ea03eb7..ebeccb61 100644 --- a/vendor/github.com/rancher/norman/clientbase/ops.go +++ b/vendor/github.com/rancher/norman/clientbase/ops.go @@ -247,7 +247,32 @@ func (a *APIOperations) DoAction(schemaType string, action string, return fmt.Errorf("action [%v] not available on [%v]", action, existing) } - _, ok = a.Types[schemaType] + return a.doAction(schemaType, action, actionURL, inputObject, respObject) +} + +func (a *APIOperations) DoCollectionAction(schemaType string, action string, + existing *types.Collection, inputObject, respObject interface{}) error { + + if existing == nil { + return errors.New("Existing object is nil") + } + + actionURL, ok := existing.Actions[action] + if !ok { + return fmt.Errorf("action [%v] not available on [%v]", action, existing) + } + + return a.doAction(schemaType, action, actionURL, inputObject, respObject) +} + +func (a *APIOperations) doAction( + schemaType string, + action string, + actionURL string, + inputObject interface{}, + respObject interface{}, +) error { + _, ok := a.Types[schemaType] if !ok { return errors.New("Unknown schema type [" + schemaType + "]") } diff --git a/vendor/github.com/rancher/norman/generator/type_template.go b/vendor/github.com/rancher/norman/generator/type_template.go index b0098671..32ee44cf 100644 --- a/vendor/github.com/rancher/norman/generator/type_template.go +++ b/vendor/github.com/rancher/norman/generator/type_template.go @@ -51,13 +51,13 @@ type {{.schema.CodeName}}Operations interface { {{end}} {{range $key, $value := .collectionActions}} {{if (and (eq $value.Input "") (eq $value.Output ""))}} - Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (error) + Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection) (error) {{else if (and (eq $value.Input "") (ne $value.Output ""))}} - Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) + Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) {{else if (and (ne $value.Input "") (eq $value.Output ""))}} - Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, input *{{$value.Input | capitalize}}) (error) + Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection, input *{{$value.Input | capitalize}}) (error) {{else}} - Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, input *{{$value.Input | capitalize}}) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) + Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection, input *{{$value.Input | capitalize}}) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) {{end}} {{end}} } @@ -125,22 +125,22 @@ func (c *{{.schema.CodeName}}Client) Delete(container *{{.schema.CodeName}}) err {{range $key, $value := .collectionActions}} {{if (and (eq $value.Input "") (eq $value.Output ""))}} - func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (error) { - err := c.apiClient.Ops.DoAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Resource, nil, nil) + func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection) (error) { + err := c.apiClient.Ops.DoCollectionAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Collection, nil, nil) return err {{else if (and (eq $value.Input "") (ne $value.Output ""))}} - func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) { + func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) { resp := &{{getCollectionOutput $value.Output $.schema.CodeName}}{} - err := c.apiClient.Ops.DoAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Resource, nil, resp) + err := c.apiClient.Ops.DoCollectionAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Collection, nil, resp) return resp, err {{else if (and (ne $value.Input "") (eq $value.Output ""))}} - func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, input *{{$value.Input | capitalize}}) (error) { - err := c.apiClient.Ops.DoAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Resource, input, nil) + func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection, input *{{$value.Input | capitalize}}) (error) { + err := c.apiClient.Ops.DoCollectionAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Collection, input, nil) return err {{else}} - func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, input *{{$value.Input | capitalize}}) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) { + func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}Collection, input *{{$value.Input | capitalize}}) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error) { resp := &{{getCollectionOutput $value.Output $.schema.CodeName}}{} - err := c.apiClient.Ops.DoAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Resource, input, resp) + err := c.apiClient.Ops.DoCollectionAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Collection, input, resp) return resp, err {{end}} }