context

package
v0.0.0-...-a0d7459 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2017 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const RegisterCmdName = "payload-register"

RegisterCmdName is the name of the payload register command.

View Source
const StatusSetCmdName = "payload-status-set"

StatusSetCmdName is the name of the payload status-set command.

View Source
const UnregisterCmdName = "payload-unregister"

UnregisterCmdName is the name of the payload unregister command.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIClient

type APIClient interface {
	// List requests the payload info for the given IDs.
	List(fullIDs ...string) ([]payload.Result, error)
	// Track sends a request to update state with the provided payloads.
	Track(payloads ...payload.Payload) ([]payload.Result, error)
	// Untrack removes the payloads from our list track.
	Untrack(fullIDs ...string) ([]payload.Result, error)
	// SetStatus sets the status for the given IDs.
	SetStatus(status string, fullIDs ...string) ([]payload.Result, error)
}

APIClient represents the API needs of a Context.

type Component

type Component interface {
	// Get returns the payload info corresponding to the given ID.
	Get(class, id string) (*payload.Payload, error)
	// Track records the payload info in the hook context.
	Track(payload payload.Payload) error
	// Untrack removes the payload from our list of payloads to track.
	Untrack(class, id string) error
	// SetStatus sets the status of the payload.
	SetStatus(class, id, status string) error
	// List returns the list of registered payload IDs.
	List() ([]string, error)
	// Flush pushes the hook context data out to state.
	Flush() error
}

Component provides the hook context data specific to payloads.

func ContextComponent

func ContextComponent(ctx HookContext) (Component, error)

ContextComponent returns the hook context for the payload payload component.

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context is the payload portion of the hook context.

func NewContext

func NewContext(api APIClient, dataDir string) *Context

NewContext returns a new jujuc.ContextComponent for payloads.

func NewContextAPI

func NewContextAPI(api APIClient, dataDir string) (*Context, error)

NewContextAPI returns a new jujuc.ContextComponent for payloads.

func (*Context) Flush

func (c *Context) Flush() error

Flush implements jujuc.ContextComponent. In this case that means all added and updated payload.Payload in the hook context are pushed to Juju state via the API.

func (*Context) Get

func (c *Context) Get(class, id string) (*payload.Payload, error)

Get returns the payload info corresponding to the given ID.

func (*Context) List

func (c *Context) List() ([]string, error)

List returns the sorted names of all registered payloads.

func (*Context) Payloads

func (c *Context) Payloads() ([]payload.Payload, error)

Payloads returns the payloads known to the context.

func (*Context) SetStatus

func (c *Context) SetStatus(class, id, status string) error

SetStatus sets the identified payload's status.

func (*Context) Track

func (c *Context) Track(pl payload.Payload) error

Track records the payload info in the hook context.

func (*Context) Untrack

func (c *Context) Untrack(class, id string) error

Untrack tells juju to stop tracking this payload.

type HookContext

type HookContext interface {
	// Component implements jujuc.Context.
	Component(string) (Component, error)
}

HookContext is the portion of jujuc.Context used in this package.

type RegisterCmd

type RegisterCmd struct {
	cmd.CommandBase
	// contains filtered or unexported fields
}

RegisterCmd is a command that registers a payload with juju.

func NewRegisterCmd

func NewRegisterCmd(ctx HookContext) (*RegisterCmd, error)

NewRegisterCmd returns a new RegisterCmd that wraps the given context.

func (RegisterCmd) Info

func (c RegisterCmd) Info() *cmd.Info

Info implements cmd.Command.

func (*RegisterCmd) Init

func (c *RegisterCmd) Init(args []string) error

Init implements cmd.Command.

func (*RegisterCmd) Run

func (c *RegisterCmd) Run(ctx *cmd.Context) error

Run implements cmd.Command.

type StatusSetCmd

type StatusSetCmd struct {
	cmd.CommandBase
	// contains filtered or unexported fields
}

StatusSetCmd is a command that registers a payload with juju.

func NewStatusSetCmd

func NewStatusSetCmd(ctx HookContext) (*StatusSetCmd, error)

NewStatusSetCmd returns a new StatusSetCmd that wraps the given context.

func (StatusSetCmd) Info

func (c StatusSetCmd) Info() *cmd.Info

Info implements cmd.Command.

func (*StatusSetCmd) Init

func (c *StatusSetCmd) Init(args []string) error

Init implements cmd.Command.

func (*StatusSetCmd) Run

func (c *StatusSetCmd) Run(ctx *cmd.Context) error

Run implements cmd.Command.

type UnregisterCmd

type UnregisterCmd struct {
	cmd.CommandBase
	// contains filtered or unexported fields
}

UnregisterCmd implements the untrack command.

func NewUnregisterCmd

func NewUnregisterCmd(ctx HookContext) (*UnregisterCmd, error)

NewUnregisterCmd returns a new UnregisterCmd that wraps the given context.

func (UnregisterCmd) Info

func (c UnregisterCmd) Info() *cmd.Info

Info implements cmd.Command.

func (*UnregisterCmd) Init

func (c *UnregisterCmd) Init(args []string) error

Init implements cmd.Command.

func (*UnregisterCmd) Run

func (c *UnregisterCmd) Run(ctx *cmd.Context) error

Run runs the unregister command.

Jump to

Keyboard shortcuts

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