client

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2014 License: Apache-2.0 Imports: 11 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 GetList

func GetList() []string

Returns a list of clients.

func ValidatePublicKey

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

Checks that the provided public key is valid. Wrapper around chef_crypto.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 Get

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

Gets an actor from the data store.

func New

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

Creates a new client.

func NewFromJson

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

Build a new client/user from a json object.

func (*Client) CheckPermEdit

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

A check to see if the client is trying to edit admin and validator attributes.

func (*Client) Delete

func (c *Client) Delete() error

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

func (*Client) DocId

func (c *Client) DocId() string

func (*Client) Flatten

func (c *Client) Flatten() []string

func (*Client) GenerateKeys

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

Generate 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 (a *Client) GetName() string

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

func (*Client) IsAdmin

func (c *Client) IsAdmin() bool

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

func (*Client) IsClient

func (c *Client) IsClient() bool

func (*Client) IsSelf

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

Is the other actor provided the same as the caller.

func (*Client) IsUser

func (c *Client) IsUser() bool

func (*Client) IsValidator

func (c *Client) IsValidator() bool

Is the client a validator client? If use-auth is false, this always returns false.

func (*Client) PublicKey

func (c *Client) PublicKey() string

Returns the client's public key. Part of the Actor interface.

func (*Client) Rename

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

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

func (*Client) Save

func (c *Client) Save() error

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

Set the client's public key.

func (*Client) ToJson

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

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

func (*Client) URLType

func (a *Client) URLType() string

func (*Client) UpdateFromJson

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

Update 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