jujuc

package
v0.0.0-...-4308112 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2024 License: AGPL-3.0 Imports: 37 Imported by: 0

Documentation

Overview

Package jujuc implements the server side of the jujuc proxy tool, which forwards command invocations to the unit agent process so that they can be executed against specific state.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoStdin = errors.New("hook tool requires stdin, none supplied")

ErrNoStdin is returned by Jujuc.Main if the hook tool requests stdin, and none is supplied.

View Source
var ErrRestrictedContext = errors.NotImplementedf("not implemented for restricted context")

ErrRestrictedContext indicates a method is not implemented in the given context.

Functions

func CommandNames

func CommandNames() (names []string)

CommandNames returns the names of all jujuc commands.

func IsNotAvailable

func IsNotAvailable(err error) bool

IsNotAvailable reports whether err was creates with NotAvailable().

func NewActionFailCommand

func NewActionFailCommand(ctx Context) (cmd.Command, error)

NewActionFailCommand returns a new ActionFailCommand with the given context.

func NewActionGetCommand

func NewActionGetCommand(ctx Context) (cmd.Command, error)

NewActionGetCommand returns an ActionGetCommand for use with the given context.

func NewActionLogCommand

func NewActionLogCommand(ctx Context) (cmd.Command, error)

func NewActionSetCommand

func NewActionSetCommand(ctx Context) (cmd.Command, error)

NewActionSetCommand returns a new ActionSetCommand with the given context.

func NewApplicationVersionSetCommand

func NewApplicationVersionSetCommand(ctx Context) (cmd.Command, error)

NewApplicationVersionSetCommand creates an application-version-set command.

func NewClosePortCommand

func NewClosePortCommand(ctx Context) (cmd.Command, error)

func NewCommand

func NewCommand(ctx Context, name string) (cmd.Command, error)

NewCommand returns an instance of the named Command, initialized to execute against the supplied Context.

func NewConfigGetCommand

func NewConfigGetCommand(ctx Context) (cmd.Command, error)

func NewCredentialGetCommand

func NewCredentialGetCommand(ctx Context) (cmd.Command, error)

NewCredentialGetCommand returns a new CredentialGetCommand with the given context.

func NewGoalStateCommand

func NewGoalStateCommand(ctx Context) (cmd.Command, error)

func NewIsLeaderCommand

func NewIsLeaderCommand(ctx Context) (cmd.Command, error)

NewIsLeaderCommand returns a new isLeaderCommand with the given context.

func NewJujuLogCommand

func NewJujuLogCommand(ctx Context) (cmd.Command, error)

func NewJujuRebootCommand

func NewJujuRebootCommand(ctx Context) (cmd.Command, error)

func NewLeaderGetCommand

func NewLeaderGetCommand(ctx Context) (cmd.Command, error)

NewLeaderGetCommand returns a new leaderGetCommand with the given context.

func NewLeaderSetCommand

func NewLeaderSetCommand(ctx Context) (cmd.Command, error)

NewLeaderSetCommand returns a new leaderSetCommand with the given context.

func NewNetworkGetCommand

func NewNetworkGetCommand(ctx Context) (_ cmd.Command, err error)

func NewOpenPortCommand

func NewOpenPortCommand(ctx Context) (cmd.Command, error)

func NewOpenedPortsCommand

func NewOpenedPortsCommand(ctx Context) (cmd.Command, error)

func NewPayloadRegisterCmd

func NewPayloadRegisterCmd(ctx Context) (cmd.Command, error)

NewPayloadRegisterCmd returns a new PayloadRegisterCmd that wraps the given context.

func NewPayloadStatusSetCmd

func NewPayloadStatusSetCmd(ctx Context) (cmd.Command, error)

NewPayloadStatusSetCmd returns a new PayloadStatusSetCmd that wraps the given context.

func NewPayloadUnregisterCmd

func NewPayloadUnregisterCmd(ctx Context) (cmd.Command, error)

NewPayloadUnregisterCmd returns a new PayloadUnregisterCmd that wraps the given context.

func NewRelationGetCommand

func NewRelationGetCommand(ctx Context) (cmd.Command, error)

func NewRelationIdValue

func NewRelationIdValue(ctx Context, result *int) (*relationIdValue, error)

NewRelationIdValue returns a gnuflag.Value for convenient parsing of relation ids in ctx.

func NewRelationIdsCommand

func NewRelationIdsCommand(ctx Context) (cmd.Command, error)

func NewRelationListCommand

func NewRelationListCommand(ctx Context) (cmd.Command, error)

func NewRelationSetCommand

func NewRelationSetCommand(ctx Context) (cmd.Command, error)

func NewResourceGetCmd

func NewResourceGetCmd(ctx Context) (cmd.Command, error)

NewResourceGetCmd creates a new ResourceGetCmd for the given hook context.

func NewSecretAddCommand

func NewSecretAddCommand(ctx Context) (cmd.Command, error)

NewSecretAddCommand returns a command to add a secret.

func NewSecretGetCommand

func NewSecretGetCommand(ctx Context) (cmd.Command, error)

NewSecretGetCommand returns a command to get a secret value.

func NewSecretGrantCommand

func NewSecretGrantCommand(ctx Context) (cmd.Command, error)

NewSecretGrantCommand returns a command to grant access to a secret.

func NewSecretIdsCommand

func NewSecretIdsCommand(ctx Context) (cmd.Command, error)

