chef

package
v0.11.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 17, 2017 License: Apache-2.0, Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const ChefVersion = "11.12.0"

ChefVersion that we pretend to emulate

Variables

This section is empty.

Functions

func Base64BlockEncode

func Base64BlockEncode(content []byte, limit int) []string

Base64BlockEncode takes a byte slice and breaks it up into a slice of base64 encoded strings

func CheckResponse

func CheckResponse(r *http.Response) error

CheckResponse receives a pointer to a http.Response and generates an Error via unmarshalling

func GenerateSignature

func GenerateSignature(priv *rsa.PrivateKey, data string) (enc []byte, err error)

GenerateSignature will generate a signature ( sign ) the given data

func HashStr

func HashStr(toHash string) string

HashStr returns the base64 encoded SHA1 sum of the toHash string

func PrivateKeyFromString

func PrivateKeyFromString(key []byte) (*rsa.PrivateKey, error)

PrivateKeyFromString parses an RSA private key from a string

Types

type AuthConfig

type AuthConfig struct {
	PrivateKey *rsa.PrivateKey
	ClientName string
}

AuthConfig representing a client and a private key used for encryption

This is embedded in the Client type

func (AuthConfig) SignRequest

func (ac AuthConfig) SignRequest(request *http.Request) error

SignRequest modifies headers of an http.Request

type Body

type Body struct {
	io.Reader
}

Body wraps io.Reader and adds methods for calculating hashes and detecting content

func (*Body) Buffer

func (body *Body) Buffer() *bytes.Buffer

Buffer creates a byte.Buffer copy from a io.Reader resets read on reader to 0,0

func (*Body) ContentType

func (body *Body) ContentType() string

ContentType returns the content-type string of Body as detected by http.DetectContentType()

func (*Body) Hash

func (body *Body) Hash() (h string)

Hash calculates the body content hash

type Client

type Client struct {
	Auth    *AuthConfig
	BaseURL *url.URL
	// contains filtered or unexported fields
}

Client is vessel for public methods used against the chef-server

func NewClient

func NewClient(cfg *Config) (*Client, error)

NewClient is the client generator used to instantiate a client for talking to a chef-server It is a simple constructor for the Client struct intended as a easy interface for issuing signed requests

func (*Client) Do

func (c *Client) Do(req *http.Request, v interface{}) (*http.Response, error)

Do is used either internally via our magic request shite or a user may use it

func (*Client) NewRequest

func (c *Client) NewRequest(method string, requestUrl string, body io.Reader) (*http.Request, error)

NewRequest returns a signed request suitable for the chef server

type Config

type Config struct {
	// This should be the user ID on the chef server
	Name string

	// This is the plain text private Key for the user
	Key string

	// BaseURL is the chef server URL used to connect too. Is using orgs you should include your org in the url
	BaseURL string

	// When set to false (default) this will enable SSL Cert Verification. If you need to disable Cert Verification set to true
	SkipSSL bool

	// Time to wait in seconds before giving up on a request to the server
	Timeout time.Duration
}

Config contains the configuration options for a chef client. This is Used primarily in the NewClient() constructor in order to setup a proper client object

type ErrorResponse

type ErrorResponse struct {
	Response *http.Response // HTTP response that caused this error
}

An ErrorResponse reports one or more errors caused by an API request. Thanks to https://github.com/google/go-github

func (*ErrorResponse) Error

func (r *ErrorResponse) Error() string

Notes

Bugs

  • tightly coupled

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL