util

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2014 License: Apache-2.0 Imports: 9 Imported by: 166

Documentation

Overview

Package util contains various utility functions that are useful across all of goiardi.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomObjURL

func CustomObjURL(obj GoiardiObj, path string) string

Craft a URL for a Goiardi object with additional path elements

func CustomURL

func CustomURL(path string) string

Craft a URL from the provided path, without providing an object.

func DeepMerge

func DeepMerge(key string, source interface{}) map[string]interface{}

Merge disparate data structures into a flat hash.

func FlattenObj

func FlattenObj(obj interface{}) map[string]interface{}

Flatten an object and expand its keys into a map[string]string so it's suitable for indexing, either with solr (eventually) or with the whipped up replacement for local mode. Objects fed into this function *must* have the "json" tag set for their struct members.

func Indexify

func Indexify(flattened map[string]interface{}) []string

Given a flattened object, prepares it for indexing by turning it into a sorted slice of strings formatted like "key:value".

func MapifyObject

func MapifyObject(obj interface{}) map[string]interface{}

Turn an object into a map[string]interface{}. Useful for when you have a slice of objects that you need to trim, mutilate, fold, etc. before returning them as JSON.

func ObjURL

func ObjURL(obj GoiardiObj) string

Craft a URL

func ValidateDBagName

func ValidateDBagName(name string) bool

func ValidateEnvName

func ValidateEnvName(name string) bool

func ValidateName

func ValidateName(name string) bool

func ValidateUserName added in v0.4.0

func ValidateUserName(name string) bool

Types

type Gerror

type Gerror interface {
	Error() string
	Status() int
	SetStatus(int)
}

An error type that includes an http status code (defaults to http.BadRequest).

func CheckAdminPlusValidator added in v0.4.0

func CheckAdminPlusValidator(json_actor map[string]interface{}) Gerror

Check that client/user json is not trying to set admin and validator at the same time. This has to be checked separately to make chef-pedent happy.

func Errorf

func Errorf(format string, a ...interface{}) Gerror

Create a new Gerror, with a formatted error string.

func New

func New(text string) Gerror

func ValidateAsBool

func ValidateAsBool(b interface{}) (bool, Gerror)

func ValidateAsConstraint

func ValidateAsConstraint(t interface{}) (bool, Gerror)

func ValidateAsFieldString

func ValidateAsFieldString(str interface{}) (string, Gerror)

func ValidateAsString

func ValidateAsString(str interface{}) (string, Gerror)

func ValidateAsVersion

func ValidateAsVersion(ver interface{}) (string, Gerror)

func ValidateAttributes

func ValidateAttributes(key string, attrs interface{}) (map[string]interface{}, Gerror)

func ValidateCookbookDivision

func ValidateCookbookDivision(dname string, div interface{}) ([]map[string]interface{}, Gerror)

func ValidateCookbookMetadata

func ValidateCookbookMetadata(mdata interface{}) (map[string]interface{}, Gerror)

func ValidateNumVersions

func ValidateNumVersions(nr string) Gerror

func ValidateRunList

func ValidateRunList(rl interface{}) ([]string, Gerror)

type GoiardiObj

type GoiardiObj interface {
	GetName() string
	URLType() string
}

Anything that implements these functions is a goiardi/chef object, like a cookbook, role, etc., and will be able to use these common functions.

Jump to

Keyboard shortcuts

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