From 36b4b1acb2e3340eaf7369916d08fd8bdf9bd8d2 Mon Sep 17 00:00:00 2001 From: Donald Guy Date: Mon, 22 Aug 2016 18:58:31 -0400 Subject: [PATCH] vendor: update go-chef, fixes #8382 --- vendor/github.com/go-chef/chef/.gitignore | 25 ---------------- vendor/github.com/go-chef/chef/build.sh | 0 vendor/github.com/go-chef/chef/cookbook.go | 14 ++++++++- vendor/github.com/go-chef/chef/http.go | 25 +++++++++++----- vendor/github.com/go-chef/chef/node.go | 16 +++++----- vendor/github.com/go-chef/chef/principal.go | 33 +++++++++++++++++++++ vendor/github.com/go-chef/chef/role.go | 5 ++++ vendor/github.com/go-chef/chef/wercker.yml | 26 ++++++---------- vendor/vendor.json | 4 ++- 9 files changed, 88 insertions(+), 60 deletions(-) delete mode 100644 vendor/github.com/go-chef/chef/.gitignore mode change 100644 => 100755 vendor/github.com/go-chef/chef/build.sh create mode 100644 vendor/github.com/go-chef/chef/principal.go diff --git a/vendor/github.com/go-chef/chef/.gitignore b/vendor/github.com/go-chef/chef/.gitignore deleted file mode 100644 index 3aeb2e2a1110..000000000000 --- a/vendor/github.com/go-chef/chef/.gitignore +++ /dev/null @@ -1,25 +0,0 @@ -# Compiled Object files, Static and Dynamic libs (Shared Objects) -*.o -*.a -*.so - -# Folders -_obj -_test - -coverage -coverage.* -# Architecture specific extensions/prefixes -*.[568vq] -[568vq].out - -*.cgo1.go -*.cgo2.c -_cgo_defun.c -_cgo_gotypes.go -_cgo_export.* - -_testmain.go - -*.exe -*.test diff --git a/vendor/github.com/go-chef/chef/build.sh b/vendor/github.com/go-chef/chef/build.sh old mode 100644 new mode 100755 diff --git a/vendor/github.com/go-chef/chef/cookbook.go b/vendor/github.com/go-chef/chef/cookbook.go index 1a725bfbfe4f..cbede1e51358 100644 --- a/vendor/github.com/go-chef/chef/cookbook.go +++ b/vendor/github.com/go-chef/chef/cookbook.go @@ -20,6 +20,10 @@ type CookbookItem struct { // http://docs.opscode.com/api_chef_server.html#cookbooks type CookbookListResult map[string]CookbookVersions +// CookbookRecipesResult is the summary info returned by chef-api when listing +// http://docs.opscode.com/api_chef_server.html#cookbooks-recipes +type CookbookRecipesResult []string + // CookbookVersions is the data container returned from the chef server when listing all cookbooks type CookbookVersions struct { Url string `json:"url,omitempty"` @@ -131,6 +135,14 @@ func (c *CookbookService) ListAvailableVersions(numVersions string) (data Cookbo return } +// ListAllRecipes lists the names of all recipes in the most recent cookbook versions +// Chef API docs: https://docs.chef.io/api_chef_server.html#id31 +func (c *CookbookService) ListAllRecipes() (data CookbookRecipesResult, err error) { + path := "cookbooks/_recipes" + err = c.client.magicRequestDecoder("GET", path, nil, &data) + return +} + // List returns a CookbookListResult with the latest versions of cookbooks available on the server func (c *CookbookService) List() (CookbookListResult, error) { return c.ListAvailableVersions("") @@ -138,7 +150,7 @@ func (c *CookbookService) List() (CookbookListResult, error) { // DeleteVersion removes a version of a cook from a server func (c *CookbookService) Delete(name, version string) (err error) { - path := fmt.Sprintf("cookbooks/%s", name) + path := fmt.Sprintf("cookbooks/%s/%s", name, version) err = c.client.magicRequestDecoder("DELETE", path, nil, nil) return } diff --git a/vendor/github.com/go-chef/chef/http.go b/vendor/github.com/go-chef/chef/http.go index f2981a3fc59f..d539955d096d 100644 --- a/vendor/github.com/go-chef/chef/http.go +++ b/vendor/github.com/go-chef/chef/http.go @@ -45,6 +45,7 @@ type Client struct { DataBags *DataBagService Environments *EnvironmentService Nodes *NodeService + Principals *PrincipalService Roles *RoleService Sandboxes *SandboxService Search *SearchService @@ -148,6 +149,7 @@ func NewClient(cfg *Config) (*Client, error) { c.DataBags = &DataBagService{client: c} c.Environments = &EnvironmentService{client: c} c.Nodes = &NodeService{client: c} + c.Principals = &PrincipalService{client: c} c.Roles = &RoleService{client: c} c.Sandboxes = &SandboxService{client: c} c.Search = &SearchService{client: c} @@ -258,18 +260,25 @@ func (ac AuthConfig) SignRequest(request *http.Request) error { endpoint = request.URL.Path } - request.Header.Set("Method", request.Method) - request.Header.Set("Hashed Path", HashStr(endpoint)) - request.Header.Set("Accept", "application/json") - request.Header.Set("X-Chef-Version", ChefVersion) - request.Header.Set("X-Ops-Timestamp", time.Now().UTC().Format(time.RFC3339)) - request.Header.Set("X-Ops-UserId", ac.ClientName) - request.Header.Set("X-Ops-Sign", "algorithm=sha1;version=1.0") + vals := map[string]string{ + "Method": request.Method, + "Hashed Path": HashStr(endpoint), + "Accept": "application/json", + "X-Chef-Version": ChefVersion, + "X-Ops-Timestamp": time.Now().UTC().Format(time.RFC3339), + "X-Ops-UserId": ac.ClientName, + "X-Ops-Sign": "algorithm=sha1;version=1.0", + "X-Ops-Content-Hash": request.Header.Get("X-Ops-Content-Hash"), + } + + for _, key := range []string{"Method", "Accept", "X-Chef-Version", "X-Ops-Timestamp", "X-Ops-UserId", "X-Ops-Sign"} { + request.Header.Set(key, vals[key]) + } // To validate the signature it seems to be very particular var content string for _, key := range []string{"Method", "Hashed Path", "X-Ops-Content-Hash", "X-Ops-Timestamp", "X-Ops-UserId"} { - content += fmt.Sprintf("%s:%s\n", key, request.Header.Get(key)) + content += fmt.Sprintf("%s:%s\n", key, vals[key]) } content = strings.TrimSuffix(content, "\n") // generate signed string of headers diff --git a/vendor/github.com/go-chef/chef/node.go b/vendor/github.com/go-chef/chef/node.go index 53ef1def8581..e884ac262b4d 100644 --- a/vendor/github.com/go-chef/chef/node.go +++ b/vendor/github.com/go-chef/chef/node.go @@ -9,14 +9,14 @@ type NodeService struct { // Node represents the native Go version of the deserialized Node type type Node struct { Name string `json:"name"` - Environment string `json:"chef_environment"` - ChefType string `json:"chef_type"` - AutomaticAttributes map[string]interface{} `json:"automatic"` - NormalAttributes map[string]interface{} `json:"normal"` - DefaultAttributes map[string]interface{} `json:"default"` - OverrideAttributes map[string]interface{} `json:"override"` - JsonClass string `json:"json_class"` - RunList []string `json:"run_list"` + Environment string `json:"chef_environment,omitempty"` + ChefType string `json:"chef_type,omitempty"` + AutomaticAttributes map[string]interface{} `json:"automatic,omitempty"` + NormalAttributes map[string]interface{} `json:"normal,omitempty"` + DefaultAttributes map[string]interface{} `json:"default,omitempty"` + OverrideAttributes map[string]interface{} `json:"override,omitempty"` + JsonClass string `json:"json_class,omitempty"` + RunList []string `json:"run_list,omitempty"` } type NodeResult struct { diff --git a/vendor/github.com/go-chef/chef/principal.go b/vendor/github.com/go-chef/chef/principal.go new file mode 100644 index 000000000000..0b57f6c8c8ba --- /dev/null +++ b/vendor/github.com/go-chef/chef/principal.go @@ -0,0 +1,33 @@ +package chef + +import "fmt" + +type PrincipalService struct { + client *Client +} + +// Principal represents the native Go version of the deserialized Principal type +type Principal struct { + Name string `json:"name"` + Type string `json:"type"` + PublicKey string `json:"public_key"` + AuthzId string `json:"authz_id"` + OrgMember bool `json:"org_member"` +} + +func NewPrincipal(name, typ, publicKey string) Principal { + return Principal{ + Name: name, + Type: typ, + PublicKey: publicKey, + } +} + +// Get gets a principal from the Chef server. +// +// Chef API docs: https://docs.chef.io/api_chef_server.html#id64 +func (e *PrincipalService) Get(name string) (principal Principal, err error) { + url := fmt.Sprintf("principals/%s", name) + err = e.client.magicRequestDecoder("GET", url, nil, &principal) + return +} diff --git a/vendor/github.com/go-chef/chef/role.go b/vendor/github.com/go-chef/chef/role.go index eaad0efe54d2..b6fe08b88416 100644 --- a/vendor/github.com/go-chef/chef/role.go +++ b/vendor/github.com/go-chef/chef/role.go @@ -62,6 +62,11 @@ func (e *RoleService) Create(role *Role) (data *RoleCreateResult, err error) { // Delete a role from the Chef server. // // Chef API docs: http://docs.getchef.com/api_chef_server.html#id33 +func (e *RoleService) Delete(name string) (err error) { + path := fmt.Sprintf("roles/%s", name) + err = e.client.magicRequestDecoder("DELETE", path, nil, nil) + return +} // Get gets a role from the Chef server. // diff --git a/vendor/github.com/go-chef/chef/wercker.yml b/vendor/github.com/go-chef/chef/wercker.yml index f688951a2b0f..a42d35e14e16 100644 --- a/vendor/github.com/go-chef/chef/wercker.yml +++ b/vendor/github.com/go-chef/chef/wercker.yml @@ -17,31 +17,23 @@ build: - script: name: Get dependencies - code: | + code: | go get -u github.com/ctdk/goiardi/chefcrypto - go get -u github.com/ctdk/goiardi/authentication + go get -u github.com/ctdk/goiardi/authentication go get -u github.com/davecgh/go-spew/spew - go get -u github.com/smartystreets/goconvey/convey - go get -u github.com/axw/gocov/gocov - go get -u github.com/matm/gocov-html + go get -u github.com/smartystreets/goconvey/convey go get -u github.com/mattn/goveralls - # Using the gocov tool to test the exact package we want to test from GOPATH + # Using the gocov tool to test the exact package we want to test from GOPATH - script: name: Test code: | - gocov test github.com/go-chef/chef > coverage.json - - - script: - name: Coverage - code: | - gocov report coverage.json - gocov-html coverage.json > $WERCKER_REPORT_ARTIFACTS_DIR/coverage.html + go test -covermode=count -coverprofile=profile.cov - - script: - name: Coveralls.io - code: | - goveralls -service='wercker.com' -repotoken=$COVERALLS_TOKEN -gocovdata=coverage.json + # - script: + # name: Coveralls.io + # code: | + # goveralls -service='wercker.com' -repotoken=$COVERALLS_TOKEN -coverprofile=profile.cov - script: name: Store cache diff --git a/vendor/vendor.json b/vendor/vendor.json index f1401fc404e6..bff0007e1e3a 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -1032,9 +1032,11 @@ "revision": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" }, { + "checksumSHA1": "JKjnR1ApU6NcC79xcGaT7QRMx3A=", "comment": "0.0.1-42-gea19666", "path": "github.com/go-chef/chef", - "revision": "ea196660dd8700ad18911681b223fe6bfc29cd69" + "revision": "bf4e81635329d7a0fc8d7c858a899a72cdb69b9e", + "revisionTime": "2016-06-30T18:09:21Z" }, { "comment": "v1.8.6",