NewSecretIdsCommand returns a command to list the IDs and labels of secrets. created by this app.

func NewSecretInfoGetCommand

func NewSecretInfoGetCommand(ctx Context) (cmd.Command, error)

NewSecretInfoGetCommand returns a command to get secret metadata.

func NewSecretRemoveCommand

func NewSecretRemoveCommand(ctx Context) (cmd.Command, error)

NewSecretRemoveCommand returns a command to remove a secret.

func NewSecretRevokeCommand

func NewSecretRevokeCommand(ctx Context) (cmd.Command, error)

NewSecretRevokeCommand returns a command to revoke access to a secret.

func NewSecretSetCommand

func NewSecretSetCommand(ctx Context) (cmd.Command, error)

NewSecretSetCommand returns a command to create a secret.

func NewStateDeleteCommand

func NewStateDeleteCommand(ctx Context) (cmd.Command, error)

NewStateDeleteCommand returns a state-delete command.

func NewStateGetCommand

func NewStateGetCommand(ctx Context) (cmd.Command, error)

NewStateGetCommand returns a state-get command.

func NewStateSetCommand

func NewStateSetCommand(ctx Context) (cmd.Command, error)

NewStateSetCommand returns a state-set command.

func NewStatusGetCommand

func NewStatusGetCommand(ctx Context) (cmd.Command, error)

func NewStatusSetCommand

func NewStatusSetCommand(ctx Context) (cmd.Command, error)

NewStatusSetCommand makes a jujuc status-set command.

func NewStorageAddCommand

func NewStorageAddCommand(ctx Context) (cmd.Command, error)

NewStorageAddCommand makes a jujuc storage-add command.

func NewStorageGetCommand

func NewStorageGetCommand(cmdCtx Context) (cmd.Command, error)

func NewStorageListCommand

func NewStorageListCommand(ctx Context) (cmd.Command, error)

func NewUnitGetCommand

func NewUnitGetCommand(ctx Context) (cmd.Command, error)

func NotAvailable

func NotAvailable(thing string) error

NotAvailable returns an error which satisfies IsNotAvailable.

Types

type ActionFailCommand

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

ActionFailCommand implements the action-fail command.

func (*ActionFailCommand) Info

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

Info returns the content for --help.

func (*ActionFailCommand) Init

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

Init sets the fail message and checks for malformed invocations.

func (*ActionFailCommand) Run

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

Run sets the Action's fail state.

func (*ActionFailCommand) SetFlags

