juju: github.com/juju/juju/worker/apicaller Index | Files

package apicaller

import "github.com/juju/juju/worker/apicaller"

Index

Package Files

connect.go manifold.go worker.go

Variables

var (

    // ErrConnectImpossible indicates that we can contact an apiserver
    // but have no hope of authenticating a connection with it.
    ErrConnectImpossible = errors.New("connection permanently impossible")

    // ErrChangedPassword indicates that the agent config used to connect
    // has been updated with a new password, and you should try again.
    ErrChangedPassword = errors.New("insecure password replaced; retry")
)

func Manifold Uses

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a manifold whose worker wraps an API connection made as configured.

func NewExternalControllerConnection Uses

func NewExternalControllerConnection(apiInfo *api.Info) (api.Connection, error)

NewExternalControllerConnection returns an api connection to a controller with the specified api info.

func OnlyConnect Uses

func OnlyConnect(a agent.Agent, apiOpen api.OpenFunc, logger Logger) (api.Connection, error)

OnlyConnect logs into the API using the supplied agent's credentials.

func ScaryConnect Uses

func ScaryConnect(a agent.Agent, apiOpen api.OpenFunc, logger Logger) (_ api.Connection, err error)

ScaryConnect logs into the API using the supplied agent's credentials, like OnlyConnect; and then:

* returns ErrConnectImpossible if the agent entity is dead or
  unauthorized for all known passwords;
* replaces insecure credentials with freshly (locally) generated ones
  (and returns ErrPasswordChanged, expecting to be reinvoked);
* unconditionally resets the remote-state password to its current value
  (for what seems like a bad reason).

This is clearly a mess but at least now it's a documented and localized mess; it should be used only when making the primary API connection for a machine or unit agent running in its own process.

type ConnectFunc Uses

type ConnectFunc func(agent.Agent, api.OpenFunc, Logger) (api.Connection, error)

ConnectFunc is responsible for making and validating an API connection on behalf of an agent.

type Logger Uses

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

Logger represents the methods used by the worker to log details.

type ManifoldConfig Uses

type ManifoldConfig struct {

    // AgentName is the name of the Agent resource that supplies
    // connection information.
    AgentName string

    // APIConfigWatcherName identifies a resource that will be
    // invalidated when api configuration changes. It's not really
    // fundamental, because it's not used directly, except to create
    // Inputs; it would be perfectly reasonable to wrap a Manifold
    // to report an extra Input instead.
    APIConfigWatcherName string

    // APIOpen is passed into NewConnection, and should be used to
    // create an API connection. You should probably just set it to
    // the local APIOpen func.
    APIOpen api.OpenFunc

    // NewConnection is responsible for getting a connection from an
    // agent, and may be responsible for other things that need to be
    // done before anyone else gets to see the connection.
    //
    // You should probably set it to ScaryConnect when running a
    // machine agent, and to OnlyConnect when running a model agent
    // (which doesn't have its own process). Unit agents should use
    // ScaryConnect at the moment; and probably switch to OnlyConnect
    // when they move into machine agent processes.
    NewConnection ConnectFunc

    // Filter is used to specialize responses to connection errors
    // made on behalf of different kinds of agent.
    Filter dependency.FilterFunc

    // Logger is used to write logging statements for the worker.
    Logger Logger
}

ManifoldConfig defines a Manifold's dependencies.

type NewExternalControllerConnectionFunc Uses

type NewExternalControllerConnectionFunc func(*api.Info) (api.Connection, error)

NewExternalControllerConnectionFunc returns a function returning an api connection to a controller with the specified api info.

Package apicaller imports 13 packages (graph) and is imported by 109 packages. Updated 2019-10-09. Refresh now. Tools for package owners.