client

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package client defines the Chef clients. Formerly clients and users were the same kind of object and stored together, but they have now been split apart. They do both implement the Actor interface, though. Clients are the more usual case for the nodes interacting with the server, but users are used for the webui and often for general user (as opposed to node) interactions with the server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExportAllClients added in v0.5.2

func ExportAllClients() []interface{}

ExportAllClients returns all clients in a fashion suitable for exporting.

func GetList

func GetList() []string

GetList returns a list of clients.

func ValidatePublicKey

func ValidatePublicKey(publicKey interface{}) (bool, util.Gerror)

ValidatePublicKey checks that the provided public key is valid. Wrapper around chefcrypto.ValidatePublicKey(), but with a different error type.

Types

type Client

type Client struct {
	Name      string `json:"name"`
	NodeName  string `json:"node_name"`
	JSONClass string `json:"json_class"`
	ChefType  string `json:"chef_type"`
	Validator bool   `json:"validator"`
	Orgname   string `json:"orgname"`

	Admin       bool   `json:"admin"`
	Certificate string `json:"certificate"`
	// contains filtered or unexported fields
}

A Client and a user are very similar, with some small differences - users can never be validators, while clients don't have passwords. Generally nodes and the like will be clients, while people interacting with the goiardi server will be users.

func AllClients added in v0.5.2

func AllClients() []*Client

AllClients returns a slice of all the clients on this server.

func Get

func Get(clientname string) (*Client, util.Gerror)

Get gets a client from the data store.

func GetMulti added in v0.10.0

func GetMulti(clientNames []string) ([]*Client, util.Gerror)

GetMulti gets multiple clients from a given slice of client names.

func New

func New(clientname string) (*Client, util.Gerror)

New creates a new client.

func NewFromJSON added in v0.6.0

func NewFromJSON(jsonActor map[string]interface{}) (*Client, util.Gerror)

NewFromJSON builds a new client/user from a json object.

func (*Client) CheckPermEdit

func (c *Client) CheckPermEdit(clientData map[string]interface{}, perm string) util.Gerror

CheckPermEdit checks to see if the client is trying to edit admin and validator attributes, and if it has permissions to do so.

func (*Client) Delete

func (c *Client) Delete() error

Delete a client, but will refuse to do so if it is the last client that is an adminstrator.

func (*Client) DocID added in v0.6.0

func (c *Client) DocID() string

DocID is for the indexer, to tell what it's identifier is.

func (*Client) Flatten

func (c *Client) Flatten() map[string]interface{}

Flatten out the client so it's suitable for indexing.

func (*Client) GenerateKeys

func (c *Client) GenerateKeys() (string, error)

GenerateKeys makes a new set of RSA keys for the client. The new private key is saved with the client, the public key is given to the client and not saved on the server at all.

func (*Client) GetName

func (c *Client) GetName() string

GetName gives the client's name.

func (*Client) GobDecode

func (c *Client) GobDecode(b []byte) error

func (*Client) GobEncode

func (c *Client) GobEncode() ([]byte, error)

func (*Client) Index

func (c *Client) Index() string

Index tells the indexer which collection of objects to place the client into.

func (*Client) IsAdmin

func (c *Client) IsAdmin() bool

IsAdmin returns true if the client is an admin. If use-auth is false, this always returns true.

func (*Client) IsClient

func (c *Client) IsClient() bool

IsClient always returns true for clients. Part of the Actor interface.

func (*Client) IsSelf

func (c *Client) IsSelf(other interface{}) bool

IsSelf returns true if the other actor provided is the same as the caller.

func (*Client) IsUser

func (c *Client) IsUser() bool

IsUser always returns false for clients. Part of the Actor interface.

func (*Client) IsValidator

func (c *Client) IsValidator() bool

IsValidator returns true if the client is a validator client. If use-auth is false, this always returns false.

func (*Client) PublicKey

func (c *Client) PublicKey() string

PublicKey returns the client's public key. Part of the Actor interface.

func (*Client) Rename

func (c *Client) Rename(newName string) util.Gerror

Rename the client. Save() must be called after this method is used. Will not rename the last admin.

func (*Client) Save

func (c *Client) Save() util.Gerror

Save the client. If a user with the same name as the client exists, returns an error. Additionally, if running with MySQL it will return any DB error.

func (*Client) SetPublicKey

func (c *Client) SetPublicKey(pk interface{}) error

SetPublicKey sets the client's public key.

func (*Client) ToJSON added in v0.6.0

func (c *Client) ToJSON() map[string]interface{}

ToJSON converts the client object into a JSON object, massaging it as needed to make chef-pedant happy.

func (*Client) URLType

func (c *Client) URLType() string

URLType returns the base URL element for clients.

func (*Client) UpdateFromJSON added in v0.6.0

func (c *Client) UpdateFromJSON(jsonActor map[string]interface{}) util.Gerror

UpdateFromJSON updates a client/user from a json object. Does a bunch of validations inside rather than in the handler.

Jump to

Keyboard shortcuts

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