func (c *ActionFailCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags handles any option flags, but there are none.

type ActionGetCommand

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

ActionGetCommand implements the action-get command.

func (*ActionGetCommand) Info

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

Info returns the content for --help.

func (*ActionGetCommand) Init

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

Init makes sure there are no additional unknown arguments to action-get.

func (*ActionGetCommand) Run

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

Run recurses into the params map for the Action, given the list of keys into the map, and returns either the keyed value, or nothing. In the case of an empty keys list, the entire params map will be returned.

func (*ActionGetCommand) SetFlags

func (c *ActionGetCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags handles known option flags; in this case, [--output={json|yaml}] and --help.

type ActionHookContext

type ActionHookContext interface {
	HookContext
	// contains filtered or unexported methods
}

ActionHookContext is the context for an action hook.

type ActionLogCommand

type ActionLogCommand struct {
	cmd.CommandBase

	Message string
	// contains filtered or unexported fields
}

ActionLogCommand implements the action-log command.

func (*ActionLogCommand) Info

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

func (*ActionLogCommand) Init

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

func (*ActionLogCommand) Run

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

type ActionSetCommand

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

ActionSetCommand implements the action-set command.

func (*ActionSetCommand) Info

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

Info returns the content for --help.

func (*ActionSetCommand) Init

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

Init accepts maps in the form of key=value, key.key2.keyN....=value

func (*ActionSetCommand) Run

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

Run adds the given <key list>/<value> pairs, such as foo.bar=baz to the existing map of results for the Action.

func (*ActionSetCommand) SetFlags

func (c *ActionSetCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags handles known option flags.

type ApplicationStatusInfo

type ApplicationStatusInfo struct {
	Application StatusInfo
	Units       []StatusInfo
}

ApplicationStatusInfo holds StatusInfo for an Application and all its Units.

type CmdGetter

type CmdGetter func(contextId, cmdName string) (cmd.Command, error)

CmdGetter looks up a Command implementation connected to a particular Context.

type ConfigGetCommand

type ConfigGetCommand struct {
	cmd.CommandBase

	Key string // The key to show. If empty, show all.
	All bool
	// contains filtered or unexported fields
}

ConfigGetCommand implements the config-get command.

func (*ConfigGetCommand) Info

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

func (*ConfigGetCommand) Init

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

func (*ConfigGetCommand) Run

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

func (*ConfigGetCommand) SetFlags

func (c *ConfigGetCommand) SetFlags(f *gnuflag.FlagSet)

type Context

type Context interface {
	HookContext
	// contains filtered or unexported methods
}

Context is the interface that all hook helper commands depend on to interact with the rest of the system.

type ContextInstance

type ContextInstance interface {
	// AvailabilityZone returns the executing unit's availability zone or an error
	// if it was not found (or is not available).
	AvailabilityZone() (string, error)

	// RequestReboot will set the reboot flag to true on the machine agent
	RequestReboot(prio RebootPriority) error
}

ContextInstance is the part of a hook context related to the unit's instance.

type ContextLeadership

type ContextLeadership interface {
	// IsLeader returns true if the local unit is known to be leader for at
	// least the next 30s.
	IsLeader() (bool, error)

	// LeaderSettings returns the current leader settings. Once leader settings
	// have been read in a given context, they will not be updated other than
	// via successful calls to WriteLeaderSettings.
	LeaderSettings(context.Context) (map[string]string, error)

	// WriteLeaderSettings writes the supplied settings directly to state, or
	// fails if the local unit is not the application's leader.
	WriteLeaderSettings(context.Context, map[string]string) error
}

ContextLeadership is the part of a hook context related to the unit leadership.

type ContextNetworking

type ContextNetworking interface {
	// PublicAddress returns the executing unit's public address or an
	// error if it is not available.
	PublicAddress(context.Context) (string, error)

	// PrivateAddress returns the executing unit's private address or an
	// error if it is not available.
	PrivateAddress() (string, error)

	// OpenPortRange marks the supplied port range for opening.
	OpenPortRange(endpointName string, portRange network.PortRange) error

	// ClosePortRange ensures the supplied port range is closed even when
	// the executing unit's application is exposed (unless it is opened
	// separately by a co-located unit).
	ClosePortRange(endpointName string, portRange network.PortRange) error

	// OpenedPortRanges returns all port ranges currently opened by this
	// unit on its assigned machine grouped by endpoint name.
	OpenedPortRanges() network.GroupedPortRanges

	// NetworkInfo returns the network info for the given bindings on the given relation.
	NetworkInfo(ctx context.Context, bindingNames []string, relationId int) (map[string]params.NetworkInfoResult, error)
}

ContextNetworking is the part of a hook context related to network interface of the unit's instance.

type ContextPayloads

type ContextPayloads interface {
	// GetPayload returns the payload info corresponding to the given ID.
	GetPayload(class, id string) (*payloads.Payload, error)
	// TrackPayload records the payload info in the hook context.
	TrackPayload(payload payloads.Payload) error
	// UntrackPayload removes the payload from our list of payloads to track.
	UntrackPayload(ctx context.Context, class, id string) error
	// SetPayloadStatus sets the status of the payload.
	SetPayloadStatus(ctx context.Context, class, id, status string) error
	// ListPayloads returns the list of registered payload IDs.
	ListPayloads() ([]string, error)
	// FlushPayloads pushes the hook context data out to state.
	FlushPayloads(context.Context) error
}

ContextPayloads exposes the functionality needed by the "payload-*" hook commands.

type ContextRelation

type ContextRelation interface {

	// Id returns an integer which uniquely identifies the relation.
	Id() int

	// Name returns the name the locally executing charm assigned to this relation.
	Name() string

	// RelationTag returns the relation tag.
	RelationTag() names.RelationTag

	// FakeId returns a string of the form "relation-name:123", which uniquely
	// identifies the relation to the hook. In reality, the identification
	// of the relation is the integer following the colon, but the composed
	// name is useful to humans observing it.
	FakeId() string

	// Settings allows read/write access to the local unit's settings in
	// this relation.
	Settings(context.Context) (Settings, error)

	// ApplicationSettings allows read/write access to the application settings in
	// this relation, but only if the current unit is leader.
	ApplicationSettings(context.Context) (Settings, error)

	// UnitNames returns a list of the remote units in the relation.
	UnitNames() []string

	// ReadSettings returns the settings of any remote unit in the relation.
	ReadSettings(ctx context.Context, unit string) (params.Settings, error)

	// ReadApplicationSettings returns the application settings of any remote unit in the relation.
	ReadApplicationSettings(ctx context.Context, app string) (params.Settings, error)

	// Suspended returns true if the relation is suspended.
	Suspended() bool

	// SetStatus sets the relation's status.
	SetStatus(context.Context, relation.Status) error

	// RemoteApplicationName returns the application on the other end of
	// the relation from the perspective of this unit.
	RemoteApplicationName() string

	// Life returns the relation's current life state.
	Life() life.Value
}

ContextRelation expresses the capabilities of a hook with respect to a relation.

type ContextRelations

type ContextRelations interface {
	// Relation returns the relation with the supplied id if it was found, and
	// an error if it was not found or is not available.
	Relation(id int) (ContextRelation, error)

	// RelationIds returns the ids of all relations the executing unit is
	// currently participating in or an error if they are not available.
	RelationIds() ([]int, error)
}

ContextRelations exposes the relations associated with the unit.

type ContextResources

type ContextResources interface {
	// DownloadResource downloads the named resource and returns
	// the path to which it was downloaded.
	DownloadResource(ctx context.Context, name string) (filePath string, _ error)
}

ContextResources exposes the functionality needed by the "resource-*" hook commands.

type ContextSecrets

type ContextSecrets interface {
	// GetSecret returns the value of the specified secret.
	GetSecret(context.Context, *secrets.URI, string, bool, bool) (secrets.SecretValue, error)

	// CreateSecret creates a secret with the specified data.
	CreateSecret(context.Context, *SecretCreateArgs) (*secrets.URI, error)

	// UpdateSecret creates a secret with the specified data.
	UpdateSecret(*secrets.URI, *SecretUpdateArgs) error

	// RemoveSecret removes a secret with the specified uri.
	RemoveSecret(*secrets.URI, *int) error

	// GrantSecret grants access to the specified secret.
	GrantSecret(*secrets.URI, *SecretGrantRevokeArgs) error

	// RevokeSecret revokes access to the specified secret.
	RevokeSecret(*secrets.URI, *SecretGrantRevokeArgs) error

	// SecretMetadata gets the secret metadata for secrets created by the charm.
	SecretMetadata() (map[string]SecretMetadata, error)
}

ContextSecrets is the part of a hook context related to secrets.

type ContextStatus

type ContextStatus interface {
	// UnitStatus returns the executing unit's current status.
	UnitStatus(context.Context) (*StatusInfo, error)

	// SetUnitStatus updates the unit's status.
	SetUnitStatus(context.Context, StatusInfo) error

	// ApplicationStatus returns the executing unit's application status
	// (including all units).
	ApplicationStatus(context.Context) (ApplicationStatusInfo, error)

	// SetApplicationStatus updates the status for the unit's application.
	SetApplicationStatus(context.Context, StatusInfo) error
}

ContextStatus is the part of a hook context related to the unit's status.

type ContextStorage

type ContextStorage interface {
	// StorageTags returns a list of tags for storage instances
	// attached to the unit or an error if they are not available.
	StorageTags(context.Context) ([]names.StorageTag, error)

	// Storage returns the ContextStorageAttachment with the supplied
	// tag if it was found, and an error if it was not found or is not
	// available to the context.
	Storage(context.Context, names.StorageTag) (ContextStorageAttachment, error)

	// HookStorage returns the storage attachment associated
	// the executing hook if it was found, and an error if it
	// was not found or is not available.
	HookStorage(context.Context) (ContextStorageAttachment, error)

	// AddUnitStorage saves storage directives in the context.
	AddUnitStorage(map[string]params.StorageDirectives) error
}

ContextStorage is the part of a hook context related to storage resources associated with the unit.

type ContextStorageAttachment

type ContextStorageAttachment interface {

	// Tag returns a tag which uniquely identifies the storage attachment
	// in the context of the unit.
	Tag() names.StorageTag

	// Kind returns the kind of the storage.
	Kind() storage.StorageKind

	// Location returns the location of the storage: the mount point for
	// filesystem-kind stores, and the device path for block-kind stores.
	Location() string
}

ContextStorageAttachment expresses the capabilities of a hook with respect to a storage attachment.

type ContextUnit

type ContextUnit interface {
	// UnitName returns the executing unit's name.
	UnitName() string

	// ConfigSettings returns the current application
	// configuration of the executing unit.
	ConfigSettings(context.Context) (charm.Settings, error)

	// GoalState returns the goal state for the current unit.
	GoalState(context.Context) (*application.GoalState, error)

	// CloudSpec returns the unit's cloud specification
	CloudSpec(context.Context) (*params.CloudSpec, error)
}

ContextUnit is the part of a hook context related to the unit.

type ContextVersion

type ContextVersion interface {

	// UnitWorkloadVersion returns the currently set workload version for
	// the unit.
	UnitWorkloadVersion(context.Context) (string, error)

	// SetUnitWorkloadVersion updates the workload version for the unit.
	SetUnitWorkloadVersion(context.Context, string) error
}

ContextVersion expresses the parts of a hook context related to reporting workload versions.

type CredentialGetCommand

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

CredentialGetCommand implements the leader-get command.

func (*CredentialGetCommand) Info

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

Info is part of the cmd.Command interface.

func (*CredentialGetCommand) Init

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

Init is part of the cmd.Command interface.

func (*CredentialGetCommand) Run

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

Run is part of the cmd.Command interface.

func (*CredentialGetCommand) SetFlags

func (c *CredentialGetCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags is part of the cmd.Command interface.

type GoalStateCommand

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

GoalStateCommand implements the config-get command.

func (*GoalStateCommand) Info

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

func (*GoalStateCommand) Init

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

func (*GoalStateCommand) Run

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

func (*GoalStateCommand) SetFlags

func (c *GoalStateCommand) SetFlags(f *gnuflag.FlagSet)

type HookContext

type HookContext interface {
	ContextUnit
	ContextStatus
	ContextInstance
	ContextNetworking
	ContextLeadership
	ContextStorage
	ContextResources
	ContextPayloads
	ContextRelations
	ContextVersion
	ContextSecrets

	// GetLogger returns a juju logger Logger for the supplied module that is
	// correctly wired up for the given context
	GetLoggerByName(module string) corelogger.Logger
}

HookContext represents the information and functionality that is common to all charm hooks.

type JujuLogCommand

type JujuLogCommand struct {
	cmd.CommandBase

	Message string
	Debug   bool
	Level   string
	// contains filtered or unexported fields
}

JujuLogCommand implements the juju-log command.

func (*JujuLogCommand) Info

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

func (*JujuLogCommand) Init

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

func (*JujuLogCommand) Run

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

func (*JujuLogCommand) SetFlags

func (c *JujuLogCommand) SetFlags(f *gnuflag.FlagSet)

type JujuLogContext

type JujuLogContext interface {
	UnitName() string
	HookRelation() (ContextRelation, error)
	GetLoggerByName(module string) corelogger.Logger
}

JujuLogContext is the Context for the JujuLogCommand

type JujuRebootCommand

type JujuRebootCommand struct {
	cmd.CommandBase

	Now bool
	// contains filtered or unexported fields
}

JujuRebootCommand implements the juju-reboot command.

func (*JujuRebootCommand) Info

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

func (*JujuRebootCommand) Init

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

func (*JujuRebootCommand) Run

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

func (*JujuRebootCommand) SetFlags

func (c *JujuRebootCommand) SetFlags(f *gnuflag.FlagSet)

type Jujuc

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

Jujuc implements the jujuc command in the form required by net/rpc.

func (*Jujuc) Main

func (j *Jujuc) Main(req Request, resp *exec.ExecResponse) error

Main runs the Command specified by req, and fills in resp. A single command is run at a time.

type NetworkGetCommand

type NetworkGetCommand struct {
	cmd.CommandBase

	RelationId int
	// contains filtered or unexported fields
}

NetworkGetCommand implements the network-get command.

func (*NetworkGetCommand) Info

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

Info is part of the cmd.Command interface.

func (*NetworkGetCommand) Init

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

Init is part of the cmd.Command interface.

func (*NetworkGetCommand) Run

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

func (*NetworkGetCommand) SetFlags

func (c *NetworkGetCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags is part of the cmd.Command interface.

type OpenedPortsCommand

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

OpenedPortsCommand implements the opened-ports command.

func (*OpenedPortsCommand) Info

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

func (*OpenedPortsCommand) Init

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

func (*OpenedPortsCommand) Run

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

func (*OpenedPortsCommand) SetFlags

func (c *OpenedPortsCommand) SetFlags(f *gnuflag.FlagSet)

type PayloadRegisterCmd

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

PayloadRegisterCmd is a command that registers a payload with juju.

func (PayloadRegisterCmd) Info

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

Info implements cmd.Command.

func (*PayloadRegisterCmd) Init

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

Init implements cmd.Command.

func (*PayloadRegisterCmd) Run

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

Run implements cmd.Command.

type PayloadStatusSetCmd

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

PayloadStatusSetCmd is a command that registers a payload with juju.

func (PayloadStatusSetCmd) Info

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

Info implements cmd.Command.

func (*PayloadStatusSetCmd) Init

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

Init implements cmd.Command.

func (*PayloadStatusSetCmd) Run

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

Run implements cmd.Command.

type PayloadUnregisterCmd

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

PayloadUnregisterCmd implements the untrack command.

func (PayloadUnregisterCmd) Info

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

Info implements cmd.Command.

func (*PayloadUnregisterCmd) Init

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

Init implements cmd.Command.

func (*PayloadUnregisterCmd) Run

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

Run runs the unregister command.

type RebootPriority

type RebootPriority int

RebootPriority is the type used for reboot requests.

const (
	// RebootSkip is a noop.
	RebootSkip RebootPriority = iota
	// RebootAfterHook means wait for current hook to finish before
	// rebooting.
	RebootAfterHook
	// RebootNow means reboot immediately, killing and requeueing the
	// calling hook
	RebootNow
)

type RelationGetCommand

type RelationGetCommand struct {
	cmd.CommandBase

	RelationId int

	Application bool

	Key           string
	UnitOrAppName string
	// contains filtered or unexported fields
}

RelationGetCommand implements the relation-get command.

func (*RelationGetCommand) Info

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

Info is part of the cmd.Command interface.

func (*RelationGetCommand) Init

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

Init is part of the cmd.Command interface.

func (*RelationGetCommand) Run

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

func (*RelationGetCommand) SetFlags

func (c *RelationGetCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags is part of the cmd.Command interface.

type RelationHookContext

type RelationHookContext interface {
	HookContext
	// contains filtered or unexported methods
}

RelationHookContext is the context for a relation hook.

type RelationIdsCommand

type RelationIdsCommand struct {
	cmd.CommandBase

	Name string
	// contains filtered or unexported fields
}

RelationIdsCommand implements the relation-ids command.

func (*RelationIdsCommand) Info

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

func (*RelationIdsCommand) Init

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

func (*RelationIdsCommand) Run

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

func (*RelationIdsCommand) SetFlags

func (c *RelationIdsCommand) SetFlags(f *gnuflag.FlagSet)

type RelationListCommand

type RelationListCommand struct {
	cmd.CommandBase

	RelationId int

	ListRemoteApplication bool
	// contains filtered or unexported fields
}

RelationListCommand implements the relation-list command.

func (*RelationListCommand) Info

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

func (*RelationListCommand) Init

func (c *RelationListCommand) Init(args []string) (err error)

func (*RelationListCommand) Run

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

func (*RelationListCommand) SetFlags

func (c *RelationListCommand) SetFlags(f *gnuflag.FlagSet)

type RelationSetCommand

type RelationSetCommand struct {
	cmd.CommandBase

	RelationId int

	Settings map[string]string

	Application bool
	// contains filtered or unexported fields
}

RelationSetCommand implements the relation-set command.

func (*RelationSetCommand) Info

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

func (*RelationSetCommand) Init

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

func (*RelationSetCommand) Run

func (c *RelationSetCommand) Run(ctx *cmd.Context) (err error)

func (*RelationSetCommand) SetFlags

func (c *RelationSetCommand) SetFlags(f *gnuflag.FlagSet)

type Request

type Request struct {
	ContextId   string
	Dir         string
	CommandName string
	Args        []string

	// StdinSet indicates whether or not the client supplied stdin. This is
	// necessary as Stdin will be nil if the client supplied stdin but it
	// is empty.
	StdinSet bool
	Stdin    []byte
}

Request contains the information necessary to run a Command remotely.

type ResourceGetCmd

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

ResourceGetCmd provides the functionality of the resource-get command.

func (ResourceGetCmd) Info

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

Info implements cmd.Command.

func (*ResourceGetCmd) Init

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

Init implements cmd.Command.

func (ResourceGetCmd) Run

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

Run implements cmd.Command.

type RestrictedContext

type RestrictedContext struct{}

RestrictedContext is a base implementation for restricted contexts to embed, so that an error is returned for methods that are not explicitly implemented.

func (*RestrictedContext) ActionParams

func (*RestrictedContext) ActionParams() (map[string]interface{}, error)

ActionParams implements hooks.Context.

func (*RestrictedContext) AddMetric

func (*RestrictedContext) AddMetric(string, string, time.Time) error

AddMetric implements hooks.Context.

func (*RestrictedContext) AddMetricLabels

func (*RestrictedContext) AddMetricLabels(string, string, time.Time, map[string]string) error

AddMetricLabels implements hooks.Context.

func (*RestrictedContext) AddUnitStorage

func (*RestrictedContext) AddUnitStorage(map[string]params.StorageDirectives) error

AddUnitStorage implements hooks.Context.

func (*RestrictedContext) ApplicationStatus

ApplicationStatus implements hooks.Context.

func (*RestrictedContext) AvailabilityZone

func (*RestrictedContext) AvailabilityZone() (string, error)

AvailabilityZone implements hooks.Context.

func (*RestrictedContext) ClosePortRange

func (*RestrictedContext) ClosePortRange(string, network.PortRange) error

ClosePortRange implements hooks.Context.

func (*RestrictedContext) CloudSpec

CloudSpec implements hooks.Context.

func (*RestrictedContext) ConfigSettings

func (*RestrictedContext) ConfigSettings(context.Context) (charm.Settings, error)

ConfigSettings implements hooks.Context.

func (*RestrictedContext) CreateSecret

func (ctx *RestrictedContext) CreateSecret(_ context.Context, args *SecretCreateArgs) (*secrets.URI, error)

CreateSecret implements runner.Context.

func (*RestrictedContext) DeleteCharmStateValue

func (*RestrictedContext) DeleteCharmStateValue(context.Context, string) error

DeleteCharmStateValue implements jujuc.unitCharmStateContext.

func (*RestrictedContext) DownloadResource

func (ctx *RestrictedContext) DownloadResource(_ context.Context, name string) (filePath string, _ error)

DownloadResource implements hooks.Context.

func (*RestrictedContext) FlushPayloads

func (ctx *RestrictedContext) FlushPayloads(_ context.Context) error

FlushPayloads pushes the hook context data out to state.

func (*RestrictedContext) GetCharmState

func (*RestrictedContext) GetCharmState(context.Context) (map[string]string, error)

GetCharmState implements jujuc.unitCharmStateContext.

func (*RestrictedContext) GetCharmStateValue

func (*RestrictedContext) GetCharmStateValue(context.Context, string) (string, error)

GetCharmStateValue implements jujuc.unitCharmStateContext.

func (*RestrictedContext) GetPayload

func (ctx *RestrictedContext) GetPayload(class, id string) (*payloads.Payload, error)

GetPayload implements hooks.Context.

func (*RestrictedContext) GetSecret

GetSecret implements runner.Context.

func (*RestrictedContext) GoalState

GoalState implements hooks.Context.

func (*RestrictedContext) GrantSecret

GrantSecret implements runner.Context.

func (*RestrictedContext) HookRelation

func (*RestrictedContext) HookRelation() (ContextRelation, error)

HookRelation implements hooks.Context.

func (*RestrictedContext) HookStorage

HookStorage implements hooks.Context.

func (*RestrictedContext) IsLeader

func (*RestrictedContext) IsLeader() (bool, error)

IsLeader implements hooks.Context.

func (*RestrictedContext) LeaderSettings

func (*RestrictedContext) LeaderSettings(_ context.Context) (map[string]string, error)

LeaderSettings implements hooks.Context.

func (*RestrictedContext) ListPayloads

func (ctx *RestrictedContext) ListPayloads() ([]string, error)

ListPayloads implements hooks.Context.

func (*RestrictedContext) LogActionMessage

func (*RestrictedContext) LogActionMessage(context.Context, string) error

LogActionMessage implements hooks.Context.

func (*RestrictedContext) NetworkInfo

func (*RestrictedContext) NetworkInfo(_ context.Context, bindingNames []string, relationId int) (map[string]params.NetworkInfoResult, error)

NetworkInfo implements hooks.Context.

func (*RestrictedContext) OpenPortRange

func (*RestrictedContext) OpenPortRange(string, network.PortRange) error

OpenPortRange implements hooks.Context.

func (*RestrictedContext) OpenedPortRanges

func (*RestrictedContext) OpenedPortRanges() network.GroupedPortRanges

OpenedPortRanges implements hooks.Context.

func (*RestrictedContext) PrivateAddress

func (*RestrictedContext) PrivateAddress() (string, error)

PrivateAddress implements hooks.Context.

func (*RestrictedContext) PublicAddress

func (*RestrictedContext) PublicAddress(_ context.Context) (string, error)

PublicAddress implements hooks.Context.

func (*RestrictedContext) Relation

func (*RestrictedContext) Relation(id int) (ContextRelation, error)

Relation implements hooks.Context.

func (*RestrictedContext) RelationIds

func (*RestrictedContext) RelationIds() ([]int, error)

RelationIds implements hooks.Context.

func (*RestrictedContext) RemoteApplicationName

func (*RestrictedContext) RemoteApplicationName() (string, error)

RemoteApplicationName implements hooks.Context.

func (*RestrictedContext) RemoteUnitName

func (*RestrictedContext) RemoteUnitName() (string, error)

RemoteUnitName implements hooks.Context.

func (*RestrictedContext) RemoveSecret

func (ctx *RestrictedContext) RemoveSecret(*secrets.URI, *int) error

func (*RestrictedContext) RequestReboot

func (*RestrictedContext) RequestReboot(prio RebootPriority) error

RequestReboot implements hooks.Context.

func (*RestrictedContext) RevokeSecret

RevokeSecret implements runner.Context.

func (*RestrictedContext) SecretMetadata

func (ctx *RestrictedContext) SecretMetadata() (map[string]SecretMetadata, error)

func (*RestrictedContext) SetActionFailed

func (*RestrictedContext) SetActionFailed() error

SetActionFailed implements hooks.Context.

func (*RestrictedContext) SetActionMessage

func (*RestrictedContext) SetActionMessage(string) error

SetActionMessage implements hooks.Context.

func (*RestrictedContext) SetApplicationStatus

func (*RestrictedContext) SetApplicationStatus(context.Context, StatusInfo) error

SetApplicationStatus implements hooks.Context.

func (*RestrictedContext) SetCharmStateValue

func (*RestrictedContext) SetCharmStateValue(context.Context, string, string) error

SetCharmStateValue implements jujuc.unitCharmStateContext.

func (*RestrictedContext) SetPayloadStatus

func (ctx *RestrictedContext) SetPayloadStatus(_ context.Context, class, id, status string) error

SetPayloadStatus implements hooks.Context.

func (*RestrictedContext) SetUnitStatus

SetUnitStatus implements hooks.Context.

func (*RestrictedContext) SetUnitWorkloadVersion

func (*RestrictedContext) SetUnitWorkloadVersion(context.Context, string) error

SetUnitWorkloadVersion implements hooks.Context.

func (*RestrictedContext) Storage

func (*RestrictedContext) Storage(context.Context, names.StorageTag) (ContextStorageAttachment, error)

Storage implements hooks.Context.

func (*RestrictedContext) StorageTags

func (*RestrictedContext) StorageTags(_ context.Context) ([]names.StorageTag, error)

StorageTags implements hooks.Context.

func (*RestrictedContext) TrackPayload

func (ctx *RestrictedContext) TrackPayload(payload payloads.Payload) error

TrackPayload implements hooks.Context.

func (*RestrictedContext) UnitStatus

UnitStatus implements hooks.Context.

func (*RestrictedContext) UnitWorkloadVersion

func (*RestrictedContext) UnitWorkloadVersion(context.Context) (string, error)

UnitWorkloadVersion implements hooks.Context.

func (*RestrictedContext) UntrackPayload

func (ctx *RestrictedContext) UntrackPayload(_ context.Context, class, id string) error

UntrackPayload implements hooks.Context.

func (*RestrictedContext) UpdateActionResults

func (*RestrictedContext) UpdateActionResults(keys []string, value interface{}) error

UpdateActionResults implements hooks.Context.

func (*RestrictedContext) UpdateSecret

func (ctx *RestrictedContext) UpdateSecret(*secrets.URI, *SecretUpdateArgs) error

UpdateSecret implements runner.Context.

func (*RestrictedContext) WorkloadName

func (*RestrictedContext) WorkloadName() (string, error)

WorkloadName implements hooks.Context.

func (*RestrictedContext) WriteLeaderSettings

func (*RestrictedContext) WriteLeaderSettings(context.Context, map[string]string) error

WriteLeaderSettings implements hooks.Context.

type SecretCreateArgs

type SecretCreateArgs struct {
	SecretUpdateArgs

	Owner secrets.Owner
}

SecretCreateArgs specifies args used to create a secret. Nil values are not included in the create.

type SecretGrantRevokeArgs

type SecretGrantRevokeArgs struct {
	ApplicationName *string
	UnitName        *string
	RelationKey     *string
	Role            *secrets.SecretRole
}

SecretGrantRevokeArgs specify the args used to grant or revoke access to a secret.

type SecretMetadata

type SecretMetadata struct {
	Owner            secrets.Owner
	Description      string
	Label            string
	RotatePolicy     secrets.RotatePolicy
	LatestRevision   int
	LatestExpireTime *time.Time
	LatestChecksum   string
	NextRotateTime   *time.Time
	Revisions        []int
	Access           []secrets.AccessInfo
}

SecretMetadata holds a secret's metadata.

type SecretUpdateArgs

type SecretUpdateArgs struct {
	// Value is the new secret value or nil to not update.
	Value secrets.SecretValue

	RotatePolicy *secrets.RotatePolicy
	ExpireTime   *time.Time

	Description *string
	Label       *string
}

SecretUpdateArgs specifies args used to update a secret. Nil values are not included in the update.

type Server

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

Server implements a server that serves command invocations via a unix domain socket.

func NewServer

func NewServer(getCmd CmdGetter, socket sockets.Socket) (*Server, error)

NewServer creates an RPC server bound to socketPath, which can execute remote command invocations against an appropriate Context. It will not actually do so until Run is called.

func (*Server) Close

func (s *Server) Close()

Close immediately stops accepting connections, and blocks until all existing connections have been closed.

func (*Server) Run

func (s *Server) Run() (err error)

Run accepts new connections until it encounters an error, or until Close is called, and then blocks until all existing connections have been closed.

type Settings

type Settings interface {
	Map() params.Settings
	Set(string, string)
	Delete(string)
}

Settings is implemented by types that manipulate unit settings.

type StateDeleteCommand

type StateDeleteCommand struct {
	cmd.CommandBase

	Key string // The key to delete
	// contains filtered or unexported fields
}

StateDeleteCommand implements the state-delete command.

func (*StateDeleteCommand) Info

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

Info returns information about the Command. Info implements part of the cmd.Command interface.

func (*StateDeleteCommand) Init

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

Init initializes the Command before running. Init implements part of the cmd.Command interface.

func (*StateDeleteCommand) Run

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

Run will execute the Command as directed by the options and positional arguments passed to Init. Run implements part of the cmd.Command interface.

type StateGetCommand

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

StateGetCommand implements the state-get command.

func (*StateGetCommand) Info

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

Info returns information about the Command. Info implements part of the cmd.Command interface.

func (*StateGetCommand) Init

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

Init initializes the Command before running. Init implements part of the cmd.Command interface.

func (*StateGetCommand) Run

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

Run will execute the Command as directed by the options and positional arguments passed to Init. Run implements part of the cmd.Command interface.

func (*StateGetCommand) SetFlags

func (c *StateGetCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags adds command specific flags to the flag set. SetFlags implements part of the cmd.Command interface.

type StateSetCommand

type StateSetCommand struct {
	cmd.CommandBase

	StateValues map[string]string
	// contains filtered or unexported fields
}

StateSetCommand implements the state-set command.

func (*StateSetCommand) Info

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

Info returns information about the Command. Info implements part of the cmd.Command interface.

func (*StateSetCommand) Init

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

Init initializes the Command before running. Init implements part of the cmd.Command interface.

func (*StateSetCommand) Run

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

Run will execute the Command as directed by the options and positional arguments passed to Init. Run implements part of the cmd.Command interface.

func (*StateSetCommand) SetFlags

func (c *StateSetCommand) SetFlags(f *gnuflag.FlagSet)

SetFlags adds command specific flags to the flag set. SetFlags implements part of the cmd.Command interface.

type StatusGetCommand

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

StatusGetCommand implements the status-get command.

func (*StatusGetCommand) ApplicationStatus

func (c *StatusGetCommand) ApplicationStatus(ctx *cmd.Context) error

func (*StatusGetCommand) Info

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

func (*StatusGetCommand) Init

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

func (*StatusGetCommand) Run

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

func (*StatusGetCommand) SetFlags

func (c *StatusGetCommand) SetFlags(f *gnuflag.FlagSet)

type StatusInfo

type StatusInfo struct {
	Tag    string
	Status string
	Info   string
	Data   map[string]interface{}
}

StatusInfo is a record of the status information for a application or a unit's workload.

type StatusSetCommand

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

StatusSetCommand implements the status-set command.

func (*StatusSetCommand) Info

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

func (*StatusSetCommand) Init

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

func (*StatusSetCommand) Run

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

func (*StatusSetCommand) SetFlags

func (c *StatusSetCommand) SetFlags(f *gnuflag.FlagSet)

type StorageAddCommand

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

StorageAddCommand implements the status-set command.

func (*StorageAddCommand) Info

func (s *StorageAddCommand) Info() *cmd.Info

func (*StorageAddCommand) Init

func (s *StorageAddCommand) Init(args []string) error

func (*StorageAddCommand) Run

func (s *StorageAddCommand) Run(ctx *cmd.Context) error

type StorageGetCommand

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

StorageGetCommand implements the storage-get command.

func (*StorageGetCommand) Info

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

func (*StorageGetCommand) Init

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

func (*StorageGetCommand) Run

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

func (*StorageGetCommand) SetFlags

func (c *StorageGetCommand) SetFlags(f *gnuflag.FlagSet)

type StorageListCommand

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

StorageListCommand implements the storage-list command.

StorageListCommand implements cmd.Command.

func (*StorageListCommand) Info

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

func (*StorageListCommand) Init

func (c *StorageListCommand) Init(args []string) (err error)

func (*StorageListCommand) Run

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

func (*StorageListCommand) SetFlags

func (c *StorageListCommand) SetFlags(f *gnuflag.FlagSet)

type UnitGetCommand

type UnitGetCommand struct {
	cmd.CommandBase

	Key string
	// contains filtered or unexported fields
}

UnitGetCommand implements the unit-get command.

func (*UnitGetCommand) Info

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

func (*UnitGetCommand) Init

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

func (*UnitGetCommand) Run

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

func (*UnitGetCommand) SetFlags

func (c *UnitGetCommand) SetFlags(f *gnuflag.FlagSet)

type UnitHookContext

type UnitHookContext interface {
	HookContext
}

UnitHookContext is the context for a unit hook.

type WorkloadHookContext

type WorkloadHookContext interface {
	HookContext
	// contains filtered or unexported methods
}

WorkloadHookContext is the context for a workload hook.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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