1
0
mirror of https://github.com/rancher/types.git synced 2025-07-16 06:25:50 +00:00

Update vendor and generated code

This commit is contained in:
Dan Ramich 2018-04-02 11:43:49 -07:00 committed by Craig Jellick
parent 63dc1b6a54
commit 0aa0706b4f
6 changed files with 57 additions and 22 deletions

View File

@ -59,6 +59,8 @@ type PrincipalOperations interface {
Update(existing *Principal, updates interface{}) (*Principal, error)
ByID(id string) (*Principal, error)
Delete(container *Principal) error
ActionSearch(resource *Principal, input *SearchPrincipalsInput) (*PrincipalCollection, error)
}
func newPrincipalClient(apiClient *Client) *PrincipalClient {
@ -105,3 +107,10 @@ func (c *PrincipalClient) ByID(id string) (*Principal, error) {
func (c *PrincipalClient) Delete(container *Principal) error {
return c.apiClient.Ops.DoResourceDelete(PrincipalType, &container.Resource)
}
func (c *PrincipalClient) ActionSearch(resource *Principal, input *SearchPrincipalsInput) (*PrincipalCollection, error) {
resp := &PrincipalCollection{}
err := c.apiClient.Ops.DoAction(PrincipalType, "search", &resource.Resource, input, resp)
return resp, err
}

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 d20a37adbef4e306cb354ad643b2c2d9b1d8a403
github.com/rancher/norman 9f2b71df502fc476603eed99d137593d4a879f53

View File

@ -11,12 +11,13 @@ import (
func funcs() template.FuncMap {
return template.FuncMap{
"capitalize": convert.Capitalize,
"unCapitalize": convert.Uncapitalize,
"upper": strings.ToUpper,
"toLower": strings.ToLower,
"hasGet": hasGet,
"hasPost": hasPost,
"capitalize": convert.Capitalize,
"unCapitalize": convert.Uncapitalize,
"upper": strings.ToUpper,
"toLower": strings.ToLower,
"hasGet": hasGet,
"hasPost": hasPost,
"getCollectionOutput": getCollectionOutput,
}
}
@ -40,3 +41,10 @@ func contains(list []string, needle string) bool {
}
return false
}
func getCollectionOutput(output, codeName string) string {
if output == "collection" {
return codeName + "Collection"
}
return convert.Capitalize(output)
}

View File

@ -126,7 +126,10 @@ func getCollectionActions(schema *types.Schema, schemas *types.Schemas) map[stri
result := map[string]types.Action{}
for name, action := range schema.CollectionActions {
if action.Output != "" {
output := strings.TrimSuffix(action.Output, "Collection")
output := action.Output
if action.Output == "collection" {
output = strings.ToLower(schema.CodeName)
}
if schemas.Schema(&schema.Version, output) != nil {
result[name] = action
}

View File

@ -53,11 +53,11 @@ type {{.schema.CodeName}}Operations interface {
{{if (and (eq $value.Input "") (eq $value.Output ""))}}
Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (error)
{{else if (and (eq $value.Input "") (ne $value.Output ""))}}
Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (*{{.Output | capitalize}}, error)
Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (*{{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)
{{else}}
Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, input *{{$value.Input | capitalize}}) (*{{.Output | capitalize}}, error)
Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, input *{{$value.Input | capitalize}}) (*{{getCollectionOutput $value.Output $.schema.CodeName}}, error)
{{end}}
{{end}}
}
@ -129,8 +129,8 @@ func (c *{{.schema.CodeName}}Client) Delete(container *{{.schema.CodeName}}) err
err := c.apiClient.Ops.DoAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Resource, nil, nil)
return err
{{else if (and (eq $value.Input "") (ne $value.Output ""))}}
func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (*{{.Output | capitalize}}, error) {
resp := &{{.Output | capitalize}}{}
func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}) (*{{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)
return resp, err
{{else if (and (ne $value.Input "") (eq $value.Output ""))}}
@ -138,8 +138,8 @@ func (c *{{.schema.CodeName}}Client) Delete(container *{{.schema.CodeName}}) err
err := c.apiClient.Ops.DoAction({{$.schema.CodeName}}Type, "{{$key}}", &resource.Resource, input, nil)
return err
{{else}}
func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, input *{{$value.Input | capitalize}}) (*{{.Output | capitalize}}, error) {
resp := &{{.Output | capitalize}}{}
func (c *{{$.schema.CodeName}}Client) Action{{$key | capitalize}} (resource *{{$.schema.CodeName}}, 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)
return resp, err
{{end}}

View File

@ -1,6 +1,7 @@
package lifecycle
import (
"fmt"
"reflect"
"github.com/rancher/norman/clientbase"
@ -92,15 +93,10 @@ func (o *objectLifecycleAdapter) finalize(metadata metav1.Object, obj runtime.Ob
copyObj = newObj
}
if err := removeFinalizer(o.constructFinalizerKey(), copyObj); err != nil {
return false, err
}
_, err := o.objectClient.Update(metadata.GetName(), copyObj)
return false, err
return false, o.removeFinalizer(o.constructFinalizerKey(), copyObj)
}
func removeFinalizer(name string, obj runtime.Object) error {
func (o *objectLifecycleAdapter) removeFinalizer(name string, obj runtime.Object) error {
metadata, err := meta.Accessor(obj)
if err != nil {
return err
@ -115,7 +111,26 @@ func removeFinalizer(name string, obj runtime.Object) error {
}
metadata.SetFinalizers(finalizers)
return nil
for i := 0; i < 3; i++ {
_, err := o.objectClient.Update(metadata.GetName(), obj)
if err == nil {
return nil
}
obj, err = o.objectClient.GetNamespaced(metadata.GetNamespace(), metadata.GetName(), metav1.GetOptions{})
if err != nil {
return err
}
metadata, err := meta.Accessor(obj)
if err != nil {
return err
}
metadata.SetFinalizers(finalizers)
}
return fmt.Errorf("failed to remove finalizer on %s:%s", metadata.GetNamespace(), metadata.GetName())
}
func (o *objectLifecycleAdapter) createKey() string {