Skip to content
Chef-Server API client in golang
Go Shell
Branch: master
Clone or download
Pull request Compare This branch is 10 commits ahead, 1 commit behind go-chef:master.
afiune Merge pull request #6 from chef/mp/cache-cb-downloads
Enable local cache of cookbook contents.
Latest commit 7ac24fb Nov 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples fix up the exampl with correct structure Oct 22, 2014
test New Cookbook Download Feature Oct 15, 2019
.gitignore [bug-fix] Fix Cookbook struct Oct 14, 2019
.studiorc Use checksum to verify cookbook integrity Oct 21, 2019
LICENSE Initial commit May 22, 2014
README.md Use Golang syntax highlighting in the markdown example Jan 19, 2017
acl.go Detect JSON content type Dec 16, 2014
acl_test.go
authentication.go New Service model Aug 4, 2014
build.sh update with new path to tools Feb 24, 2015
client.go Support retrieving client keys May 19, 2017
client_test.go Support retrieving client keys May 19, 2017
cookbook.go New Cookbook Download Feature Oct 15, 2019
cookbook_download.go Do not download cookbook files that are already download Nov 13, 2019
cookbook_download_test.go Do not download cookbook files that are already download Nov 13, 2019
cookbook_test.go Adds GetVersion tests using stretchr/testify Oct 14, 2019
databag.go Implement data bag item create, update, delete Jun 17, 2015
databag_test.go Implement data bag item create, update, delete Jun 17, 2015
debug.go Node 100% complete to the api spec. closes go-chef#35 Oct 6, 2014
doc.go update basic docs closes go-chef#24 Oct 6, 2014
environment.go point all API links to docs.chef.io Apr 8, 2017
environment_test.go Use EnvironmentResult vs CreateReault & ListResult Aug 14, 2014
go.mod Update go.mod to point to our fork Oct 14, 2019
go.sum Adds GetVersion tests using stretchr/testify Oct 14, 2019
group.go Add support for the organizations endpoint Jul 22, 2019
group_test.go Add support for the organizations endpoint Jul 22, 2019
http.go Add support for the /users and /users/USERNAME endpoints Jul 22, 2019
http_test.go Add support for the /users and /users/USERNAME endpoints Jul 22, 2019
node.go Adding node policy_name and policy_group attributes May 17, 2019
node_test.go Clean up the formatted test message syntax May 17, 2019
organization.go Add support for the organizations endpoint Jul 22, 2019
organization_test.go Add support for the organizations endpoint Jul 22, 2019
principal.go point all API links to docs.chef.io Apr 8, 2017
principal_test.go Clean up the formatted test message syntax May 17, 2019
reader.go * Fixed drain bugs Aug 4, 2014
reader_test.go New Service model Aug 4, 2014
release.go Node 100% complete to the api spec. closes go-chef#35 Oct 6, 2014
role.go point all API links to docs.chef.io Apr 8, 2017
role_test.go implement the role delete function. Apr 2, 2016
run_list.go Add documentation for the RunList struct Aug 6, 2019
run_list_test.go New Service model Aug 4, 2014
sandbox.go Fix Json body on Sandoxe Put, so chef server accept the PUT Aug 17, 2015
sandbox_test.go Clean up the formatted test message syntax May 17, 2019
search.go fmt, and add fmt test Jan 24, 2017
search_test.go Clean up the formatted test message syntax May 17, 2019
user.go Add support for the /users and /users/USERNAME endpoints Jul 22, 2019
user_test.go Add support for the /users and /users/USERNAME endpoints Jul 22, 2019
wercker.yml remove irc notify Aug 25, 2017

README.md

Stories in Ready Build Status Coverage Status

Chef Server API Client Library in Golang

This is a Library that you can use to write tools to interact with the chef server.

Install

go get github.com/go-chef/chef

Test

go get -t github.com/go-chef/chef
go test -v github.com/go-chef/chef

SSL

If you run into an SSL verification problem when trying to connect to a ssl server with self signed certs setup your config object with SkipSSL: true

Usage

This example is setting up a basic client that you can use to interact with all the service endpoints (clients, nodes, cookbooks, etc.) More usage examples can be found in the examples directory.

package main

import (
	"fmt"
	"io/ioutil"
	"os"

	"github.com/go-chef/chef"
)

func main() {
	// read a client key
	key, err := ioutil.ReadFile("key.pem")
	if err != nil {
		fmt.Println("Couldn't read key.pem:", err)
		os.Exit(1)
	}

	// build a client
	client, err := chef.NewClient(&chef.Config{
		Name: "foo",
		Key:  string(key),
		// goiardi is on port 4545 by default. chef-zero is 8889
		BaseURL: "http://localhost:4545",
	})
	if err != nil {
		fmt.Println("Issue setting up client:", err)
	}

	// List Cookbooks
	cookList, err := client.Cookbooks.List()
	if err != nil {
		fmt.Println("Issue listing cookbooks:", err)
	}

	// Print out the list
	fmt.Println(cookList)
}

CONTRIBUTING

If you feel like contributing, great! Just fork the repo, make your improvements, and submit a pull request. Tests would, of course, be appreciated. Adding tests where there are no tests currently would be even more appreciated. At least, though, try and not break anything worse than it is. Test coverage has improved, but is still an ongoing concern.

AUTHORS

Jesse Nelson @spheromak
AJ Christensen @fujin
Brad Beam @bradbeam
Kraig Amador @bigkraig

COPYRIGHT

Copyright 2013-2014, Jesse Nelson

LICENSE

Like many Chef ecosystem programs, go-chef/chef is licensed under the Apache 2.0 License. See the LICENSE file for details.

Chef is copyright (c) 2008-2014 Chef, Inc. and its various contributors.

Thanks go out to the fine folks of Opscode and the Chef community for all their hard work.

You can’t perform that action at this time.