Merge pull request #8401 from donaldguy/vendor-update-chef

vendor: update go-chef, fixes #8382
This commit is contained in:
Mitchell Hashimoto 2016-08-25 22:24:03 -07:00 committed by GitHub
commit 16bedd8625
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 // http://docs.opscode.com/api_chef_server.html#cookbooks
type CookbookListResult map[string]CookbookVersions 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 // CookbookVersions is the data container returned from the chef server when listing all cookbooks
type CookbookVersions struct { type CookbookVersions struct {
Url string `json:"url,omitempty"` Url string `json:"url,omitempty"`
@ -131,6 +135,14 @@ func (c *CookbookService) ListAvailableVersions(numVersions string) (data Cookbo
return 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 // List returns a CookbookListResult with the latest versions of cookbooks available on the server
func (c *CookbookService) List() (CookbookListResult, error) { func (c *CookbookService) List() (CookbookListResult, error) {
return c.ListAvailableVersions("") return c.ListAvailableVersions("")
@ -138,7 +150,7 @@ func (c *CookbookService) List() (CookbookListResult, error) {
// DeleteVersion removes a version of a cook from a server // DeleteVersion removes a version of a cook from a server
func (c *CookbookService) Delete(name, version string) (err error) { 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) err = c.client.magicRequestDecoder("DELETE", path, nil, nil)
return return
} }

View File

@ -45,6 +45,7 @@ type Client struct {
DataBags *DataBagService DataBags *DataBagService
Environments *EnvironmentService Environments *EnvironmentService
Nodes *NodeService Nodes *NodeService
Principals *PrincipalService
Roles *RoleService Roles *RoleService
Sandboxes *SandboxService Sandboxes *SandboxService
Search *SearchService Search *SearchService
@ -148,6 +149,7 @@ func NewClient(cfg *Config) (*Client, error) {
c.DataBags = &DataBagService{client: c} c.DataBags = &DataBagService{client: c}
c.Environments = &EnvironmentService{client: c} c.Environments = &EnvironmentService{client: c}
c.Nodes = &NodeService{client: c} c.Nodes = &NodeService{client: c}
c.Principals = &PrincipalService{client: c}
c.Roles = &RoleService{client: c} c.Roles = &RoleService{client: c}
c.Sandboxes = &SandboxService{client: c} c.Sandboxes = &SandboxService{client: c}
c.Search = &SearchService{client: c} c.Search = &SearchService{client: c}
@ -258,18 +260,25 @@ func (ac AuthConfig) SignRequest(request *http.Request) error {
endpoint = request.URL.Path endpoint = request.URL.Path
} }
request.Header.Set("Method", request.Method) vals := map[string]string{
request.Header.Set("Hashed Path", HashStr(endpoint)) "Method": request.Method,
request.Header.Set("Accept", "application/json") "Hashed Path": HashStr(endpoint),
request.Header.Set("X-Chef-Version", ChefVersion) "Accept": "application/json",
request.Header.Set("X-Ops-Timestamp", time.Now().UTC().Format(time.RFC3339)) "X-Chef-Version": ChefVersion,
request.Header.Set("X-Ops-UserId", ac.ClientName) "X-Ops-Timestamp": time.Now().UTC().Format(time.RFC3339),
request.Header.Set("X-Ops-Sign", "algorithm=sha1;version=1.0") "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 // To validate the signature it seems to be very particular
var content string var content string
for _, key := range []string{"Method", "Hashed Path", "X-Ops-Content-Hash", "X-Ops-Timestamp", "X-Ops-UserId"} { 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") content = strings.TrimSuffix(content, "\n")
// generate signed string of headers // 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 // Node represents the native Go version of the deserialized Node type
type Node struct { type Node struct {
Name string `json:"name"` Name string `json:"name"`
Environment string `json:"chef_environment"` Environment string `json:"chef_environment,omitempty"`
ChefType string `json:"chef_type"` ChefType string `json:"chef_type,omitempty"`
AutomaticAttributes map[string]interface{} `json:"automatic"` AutomaticAttributes map[string]interface{} `json:"automatic,omitempty"`
NormalAttributes map[string]interface{} `json:"normal"` NormalAttributes map[string]interface{} `json:"normal,omitempty"`
DefaultAttributes map[string]interface{} `json:"default"` DefaultAttributes map[string]interface{} `json:"default,omitempty"`
OverrideAttributes map[string]interface{} `json:"override"` OverrideAttributes map[string]interface{} `json:"override,omitempty"`
JsonClass string `json:"json_class"` JsonClass string `json:"json_class,omitempty"`
RunList []string `json:"run_list"` RunList []string `json:"run_list,omitempty"`
} }
type NodeResult struct { 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. // Delete a role from the Chef server.
// //
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id33 // 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. // 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/ctdk/goiardi/authentication
go get -u github.com/davecgh/go-spew/spew go get -u github.com/davecgh/go-spew/spew
go get -u github.com/smartystreets/goconvey/convey 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 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: - script:
name: Test name: Test
code: | code: |
gocov test github.com/go-chef/chef > coverage.json go test -covermode=count -coverprofile=profile.cov
- script: # - script:
name: Coverage # name: Coveralls.io
code: | # code: |
gocov report coverage.json # goveralls -service='wercker.com' -repotoken=$COVERALLS_TOKEN -coverprofile=profile.cov
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: - script:
name: Store cache name: Store cache

4
vendor/vendor.json vendored
View File

@ -1040,9 +1040,11 @@
"revision": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b" "revision": "bf97c77db7c945cbcdbf09d56c6f87a66f54537b"
}, },
{ {
"checksumSHA1": "JKjnR1ApU6NcC79xcGaT7QRMx3A=",
"comment": "0.0.1-42-gea19666", "comment": "0.0.1-42-gea19666",
"path": "github.com/go-chef/chef", "path": "github.com/go-chef/chef",
"revision": "ea196660dd8700ad18911681b223fe6bfc29cd69" "revision": "bf4e81635329d7a0fc8d7c858a899a72cdb69b9e",
"revisionTime": "2016-06-30T18:09:21Z"
}, },
{ {
"comment": "v1.8.6", "comment": "v1.8.6",