diff --git a/vendor.conf b/vendor.conf index 14a49710..67b4fbb9 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 ee25c89cfd450e9256b251d43ecbb7d27670adfa +github.com/rancher/norman a978cad0e8751968fec4371f9ab6df6d446a389b diff --git a/vendor/github.com/rancher/norman/clientbase/common.go b/vendor/github.com/rancher/norman/clientbase/common.go index cfc5760b..73dcb7a0 100644 --- a/vendor/github.com/rancher/norman/clientbase/common.go +++ b/vendor/github.com/rancher/norman/clientbase/common.go @@ -36,6 +36,7 @@ type ClientOpts struct { Timeout time.Duration HTTPClient *http.Client CACerts string + Insecure bool } func (c *ClientOpts) getAuthHeader() string { @@ -176,6 +177,15 @@ func NewAPIClient(opts *ClientOpts) (APIBaseClient, error) { client.Transport = tr } + if opts.Insecure { + tr := &http.Transport{ + TLSClientConfig: &tls.Config{ + InsecureSkipVerify: opts.Insecure, + }, + } + client.Transport = tr + } + req, err := http.NewRequest("GET", opts.URL, nil) if err != nil { return result, err diff --git a/vendor/github.com/rancher/norman/clientbase/ops.go b/vendor/github.com/rancher/norman/clientbase/ops.go index 05a06ba9..f6883e63 100644 --- a/vendor/github.com/rancher/norman/clientbase/ops.go +++ b/vendor/github.com/rancher/norman/clientbase/ops.go @@ -7,7 +7,6 @@ import ( "io" "io/ioutil" "net/http" - "regexp" "github.com/pkg/errors" "github.com/rancher/norman/types" @@ -170,16 +169,9 @@ func (a *APIOperations) DoCreate(schemaType string, createObj interface{}, respO return errors.New("Resource type [" + schemaType + "] is not creatable") } - var collectionURL string - collectionURL, ok = schema.Links[COLLECTION] - if !ok { - // return errors.New("Failed to find collection URL for [" + schemaType + "]") - // This is a hack to address https://github.com/rancher/cattle/issues/254 - re := regexp.MustCompile("schemas.*") - collectionURL = re.ReplaceAllString(schema.Links[SELF], schema.PluralName) - } - - return a.DoModify("POST", collectionURL, createObj, respObject) + // using collection link to post doesn't help the resources under project or cluster, because they need a projectId or clusterId in the path + // for example, v3/projects/foo/apps, v3/cluster/bar/namespaces + return a.DoModify("POST", a.Opts.URL+"/"+schemaType, createObj, respObject) } func (a *APIOperations) DoUpdate(schemaType string, existing *types.Resource, updates interface{}, respObject interface{}) error { diff --git a/vendor/github.com/rancher/norman/generator/funcs.go b/vendor/github.com/rancher/norman/generator/funcs.go index 6af1d3e7..274b43b7 100644 --- a/vendor/github.com/rancher/norman/generator/funcs.go +++ b/vendor/github.com/rancher/norman/generator/funcs.go @@ -11,10 +11,12 @@ import ( func funcs() template.FuncMap { return template.FuncMap{ - "capitalize": convert.Capitalize, - "upper": strings.ToUpper, - "toLower": strings.ToLower, - "hasGet": hasGet, + "capitalize": convert.Capitalize, + "unCapitalize": convert.Uncapitalize, + "upper": strings.ToUpper, + "toLower": strings.ToLower, + "hasGet": hasGet, + "hasPost": hasPost, } } @@ -26,6 +28,10 @@ func hasGet(schema *types.Schema) bool { return contains(schema.CollectionMethods, http.MethodGet) } +func hasPost(schema *types.Schema) bool { + return contains(schema.CollectionMethods, http.MethodPost) +} + func contains(list []string, needle string) bool { for _, i := range list { if i == needle { diff --git a/vendor/github.com/rancher/norman/generator/type_template.go b/vendor/github.com/rancher/norman/generator/type_template.go index 0044c12e..7b28fadf 100644 --- a/vendor/github.com/rancher/norman/generator/type_template.go +++ b/vendor/github.com/rancher/norman/generator/type_template.go @@ -21,7 +21,7 @@ type {{.schema.CodeName}} struct { types.Resource {{- end}} {{- range $key, $value := .structFields}} - {{$key}} {{$value.Type}} %BACK%json:"{{$value.Name}},omitempty"%BACK% + {{$key}} {{$value.Type}} %BACK%json:"{{$value.Name}},omitempty" yaml:"{{$value.Name}},omitempty"%BACK% {{- end}} }