1
0
mirror of https://github.com/rancher/types.git synced 2025-09-01 21:32:10 +00:00

update vendor

This commit is contained in:
Daishan Peng
2018-02-27 16:47:43 -07:00
committed by Darren Shepherd
parent ca5555dd00
commit 3cd90ff2f7
5 changed files with 25 additions and 17 deletions

View File

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

View File

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

View File

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

View File

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