juju: github.com/juju/juju/payload/context Index | Files

package context

import "github.com/juju/juju/payload/context"

Index

Package Files

context.go register.go status-set.go unregister.go utils.go

Constants

const RegisterCmdName = "payload-register"

RegisterCmdName is the name of the payload register command.

const StatusSetCmdName = "payload-status-set"

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

const UnregisterCmdName = "payload-unregister"

UnregisterCmdName is the name of the payload unregister command.

type APIClient Uses

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 Uses

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 Uses

func ContextComponent(ctx HookContext) (Component, error)

ContextComponent returns the hook context for the payload payload component.

type Context Uses

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

Context is the payload portion of the hook context.

func NewContext Uses

func NewContext(api APIClient, dataDir string) *Context

NewContext returns a new hooks.ContextComponent for payloads.

func NewContextAPI Uses

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

NewContextAPI returns a new hooks.ContextComponent for payloads.

func (*Context) Flush Uses

func (c *Context) Flush() error

Flush implements hooks.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 Uses

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

Get returns the payload info corresponding to the given ID.

func (*Context) List Uses

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

List returns the sorted names of all registered payloads.

func (*Context) Payloads Uses

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

Payloads returns the payloads known to the context.

func (*Context) SetStatus Uses

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

SetStatus sets the identified payload's status.

func (*Context) Track Uses

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

Track records the payload info in the hook context.

func (*Context) Untrack Uses

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

Untrack tells juju to stop tracking this payload.

type HookContext Uses

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

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

type RegisterCmd Uses

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

RegisterCmd is a command that registers a payload with juju.

func NewRegisterCmd Uses

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

NewRegisterCmd returns a new RegisterCmd that wraps the given context.

func (RegisterCmd) Info Uses

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

Info implements cmd.Command.

func (*RegisterCmd) Init Uses

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

Init implements cmd.Command.

func (*RegisterCmd) Run Uses

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

Run implements cmd.Command.

type StatusSetCmd Uses

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

StatusSetCmd is a command that registers a payload with juju.

func NewStatusSetCmd Uses

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

NewStatusSetCmd returns a new StatusSetCmd that wraps the given context.

func (StatusSetCmd) Info Uses

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

Info implements cmd.Command.

func (*StatusSetCmd) Init Uses

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

Init implements cmd.Command.

func (*StatusSetCmd) Run Uses

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

Run implements cmd.Command.

type UnregisterCmd Uses

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

UnregisterCmd implements the untrack command.

func NewUnregisterCmd Uses

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

NewUnregisterCmd returns a new UnregisterCmd that wraps the given context.

func (UnregisterCmd) Info Uses

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

Info implements cmd.Command.

func (*UnregisterCmd) Init Uses

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

Init implements cmd.Command.

func (*UnregisterCmd) Run Uses

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

Run runs the unregister command.

Package context imports 9 packages (graph) and is imported by 8 packages. Updated 2019-01-15. Refresh now. Tools for package owners.