juju: github.com/wallyworld/juju/worker/caasoperator Index | Files | Directories

package caasoperator

import "github.com/wallyworld/juju/worker/caasoperator"


Package Files

action.go caasoperator.go client.go download.go initializer.go localstate.go manifold.go paths.go


var ErrNoStateFile = errors.New("operator state file does not exist")

ErrNoStateFile is used to indicate an operator state file does not exist.

func LoadOperatorInfo Uses

func LoadOperatorInfo(paths Paths) (*caas.OperatorInfo, error)

LoadOperatorInfo loads the operator info file from the state dir.

func Manifold Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a dependency manifold that runs a caasoperator worker, using the resource names defined in the supplied config.

func NewWorker Uses

func NewWorker(config Config) (worker.Worker, error)

NewWorker creates a new worker which will install and operate a CaaS-based application, by executing hooks and operations in response to application state changes.

type ApplicationWatcher Uses

type ApplicationWatcher interface {
    Watch(string) (watcher.NotifyWatcher, error)

ApplicationWatcher provides an interface watching for application changes.

type CharmConfigGetter Uses

type CharmConfigGetter interface {
    CharmConfig(string) (charm.Settings, error)
    WatchCharmConfig(string) (watcher.NotifyWatcher, error)

CharmConfigGetter provides an interface for watching and getting the application's charm config settings.

type CharmGetter Uses

type CharmGetter interface {
    Charm(application string) (*caasoperatorapi.CharmInfo, error)

CharmGetter provides an interface for getting the URL and SHA256 hash of the charm currently assigned to the application.

type Client Uses

type Client interface {
    Model() (*model.Model, error)

Client provides an interface for interacting with the CAASOperator API. Subsets of this should be passed to the CAASOperator worker.

type Config Uses

type Config struct {
    Logger Logger

    // ModelUUID is the UUID of the model.
    ModelUUID string

    // ModelName is the name of the model.
    ModelName string

    // Application holds the name of the application that
    // this CAAS operator manages.
    Application string

    // CharmGetter is an interface used for getting the
    // application's charm URL and SHA256 hash.
    CharmGetter CharmGetter

    // Clock holds the clock to be used by the CAAS operator
    // for time-related operations.
    Clock clock.Clock

    // DataDir holds the path to the Juju "data directory",
    // i.e. "/var/lib/juju" (by default). The CAAS operator
    // expects to find the jujud binary at <data-dir>/tools/jujud.
    DataDir string

    // ProfileDir is where the introspection scripts are written.
    ProfileDir string

    // Downloader is an interface used for downloading the
    // application charm.
    Downloader Downloader

    // StatusSetter is an interface used for setting the
    // application status.
    StatusSetter StatusSetter

    // UnitGetter is an interface for getting a unit.
    UnitGetter UnitGetter

    // UnitRemover is an interface for removing a unit.
    UnitRemover UnitRemover

    // ApplicationWatcher is an interface for getting info about an application's charm.
    ApplicationWatcher ApplicationWatcher

    // ContainerStartWatcher provides an interface for watching
    // for unit container starts.
    ContainerStartWatcher ContainerStartWatcher

    // VersionSetter is an interface for setting the operator agent version.
    VersionSetter VersionSetter

    // LeadershipTrackerFunc is a function for getting a leadership tracker worker.
    LeadershipTrackerFunc func(unitTag names.UnitTag) leadership.TrackerWorker

    // UniterFacadeFunc is a function for making a uniter facade.
    UniterFacadeFunc func(unitTag names.UnitTag) *apiuniter.State

    // UniterParams are parameters used to construct a uniter worker.
    UniterParams *uniter.UniterParams

    // StartUniterFunc starts a uniter worker using the given runner.
    StartUniterFunc func(runner *worker.Runner, params *uniter.UniterParams) error

    // RunListenerSocketFunc returns a socket used for the juju run listener.
    RunListenerSocketFunc func(*uniter.SocketConfig) (*sockets.Socket, error)

    // OperatorInfo contains serving information such as Certs and PrivateKeys.
    OperatorInfo caas.OperatorInfo

    // ExecClientGetter returns an exec client for initializing caas units.
    ExecClientGetter func() (exec.Executor, error)

Config hold the configuration for a caasoperator worker.

func (Config) Validate Uses

func (config Config) Validate() error

type ContainerStartWatcher Uses

type ContainerStartWatcher interface {
    WatchContainerStart(string, string) (watcher.StringsWatcher, error)

ContainerStartWatcher provides an interface for watching for unit starts.

type Downloader Uses

type Downloader interface {
    // Download downloads a file to a local directory, and
    // returns the local path to the file.
    Download(downloader.Request) (string, error)

Downloader provides an interface for downloading files to disk.

type LocalState Uses

type LocalState struct {
    // CharmModifiedVersion increases any time the charm,
    // or any part of it, is changed in some way.
    CharmModifiedVersion int

    // CharmURL reports the currently installed charm URL. This is set
    // by the committing of deploy (install/upgrade) ops.
    CharmURL *charm.URL

LocalState is a cache of the state of the operator It is generally compared to the remote state of the the application as stored in the controller.

type Logger Uses

type Logger interface {
    Debugf(string, ...interface{})
    Infof(string, ...interface{})
    Errorf(string, ...interface{})
    Warningf(string, ...interface{})

type ManifoldConfig Uses

type ManifoldConfig struct {
    Logger Logger

    AgentName     string
    APICallerName string
    ClockName     string

    MachineLock           machinelock.Lock
    LeadershipGuarantee   time.Duration
    CharmDirName          string
    ProfileDir            string
    HookRetryStrategyName string
    TranslateResolverErr  func(error) error

    NewWorker          func(Config) (worker.Worker, error)
    NewClient          func(base.APICaller) Client
    NewCharmDownloader func(base.APICaller) Downloader

    NewExecClient     func(namespace string) (exec.Executor, error)
    RunListenerSocket func(*uniter.SocketConfig) (*sockets.Socket, error)

    LoadOperatorInfo func(paths Paths) (*caas.OperatorInfo, error)

    NewContainerStartWatcherClient func(Client) ContainerStartWatcher

ManifoldConfig defines the names of the manifolds on which a Manifold will depend.

func (ManifoldConfig) Validate Uses

func (config ManifoldConfig) Validate() error

type Paths Uses

type Paths struct {

    // ToolsDir is the directory containing the jujud executable running this
    // process; and also containing hook tool symlinks to that executable. It's
    // the only path in this struct that is not typically pointing inside the
    // directory reserved for the exclusive use of this worker (typically
    // /var/lib/juju/tools )
    ToolsDir string

    // Runtime represents the set of paths that are relevant at runtime.
    Runtime RuntimePaths

    // State represents the set of paths that hold persistent local state for
    // the operator.
    State StatePaths

Paths represents the set of filesystem paths a caasoperator worker has reason to care about.

func NewPaths Uses

func NewPaths(dataDir string, applicationTag names.ApplicationTag) Paths

NewPaths returns the set of filesystem paths that the supplied unit should use, given the supplied root juju data directory path.

func (Paths) ComponentDir Uses

func (paths Paths) ComponentDir(name string) string

ComponentDir returns the filesystem path to the directory containing all data files for a component.

func (Paths) GetBaseDir Uses

func (paths Paths) GetBaseDir() string

GetBaseDir exists to satisfy the context.Paths interface.

func (Paths) GetCharmDir Uses

func (paths Paths) GetCharmDir() string

GetCharmDir exists to satisfy the context.Paths interface.

func (Paths) GetMetricsSpoolDir Uses

func (paths Paths) GetMetricsSpoolDir() string

GetMetricsSpoolDir exists to satisfy the runner.Paths interface.

func (Paths) GetToolsDir Uses

func (paths Paths) GetToolsDir() string

GetToolsDir exists to satisfy the context.Paths interface.

type RuntimePaths Uses

type RuntimePaths struct {

    // JujuRunSocket listens for juju-run invocations, and is always
    // active.
    JujuRunSocket string

    // HookCommandServerSocket listens for hook command invocations, and is only
    // active when supporting a hook execution context.
    HookCommandServerSocket string

RuntimePaths represents the set of paths that are relevant at runtime.

type StateFile Uses

type StateFile struct {
    // contains filtered or unexported fields

StateFile holds the disk state for an operator.

func NewStateFile Uses

func NewStateFile(path string) *StateFile

NewStateFile returns a new StateFile using path.

func (*StateFile) Read Uses

func (f *StateFile) Read() (*LocalState, error)

Read reads a State from the file. If the file does not exist it returns ErrNoStateFile.

func (*StateFile) Write Uses

func (f *StateFile) Write(st *LocalState) error

Write stores the supplied state to the file.

type StatePaths Uses

type StatePaths struct {

    // BaseDir is the operator's base directory.
    BaseDir string

    // CharmDir is the directory to which the charm the operator runs is deployed.
    CharmDir string

    // OperationsFile holds information about what the operator is doing
    // and/or has done.
    OperationsFile string

    // BundlesDir holds downloaded charms.
    BundlesDir string

    // DeployerDir holds metadata about charms that are installing or have
    // been installed.
    DeployerDir string

    // MetricsSpoolDir acts as temporary storage for metrics being sent from
    // the operator to state.
    MetricsSpoolDir string

StatePaths represents the set of paths that hold persistent local state for the operator.

type StatusSetter Uses

type StatusSetter interface {
    // SetStatus sets the status of an application.
        application string,
        status status.Status,
        info string,
        data map[string]interface{},
    ) error

StatusSetter provides an interface for setting the status of a CAAS application.

type UnitGetter Uses

type UnitGetter interface {
    WatchUnits(string) (watcher.StringsWatcher, error)
    Life(string) (life.Value, error)

UnitGetter provides an interface for watching for the lifecycle state changes (including addition) of a specified application's units, and fetching their details.

type UnitRemover Uses

type UnitRemover interface {
    RemoveUnit(string) error

UnitRemover provides an interface for removing a unit.

type VersionSetter Uses

type VersionSetter interface {
    SetVersion(appName string, v version.Binary) error

VersionSetter provides an interface for setting the operator agent version.


mocksPackage mocks is a generated GoMock package.

Package caasoperator imports 59 packages (graph). Updated 2020-08-11. Refresh now. Tools for package owners.