vendor: update go-chef, fixes #8382

This commit is contained in:
Donald Guy 2016-08-22 18:58:31 -04:00
parent d32487c335
commit 36b4b1acb2
9 changed files with 88 additions and 60 deletions

View File

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

0
vendor/github.com/go-chef/chef/build.sh generated vendored Normal file → Executable file
View File

View File

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

View File

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

View File

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

33
vendor/github.com/go-chef/chef/principal.go generated vendored Normal file
View File

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

View File

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

View File

@ -22,26 +22,18 @@ build:
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/mattn/goveralls
# 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
go test -covermode=count -coverprofile=profile.cov
- script:
name: Coverage
code: |
gocov report coverage.json
gocov-html coverage.json > $WERCKER_REPORT_ARTIFACTS_DIR/coverage.html
- 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

4
vendor/vendor.json vendored
View File

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