GithubHelp home page GithubHelp logo

v-andrius / chef Goto Github PK

View Code? Open in Web Editor NEW

This project forked from go-chef/chef

0.0 0.0 0.0 607 KB

Chef-Server API client in golang

Home Page: http://godoc.org/github.com/go-chef/chef

License: Apache License 2.0

Go 87.90% Shell 2.12% Ruby 9.98%

chef's Introduction

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
examples::chefapi_tester kitchen verify 

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. At @chefapi) 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)
}

Chef API Error Status

To get tthhe error status and error message returned from calls to the Chef API Server you cane use ChefError to unwind the ErrorResponse and access the original http error. These methods are available to get specific information from the the error. Error() returns a formatted error message with the URL and status code. StatusCode() returns the original return status code. StatusMsg() returns the error message extracted from the error message body. StatusText() returns the returned error message body, usually JSON. StatusMethod() returns the name of the method used for the request. StatusURL() returns the URL object used for the request.

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
Mark Gibbons @mark

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.

chef's People

Contributors

markgibbons avatar spheromak avatar mudash avatar bigkraig avatar marcparadise avatar tyler-ball avatar radeksimko avatar bradbeam avatar hynd avatar limitusus avatar jenkins-nuglif avatar jasonwbarnett avatar jvrplmlmn avatar jjhuff avatar waffle-iron avatar mpolden avatar meson10 avatar srenatus avatar theckman avatar grobie avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.