Skip to content

Commit

Permalink
Merge pull request #62 from pascallap/environment_cookbooks
Browse files Browse the repository at this point in the history
Implementation of: listing cookbooks in a given environment
  • Loading branch information
spheromak committed Aug 9, 2015
2 parents 19b2553 + 19973ec commit 98983e8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type Environment struct {
CookbookVersions map[string]string `json:"cookbook_versions"`
}

type EnvironmentCookbookResult map[string]CookbookVersions

func strMapToStr(e map[string]string) (out string) {
keys := make([]string, len(e))
for k, _ := range e {
Expand Down Expand Up @@ -93,6 +95,11 @@ func (e *EnvironmentService) Put(environment *Environment) (data *Environment, e
// Get the versions of a cookbook for this environment from the Chef server.
//
// Chef API docs: http://docs.getchef.com/api_chef_server.html#id19
func (e *EnvironmentService) ListCookbooks(name string, numVersions string) (data EnvironmentCookbookResult, err error) {
path := versionParams(fmt.Sprintf("environments/%s/cookbooks", name), numVersions)
err = e.client.magicRequestDecoder("GET", path, nil, &data)
return
}

// Get a hash of cookbooks and cookbook versions (including all dependencies) that
// are required by the run_list array. Version constraints may be specified using
Expand Down

0 comments on commit 98983e8

Please sign in to comment.