Documentation ¶
Index ¶
- Constants
- Variables
- func Actions(args params.Entities, actionFn func(string) (state.Action, error)) params.ActionResults
- func AuthAndActionFromTagFn(canAccess AuthFunc, getActionByTag func(names.ActionTag) (state.Action, error)) func(string) (state.Action, error)
- func BeginActions(args params.Entities, actionFn func(string) (state.Action, error)) params.ErrorResults
- func CharmArchiveEntry(charmPath, entryPath string, wantIcon bool) ([]byte, error)
- func ClassifyDetachedStorage(storage []state.StorageInstance) (destroyed, detached []params.Entity)
- func ConvertActions(ar state.ActionReceiver, fn GetActionsFn) ([]params.ActionResult, error)
- func DestroyErr(desc string, ids []string, errs []error) error
- func DestroyMachines(st origStateInterface, force bool, ids ...string) error
- func DestroyModel(st ModelManagerBackend, modelTag names.ModelTag) error
- func DestroyModelIncludingHosted(st ModelManagerBackend, systemTag names.ModelTag) error
- func EntityStatusFromState(statusInfo status.StatusInfo) params.EntityStatus
- func FinishActions(args params.ActionExecutionResults, ...) params.ErrorResults
- func HasModelAdmin(authorizer facade.Authorizer, user names.UserTag, ...) (bool, error)
- func HasPermission(userGetter userAccessFunc, utag names.Tag, ...) (bool, error)
- func InstanceTypes(cons instanceTypeConstraints) (params.InstanceTypesResult, error)
- func IsDischargeRequiredError(err error) bool
- func IsUpgradeInProgressError(err error) bool
- func MachineStatus(machine MachineStatusGetter) (status.StatusInfo, error)
- func MakeActionResult(actionReceiverTag names.Tag, action state.Action) params.ActionResult
- func ModelMachineInfo(st ModelManagerBackend) (machineInfo []params.ModelMachineInfo, _ error)
- func ModelUserInfo(user permission.UserAccess, st modelConnectionAbleBackend) (params.ModelUserInfo, error)
- func NewInstanceTypeConstraints(env environs.Environ, constraints constraints.Value) instanceTypeConstraints
- func NewToolsURLGetter(modelUUID string, a APIHostPortsGetter) *toolsURLGetter
- func NoAddressSetError(unitTag names.UnitTag, addressName string) error
- func NotSupportedError(tag names.Tag, operation string) error
- func OperationBlockedError(msg string) error
- func ParamsActionExecutionResultsToStateActionResults(arg params.ActionExecutionResult) (state.ActionResults, error)
- func ReadCharmFromStorage(store storage.Storage, dataDir, storagePath string) (string, error)
- func RegisterFacade(name string, version int, factory facade.Factory, facadeType reflect.Type)
- func RegisterFacadeForFeature(name string, version int, factory facade.Factory, facadeType reflect.Type, ...)
- func RegisterHookContextFacade(name string, version int, newHookContextFacade NewHookContextFacadeFn, ...)
- func RegisterStandardFacade(name string, version int, newFunc interface{})
- func RegisterStandardFacadeForFeature(name string, version int, newFunc interface{}, feature string)
- func RestoreError(err error) error
- func ServerError(err error) *params.Error
- func ServerErrorAndStatus(err error) (*params.Error, int)
- func StateJobs(jobs []multiwatcher.MachineJob) ([]state.MachineJob, error)
- func StateToParamsUserAccessPermission(descriptionAccess permission.Access) (params.UserAccessPermission, error)
- func TagToActionReceiverFn(findEntity func(names.Tag) (state.Entity, error)) func(tag string) (state.ActionReceiver, error)
- func ToolsURL(serverRoot string, v version.Binary) string
- func UnitStatus(unit UnitStatusGetter) (agent StatusAndErr, workload StatusAndErr)
- func UnitStorage(st StorageAccessor, unit names.UnitTag) ([]state.StorageInstance, error)
- func UnknownModelError(uuid string) error
- func UserAccess(st *state.State, utag names.UserTag) (modelUser, controllerUser permission.UserAccess, err error)
- func WatchActionNotifications(args params.Entities, canAccess AuthFunc, ...) params.StringsWatchResults
- func WatchOneActionReceiverNotifications(tagToActionReceiver func(tag string) (state.ActionReceiver, error), ...) func(names.Tag) (params.StringsWatchResult, error)
- type APIAddresser
- func (api *APIAddresser) APIAddresses() (params.StringsResult, error)
- func (api *APIAddresser) APIHostPorts() (params.APIHostPortsResult, error)
- func (a *APIAddresser) CACert() params.BytesResult
- func (a *APIAddresser) ModelUUID() params.StringResult
- func (api *APIAddresser) WatchAPIHostPorts() (params.NotifyWatchResult, error)
- type APIHostPortsGetter
- type AddressAndCertGetter
- type AgentEntityWatcher
- type Application
- type ApplicationStatusGetter
- type ApplicationStatusSetter
- type AuthFunc
- type BlockChecker
- type BlockGetter
- type ControllerConfigAPI
- type DeadEnsurer
- type DischargeRequiredError
- type EnvironConfigGetterFuncs
- type GetActionsFn
- type GetAuthFunc
- type InstanceIdGetter
- type LifeGetter
- type Machine
- type MachineStatusGetter
- type Model
- type ModelMachinesWatcher
- type ModelManagerBackend
- type ModelStatusAPI
- type ModelWatcher
- type MultiNotifyWatcher
- type NewHookContextFacadeFn
- type PasswordChanger
- type RebootActionGetter
- type RebootFlagClearer
- type RebootRequester
- type Remover
- type Resources
- type StateAddresser
- type StatusAndErr
- type StatusGetter
- type StatusSetter
- type StorageAccessor
- type StringResource
- type ToolsFinder
- type ToolsGetter
- type ToolsSetter
- type ToolsStorageGetter
- type ToolsURLGetter
- type UnitAgentFinder
- type UnitStatusGetter
- type UnitsWatcher
- type ValueResource
Constants ¶
const DefaultCharmIcon = `` /* 9060-byte string literal not displayed */
DefaultCharmIcon holds the default charm icon SVG content. Keep this in sync with the default icon returned by the charm store.
const EveryoneTagName = "everyone@external"
EveryoneTagName represents a special group that encompasses all external users.
Variables ¶
var ( ErrBadId = errors.New("id not found") ErrBadCreds = errors.New("invalid entity name or password") ErrNoCreds = errors.New("no credentials provided") ErrLoginExpired = errors.New("login expired") ErrPerm = errors.New("permission denied") ErrNotLoggedIn = errors.New("not logged in") ErrUnknownWatcher = errors.New("unknown watcher id") ErrStoppedWatcher = errors.New("watcher has been stopped") ErrBadRequest = errors.New("invalid request") ErrTryAgain = errors.New("try again") ErrActionNotAvailable = errors.New("action no longer available") )
var Facades = &facade.Registry{}
Facades is the registry that tracks all of the Facades that will be exposed in the API. It can be used to List/Get/Register facades.
Most implementers of a facade will probably want to use RegisterStandardFacade rather than Facades.Register, as it provides much cleaner syntax and semantics for calling during init().
Developers in a happy future will not want to use Facades at all, eschewing globals in favour of explicitly building apis and supplying them directly to an apiserver.
Functions ¶
func Actions ¶
func Actions(args params.Entities, actionFn func(string) (state.Action, error)) params.ActionResults
Actions returns the Actions by Tags passed in and ensures that the receiver asking for them is the same one that has the action. It's a helper function currently used by the uniter and by machineactions. It needs an actionFn that can fetch an action from state using it's id that's usually created by AuthAndActionFromTagFn
func AuthAndActionFromTagFn ¶
func AuthAndActionFromTagFn(canAccess AuthFunc, getActionByTag func(names.ActionTag) (state.Action, error)) func(string) (state.Action, error)
AuthAndActionFromTagFn takes in an authorizer function and a function that can fetch action by tags from state and returns a function that can fetch an action from state by id and check the authorization.
func BeginActions ¶
func BeginActions(args params.Entities, actionFn func(string) (state.Action, error)) params.ErrorResults
BeginActions calls begin on every action passed in through args. It's a helper function currently used by the uniter and by machineactions It needs an actionFn that can fetch an action from state using it's id, that's usually created by AuthAndActionFromTagFn
func CharmArchiveEntry ¶
CharmArchiveEntry retrieves the specified entry from the zip archive.
func ClassifyDetachedStorage ¶
func ClassifyDetachedStorage(storage []state.StorageInstance) (destroyed, detached []params.Entity)
ClassifyDetachedStorage classifies storage instances into those that will be destroyed, and those that will be detached, when their attachment is removed.
func ConvertActions ¶
func ConvertActions(ar state.ActionReceiver, fn GetActionsFn) ([]params.ActionResult, error)
ConvertActions takes a generic getActionsFn to obtain a slice of state.Action and then converts them to the API slice of params.ActionResult.
func DestroyMachines ¶
func DestroyModel ¶
func DestroyModel(st ModelManagerBackend, modelTag names.ModelTag) error
DestroyModel sets the environment to dying. Cleanup jobs then destroy all services and non-manager, non-manual machine instances in the specified model. This function assumes that all necessary authentication checks have been done. An error will be returned if this model is a controller hosting other model.
func DestroyModelIncludingHosted ¶
func DestroyModelIncludingHosted(st ModelManagerBackend, systemTag names.ModelTag) error
DestroyModelIncludingHosted sets the model to dying. Cleanup jobs then destroy all services and non-manager, non-manual machine instances in the specified model. This function assumes that all necessary authentication checks have been done. If the model is a controller hosting other models, they will also be destroyed.
func EntityStatusFromState ¶
func EntityStatusFromState(statusInfo status.StatusInfo) params.EntityStatus
EntityStatusFromState converts a state.StatusInfo into a params.EntityStatus.
func FinishActions ¶
func FinishActions(args params.ActionExecutionResults, actionFn func(string) (state.Action, error)) params.ErrorResults
FinishActions saves the result of a completed Action. It's a helper function currently used by the uniter and by machineactions It needs an actionFn that can fetch an action from state using it's id that's usually created by AuthAndActionFromTagFn
func HasModelAdmin ¶
func HasModelAdmin( authorizer facade.Authorizer, user names.UserTag, controllerTag names.ControllerTag, model Model, ) (bool, error)
HasModelAdmin reports whether or not a user has admin access to the specified model. A user has model access if they are the model owner, if they are a controller superuser, or if they have been explicitly granted admin access to the model.
func HasPermission ¶
func HasPermission(userGetter userAccessFunc, utag names.Tag, requestedPermission permission.Access, target names.Tag) (bool, error)
HasPermission returns true if the specified user has the specified permission on target.
func InstanceTypes ¶
func InstanceTypes(cons instanceTypeConstraints) (params.InstanceTypesResult, error)
InstanceTypes returns a list of the available instance types in the provider according to the passed constraints.
func IsDischargeRequiredError ¶
IsDischargeRequiredError reports whether the cause of the error is a *DischargeRequiredError.
func IsUpgradeInProgressError ¶
IsUpgradeInProgress returns true if this error is caused by an upgrade in progress.
func MachineStatus ¶
func MachineStatus(machine MachineStatusGetter) (status.StatusInfo, error)
MachineStatus returns the machine agent status for a given machine, with special handling for agent presence.
func MakeActionResult ¶
func MakeActionResult(actionReceiverTag names.Tag, action state.Action) params.ActionResult
MakeActionResult does the actual type conversion from state.Action to params.ActionResult.
func ModelMachineInfo ¶
func ModelMachineInfo(st ModelManagerBackend) (machineInfo []params.ModelMachineInfo, _ error)
ModelMachineInfo returns information about machine hardware for alive top level machines (not containers).
func ModelUserInfo ¶
func ModelUserInfo(user permission.UserAccess, st modelConnectionAbleBackend) (params.ModelUserInfo, error)
ModelUserInfo converts permission.UserAccess to params.ModelUserInfo.
func NewInstanceTypeConstraints ¶
func NewInstanceTypeConstraints(env environs.Environ, constraints constraints.Value) instanceTypeConstraints
NewInstanceTypeConstraints returns an instanceTypeConstraints with the passed parameters.
func NewToolsURLGetter ¶
func NewToolsURLGetter(modelUUID string, a APIHostPortsGetter) *toolsURLGetter
NewToolsURLGetter creates a new ToolsURLGetter that returns tools URLs pointing at an API server.
func NoAddressSetError ¶
func NotSupportedError ¶
func OperationBlockedError ¶
OperationBlockedError returns an error which signifies that an operation has been blocked; the message should describe what has been blocked.
func ParamsActionExecutionResultsToStateActionResults ¶
func ParamsActionExecutionResultsToStateActionResults(arg params.ActionExecutionResult) (state.ActionResults, error)
ParamsActionExecutionResultsToStateActionResults does exactly what the name implies.
func ReadCharmFromStorage ¶
ReadCharmFromStorage fetches the charm at the specified path from the store and copies it to a temp directory in dataDir.
func RegisterFacade ¶
RegisterFacade updates the global facade registry with a new version of a new type.
func RegisterFacadeForFeature ¶
func RegisterFacadeForFeature(name string, version int, factory facade.Factory, facadeType reflect.Type, feature string)
RegisterFacadeForFeature updates the global facade registry with a new version of a new type. If the feature is non-empty, this facade is only available when the specified feature flag is set.
func RegisterHookContextFacade ¶
func RegisterHookContextFacade(name string, version int, newHookContextFacade NewHookContextFacadeFn, facadeType reflect.Type)
RegisterHookContextFacade registers facades for use within a hook context. This function handles the translation from a hook-context-facade to a standard facade so the caller's factory method can elide unnecessary arguments. This function also handles any necessary authorization for the client.
XXX(fwereade): this is fundamentally broken, because it (1) arbitrarily creates a new facade for a tiny fragment of a specific client worker's reponsibilities and (2) actively conceals necessary auth information from the facade. Don't call it; actively work to delete code that uses it, and rewrite it properly.
func RegisterStandardFacade ¶
RegisterStandardFacade registers a factory function for a normal New* style function. This requires that the function has the form: NewFoo(*state.State, facade.Resources, facade.Authorizer) (*Type, error) With that syntax, we will create a helper function that wraps calling NewFoo with the right parameters, and returns the *Type correctly.
func RegisterStandardFacadeForFeature ¶
func RegisterStandardFacadeForFeature(name string, version int, newFunc interface{}, feature string)
RegisterStandardFacadeForFeature registers a factory function for a normal New* style function. This requires that the function has the form: NewFoo(*state.State, facade.Resources, facade.Authorizer) (*Type, error) With that syntax, we will create a helper function that wraps calling NewFoo with the right parameters, and returns the *Type correctly. If the feature is non-empty, this facade is only available when the specified feature flag is set.
func RestoreError ¶
RestoreError makes a best effort at converting the given error back into an error originally converted by ServerError().
func ServerError ¶
ServerError returns an error suitable for returning to an API client, with an error code suitable for various kinds of errors generated in packages outside the API.
func ServerErrorAndStatus ¶
ServerErrorAndStatus is like ServerError but also returns an HTTP status code appropriate for using in a response holding the given error.
func StateJobs ¶
func StateJobs(jobs []multiwatcher.MachineJob) ([]state.MachineJob, error)
StateJobs translates a slice of multiwatcher jobs to their equivalents in state.
func StateToParamsUserAccessPermission ¶
func StateToParamsUserAccessPermission(descriptionAccess permission.Access) (params.UserAccessPermission, error)
StateToParamsUserAccessPermission converts permission.Access to params.AccessPermission.
func TagToActionReceiverFn ¶
func TagToActionReceiverFn(findEntity func(names.Tag) (state.Entity, error)) func(tag string) (state.ActionReceiver, error)
TagToActionReceiver takes a tag string and tries to convert it to an ActionReceiver. It needs a findEntity function passed in that can search for the tags in state.
func UnitStatus ¶
func UnitStatus(unit UnitStatusGetter) (agent StatusAndErr, workload StatusAndErr)
UnitStatus returns the unit agent and workload status for a given unit, with special handling for agent presence.
func UnitStorage ¶
func UnitStorage(st StorageAccessor, unit names.UnitTag) ([]state.StorageInstance, error)
UnitStorage returns the storage instances attached to the specified unit.
func UnknownModelError ¶
func UserAccess ¶
func UserAccess(st *state.State, utag names.UserTag) (modelUser, controllerUser permission.UserAccess, err error)
UserAccess returns the access the user has on the model state and the host controller.
func WatchActionNotifications ¶
func WatchActionNotifications(args params.Entities, canAccess AuthFunc, watchOne func(names.Tag) (params.StringsWatchResult, error)) params.StringsWatchResults
WatchActionNotifications returns a StringsWatcher for observing incoming actions towards an actionreceiver. It's a helper function currently used by the uniter and by machineactions canAccess is passed in by the respective caller to provide authorization. watchOne is usually a function created by WatchOneActionReceiverNotifications
func WatchOneActionReceiverNotifications ¶
func WatchOneActionReceiverNotifications(tagToActionReceiver func(tag string) (state.ActionReceiver, error), registerFunc func(r facade.Resource) string) func(names.Tag) (params.StringsWatchResult, error)
WatchOneActionReceiverNotifications to create a watcher for one receiver. It needs a tagToActionReceiver function and a registerFunc to register resources. It's a helper function currently used by the uniter and by machineactions
Types ¶
type APIAddresser ¶
type APIAddresser struct {
// contains filtered or unexported fields
}
APIAddresser implements the APIAddresses method
func NewAPIAddresser ¶
func NewAPIAddresser(getter AddressAndCertGetter, resources facade.Resources) *APIAddresser
NewAPIAddresser returns a new APIAddresser that uses the given getter to fetch its addresses.
func (*APIAddresser) APIAddresses ¶
func (api *APIAddresser) APIAddresses() (params.StringsResult, error)
APIAddresses returns the list of addresses used to connect to the API.
func (*APIAddresser) APIHostPorts ¶
func (api *APIAddresser) APIHostPorts() (params.APIHostPortsResult, error)
APIHostPorts returns the API server addresses.
func (*APIAddresser) CACert ¶
func (a *APIAddresser) CACert() params.BytesResult
CACert returns the certificate used to validate the state connection.
func (*APIAddresser) ModelUUID ¶
func (a *APIAddresser) ModelUUID() params.StringResult
ModelUUID returns the model UUID to connect to the environment that the current connection is for.
func (*APIAddresser) WatchAPIHostPorts ¶
func (api *APIAddresser) WatchAPIHostPorts() (params.NotifyWatchResult, error)
WatchAPIHostPorts watches the API server addresses.
type APIHostPortsGetter ¶
type APIHostPortsGetter interface { // APIHostPorst returns the HostPorts for each API server. APIHostPorts() ([][]network.HostPort, error) }
APIHostPortsGetter is an interface providing the APIHostPorts method.
type AddressAndCertGetter ¶
type AddressAndCertGetter interface { Addresses() ([]string, error) APIAddressesFromMachines() ([]string, error) CACert() string ModelUUID() string APIHostPorts() ([][]network.HostPort, error) WatchAPIHostPorts() state.NotifyWatcher }
AddressAndCertGetter can be used to find out controller addresses and the CA public certificate.
type AgentEntityWatcher ¶
type AgentEntityWatcher struct {
// contains filtered or unexported fields
}
AgentEntityWatcher implements a common Watch method for use by various facades.
func NewAgentEntityWatcher ¶
func NewAgentEntityWatcher(st state.EntityFinder, resources facade.Resources, getCanWatch GetAuthFunc) *AgentEntityWatcher
NewAgentEntityWatcher returns a new AgentEntityWatcher. The GetAuthFunc will be used on each invocation of Watch to determine current permissions.
func (*AgentEntityWatcher) Watch ¶
func (a *AgentEntityWatcher) Watch(args params.Entities) (params.NotifyWatchResults, error)
Watch starts an NotifyWatcher for each given entity.
type Application ¶
type Application interface{}
Application defines methods provided by a state.Application instance.
type ApplicationStatusGetter ¶
type ApplicationStatusGetter struct {
// contains filtered or unexported fields
}
ApplicationStatusGetter is a StatusGetter for combined application and unit statuses. TODO(fwereade) this is completely evil and should never have been created. We have a perfectly adequate StatusGetter already, that accepts bulk args; all this does is break the user model, break the api model, and lie about unit statuses).
func NewApplicationStatusGetter ¶
func NewApplicationStatusGetter(st *state.State, getCanAccess GetAuthFunc) *ApplicationStatusGetter
NewApplicationStatusGetter returns a ApplicationStatusGetter.
func (*ApplicationStatusGetter) Status ¶
func (s *ApplicationStatusGetter) Status(args params.Entities) (params.ApplicationStatusResults, error)
Status returns the status of the Application for each given Unit tag.
type ApplicationStatusSetter ¶
type ApplicationStatusSetter struct {
// contains filtered or unexported fields
}
ApplicationStatusSetter implements a SetApplicationStatus method to be used by facades that can change an application status. This is only slightly less evil than ApplicationStatusGetter. We have StatusSetter already; all this does is set the status for the wrong entity, and render the auth so confused as to be ~worthless.
func NewServiceStatusSetter ¶
func NewServiceStatusSetter(st *state.State, getCanModify GetAuthFunc) *ApplicationStatusSetter
NewServiceStatusSetter returns a ServiceStatusSetter.
func (*ApplicationStatusSetter) SetStatus ¶
func (s *ApplicationStatusSetter) SetStatus(args params.SetStatus) (params.ErrorResults, error)
SetStatus sets the status on the service given by the unit in args if the unit is the leader.
type AuthFunc ¶
type AuthFunc func(tag names.Tag) bool
AuthFunc returns whether the given entity is available to some operation.
type BlockChecker ¶
type BlockChecker struct {
// contains filtered or unexported fields
}
BlockChecker checks for current blocks if any.
func NewBlockChecker ¶
func NewBlockChecker(s BlockGetter) *BlockChecker
func (*BlockChecker) ChangeAllowed ¶
func (c *BlockChecker) ChangeAllowed() error
ChangeAllowed checks if change block is in place. Change block prevents all operations that may change current environment in any way from running successfully.
func (*BlockChecker) DestroyAllowed ¶
func (c *BlockChecker) DestroyAllowed() error
DestroyAllowed checks if destroy block is in place. Destroy block prevents destruction of current environment.
func (*BlockChecker) RemoveAllowed ¶
func (c *BlockChecker) RemoveAllowed() error
RemoveAllowed checks if remove block is in place. Remove block prevents removal of machine, service, unit and relation from current environment.
type BlockGetter ¶
type ControllerConfigAPI ¶
type ControllerConfigAPI struct {
// contains filtered or unexported fields
}
ControllerConfigAPI implements two common methods for use by various facades - eg Provisioner and ControllerConfig.
func NewControllerConfig ¶
func NewControllerConfig(st state.ControllerAccessor) *ControllerConfigAPI
NewControllerConfig returns a new NewControllerConfigAPI.
func (*ControllerConfigAPI) ControllerConfig ¶
func (s *ControllerConfigAPI) ControllerConfig() (params.ControllerConfigResult, error)
ControllerConfig returns the controller's configuration.
type DeadEnsurer ¶
type DeadEnsurer struct {
// contains filtered or unexported fields
}
DeadEnsurer implements a common EnsureDead method for use by various facades.
func NewDeadEnsurer ¶
func NewDeadEnsurer(st state.EntityFinder, getCanModify GetAuthFunc) *DeadEnsurer
NewDeadEnsurer returns a new DeadEnsurer. The GetAuthFunc will be used on each invocation of EnsureDead to determine current permissions.
func (*DeadEnsurer) EnsureDead ¶
func (d *DeadEnsurer) EnsureDead(args params.Entities) (params.ErrorResults, error)
EnsureDead calls EnsureDead on each given entity from state. It will fail if the entity is not present. If it's Alive, nothing will happen (see state/EnsureDead() for units or machines).
type DischargeRequiredError ¶
type DischargeRequiredError struct { Cause error Macaroon *macaroon.Macaroon }
DischargeRequiredError is the error returned when a macaroon requires discharging to complete authentication.
func (*DischargeRequiredError) Error ¶
func (e *DischargeRequiredError) Error() string
Error implements the error interface.
type EnvironConfigGetterFuncs ¶
type EnvironConfigGetterFuncs struct { ModelConfigFunc func() (*config.Config, error) CloudSpecFunc func(names.ModelTag) (environs.CloudSpec, error) }
EnvironConfigGetterFuncs holds implements environs.EnvironConfigGetter in a pluggable way.
func (EnvironConfigGetterFuncs) CloudSpec ¶
func (f EnvironConfigGetterFuncs) CloudSpec(model names.ModelTag) (environs.CloudSpec, error)
CloudSpec implements environs.EnvironConfigGetter.
func (EnvironConfigGetterFuncs) ModelConfig ¶
func (f EnvironConfigGetterFuncs) ModelConfig() (*config.Config, error)
ModelConfig implements EnvironConfigGetter.
type GetActionsFn ¶
GetActionsFn declares the function type that returns a slice of state.Action and error, used to curry specific list functions.
type GetAuthFunc ¶
GetAuthFunc returns an AuthFunc.
func AuthAlways ¶
func AuthAlways() GetAuthFunc
AuthAlways returns an authentication function that always returns true iff it is passed a valid tag.
func AuthAny ¶
func AuthAny(getFuncs ...GetAuthFunc) GetAuthFunc
AuthAny returns an AuthFunc generator that returns an AuthFunc that accepts any tag authorized by any of its arguments. If no arguments are passed this is equivalent to AuthNever.
func AuthFuncForTag ¶
func AuthFuncForTag(valid names.Tag) GetAuthFunc
AuthFuncForTag returns an authentication function that always returns true iff it is passed a specific tag.
func AuthFuncForTagKind ¶
func AuthFuncForTagKind(kind string) GetAuthFunc
AuthFuncForTagKind returns a GetAuthFunc which creates an AuthFunc allowing only the given tag kind and denies all others. Passing an empty kind is an error.
func AuthNever ¶
func AuthNever() GetAuthFunc
AuthNever returns an authentication function that never returns true.
type InstanceIdGetter ¶
type InstanceIdGetter struct {
// contains filtered or unexported fields
}
InstanceIdGetter implements a common InstanceId method for use by various facades.
func NewInstanceIdGetter ¶
func NewInstanceIdGetter(st state.EntityFinder, getCanRead GetAuthFunc) *InstanceIdGetter
NewInstanceIdGetter returns a new InstanceIdGetter. The GetAuthFunc will be used on each invocation of InstanceId to determine current permissions.
func (*InstanceIdGetter) InstanceId ¶
func (ig *InstanceIdGetter) InstanceId(args params.Entities) (params.StringResults, error)
InstanceId returns the provider specific instance id for each given machine or an CodeNotProvisioned error, if not set.
type LifeGetter ¶
type LifeGetter struct {
// contains filtered or unexported fields
}
LifeGetter implements a common Life method for use by various facades.
func NewLifeGetter ¶
func NewLifeGetter(st state.EntityFinder, getCanRead GetAuthFunc) *LifeGetter
NewLifeGetter returns a new LifeGetter. The GetAuthFunc will be used on each invocation of Life to determine current permissions.
func (*LifeGetter) Life ¶
func (lg *LifeGetter) Life(args params.Entities) (params.LifeResults, error)
Life returns the life status of every supplied entity, where available.
type Machine ¶
type Machine interface { Id() string InstanceId() (instance.Id, error) WantsVote() bool HasVote() bool Status() (status.StatusInfo, error) ContainerType() instance.ContainerType HardwareCharacteristics() (*instance.HardwareCharacteristics, error) Life() state.Life ForceDestroy() error Destroy() error AgentPresence() (bool, error) IsManager() bool }
type MachineStatusGetter ¶
type MachineStatusGetter interface { Status() (status.StatusInfo, error) AgentPresence() (bool, error) Id() string Life() state.Life }
MachineStatusGetter defines the machine functionality required to status.
type Model ¶
type Model interface { Config() (*config.Config, error) Life() state.Life ModelTag() names.ModelTag Owner() names.UserTag Status() (status.StatusInfo, error) Cloud() string CloudCredential() (names.CloudCredentialTag, bool) CloudRegion() string Users() ([]permission.UserAccess, error) Destroy() error DestroyIncludingHosted() error }
Model defines methods provided by a state.Model instance. All the interface methods are defined directly on state.Model and are reproduced here for use in tests.
type ModelMachinesWatcher ¶
type ModelMachinesWatcher struct {
// contains filtered or unexported fields
}
ModelMachinesWatcher implements a common WatchModelMachines method for use by various facades.
func NewModelMachinesWatcher ¶
func NewModelMachinesWatcher(st state.ModelMachinesWatcher, resources facade.Resources, authorizer facade.Authorizer) *ModelMachinesWatcher
NewModelMachinesWatcher returns a new ModelMachinesWatcher. The GetAuthFunc will be used on each invocation of WatchUnits to determine current permissions.
func (*ModelMachinesWatcher) WatchModelMachines ¶
func (e *ModelMachinesWatcher) WatchModelMachines() (params.StringsWatchResult, error)
WatchModelMachines returns a StringsWatcher that notifies of changes to the life cycles of the top level machines in the current model.
type ModelManagerBackend ¶
type ModelManagerBackend interface { APIHostPortsGetter ToolsStorageGetter BlockGetter metricsender.MetricsSenderBackend state.CloudAccessor ModelUUID() string ModelsForUser(names.UserTag) ([]*state.UserModel, error) IsControllerAdmin(user names.UserTag) (bool, error) NewModel(state.ModelArgs) (Model, ModelManagerBackend, error) ComposeNewModelConfig(modelAttr map[string]interface{}, regionSpec *environs.RegionSpec) (map[string]interface{}, error) ControllerModel() (Model, error) ControllerConfig() (controller.Config, error) ForModel(tag names.ModelTag) (ModelManagerBackend, error) GetModel(names.ModelTag) (Model, error) Model() (Model, error) ModelConfigDefaultValues() (config.ModelDefaultAttributes, error) UpdateModelConfigDefaultValues(update map[string]interface{}, remove []string, regionSpec *environs.RegionSpec) error Unit(name string) (*state.Unit, error) ModelTag() names.ModelTag ModelConfig() (*config.Config, error) AllModels() ([]Model, error) AddModelUser(string, state.UserAccessSpec) (permission.UserAccess, error) AddControllerUser(state.UserAccessSpec) (permission.UserAccess, error) RemoveUserAccess(names.UserTag, names.Tag) error UserAccess(names.UserTag, names.Tag) (permission.UserAccess, error) AllMachines() (machines []Machine, err error) AllApplications() (applications []Application, err error) ControllerUUID() string ControllerTag() names.ControllerTag Export() (description.Model, error) SetUserAccess(subject names.UserTag, target names.Tag, access permission.Access) (permission.UserAccess, error) LastModelConnection(user names.UserTag) (time.Time, error) LatestMigration() (state.ModelMigration, error) DumpAll() (map[string]interface{}, error) Close() error }
ModelManagerBackend defines methods provided by a state instance used by the model manager apiserver implementation. All the interface methods are defined directly on state.State and are reproduced here for use in tests.
func NewModelManagerBackend ¶
func NewModelManagerBackend(st *state.State) ModelManagerBackend
NewModelManagerBackend returns a modelManagerStateShim wrapping the passed state, which implements ModelManagerBackend.
type ModelStatusAPI ¶
type ModelStatusAPI struct {
// contains filtered or unexported fields
}
ModelStatusAPI implements the ModelStatus() API.
func NewModelStatusAPI ¶
func NewModelStatusAPI(st ModelManagerBackend, authorizer facade.Authorizer, apiUser names.UserTag) *ModelStatusAPI
NewModelStatusAPI creates an implementation providing the ModelStatus() API.
func (*ModelStatusAPI) ModelStatus ¶
func (c *ModelStatusAPI) ModelStatus(req params.Entities) (params.ModelStatusResults, error)
ModelStatus returns a summary of the model.
type ModelWatcher ¶
type ModelWatcher struct {
// contains filtered or unexported fields
}
ModelWatcher implements two common methods for use by various facades - WatchForModelConfigChanges and ModelConfig.
func NewModelWatcher ¶
func NewModelWatcher(st state.ModelAccessor, resources facade.Resources, authorizer facade.Authorizer) *ModelWatcher
NewModelWatcher returns a new ModelWatcher. Active watchers will be stored in the provided Resources. The two GetAuthFunc callbacks will be used on each invocation of the methods to determine current permissions. Right now, environment tags are not used, so both created AuthFuncs are called with "" for tag, which means "the current environment".
func (*ModelWatcher) ModelConfig ¶
func (m *ModelWatcher) ModelConfig() (params.ModelConfigResult, error)
ModelConfig returns the current environment's configuration.
func (*ModelWatcher) WatchForModelConfigChanges ¶
func (m *ModelWatcher) WatchForModelConfigChanges() (params.NotifyWatchResult, error)
WatchForModelConfigChanges returns a NotifyWatcher that observes changes to the environment configuration. Note that although the NotifyWatchResult contains an Error field, it's not used because we are only returning a single watcher, so we use the regular error return.
type MultiNotifyWatcher ¶
type MultiNotifyWatcher struct {
// contains filtered or unexported fields
}
MultiNotifyWatcher implements state.NotifyWatcher, combining multiple NotifyWatchers.
func NewMultiNotifyWatcher ¶
func NewMultiNotifyWatcher(w ...state.NotifyWatcher) *MultiNotifyWatcher
NewMultiNotifyWatcher creates a NotifyWatcher that combines each of the NotifyWatchers passed in. Each watcher's initial event is consumed, and a single initial event is sent. Subsequent events are not coalesced.
func (*MultiNotifyWatcher) Changes ¶
func (w *MultiNotifyWatcher) Changes() <-chan struct{}
func (*MultiNotifyWatcher) Err ¶
func (w *MultiNotifyWatcher) Err() error
func (*MultiNotifyWatcher) Kill ¶
func (w *MultiNotifyWatcher) Kill()
func (*MultiNotifyWatcher) Stop ¶
func (w *MultiNotifyWatcher) Stop() error
func (*MultiNotifyWatcher) Wait ¶
func (w *MultiNotifyWatcher) Wait() error
type NewHookContextFacadeFn ¶
NewHookContextFacadeFn specifies the function signature that can be used to register a hook context facade.
type PasswordChanger ¶
type PasswordChanger struct {
// contains filtered or unexported fields
}
PasswordChanger implements a common SetPasswords method for use by various facades.
func NewPasswordChanger ¶
func NewPasswordChanger(st state.EntityFinder, getCanChange GetAuthFunc) *PasswordChanger
NewPasswordChanger returns a new PasswordChanger. The GetAuthFunc will be used on each invocation of SetPasswords to determine current permissions.
func (*PasswordChanger) SetPasswords ¶
func (pc *PasswordChanger) SetPasswords(args params.EntityPasswords) (params.ErrorResults, error)
SetPasswords sets the given password for each supplied entity, if possible.
type RebootActionGetter ¶
type RebootActionGetter struct {
// contains filtered or unexported fields
}
RebootActionGetter implements the GetRebootAction API method
func NewRebootActionGetter ¶
func NewRebootActionGetter(st state.EntityFinder, auth GetAuthFunc) *RebootActionGetter
func (*RebootActionGetter) GetRebootAction ¶
func (r *RebootActionGetter) GetRebootAction(args params.Entities) (params.RebootActionResults, error)
GetRebootAction returns the action a machine agent should take. If a reboot flag is set on the machine, then that machine is expected to reboot (params.ShouldReboot). a reboot flag set on the machine parent or grandparent, will cause the machine to shutdown (params.ShouldShutdown). If no reboot flag is set, the machine should do nothing (params.ShouldDoNothing).
type RebootFlagClearer ¶
type RebootFlagClearer struct {
// contains filtered or unexported fields
}
RebootFlagClearer implements the ClearReboot API call
func NewRebootFlagClearer ¶
func NewRebootFlagClearer(st state.EntityFinder, auth GetAuthFunc) *RebootFlagClearer
func (*RebootFlagClearer) ClearReboot ¶
func (r *RebootFlagClearer) ClearReboot(args params.Entities) (params.ErrorResults, error)
ClearReboot will clear the reboot flag on provided machines, if it exists.
type RebootRequester ¶
type RebootRequester struct {
// contains filtered or unexported fields
}
RebootRequester implements the RequestReboot API method
func NewRebootRequester ¶
func NewRebootRequester(st state.EntityFinder, auth GetAuthFunc) *RebootRequester
func (*RebootRequester) RequestReboot ¶
func (r *RebootRequester) RequestReboot(args params.Entities) (params.ErrorResults, error)
RequestReboot sets the reboot flag on the provided machines
type Remover ¶
type Remover struct {
// contains filtered or unexported fields
}
Remover implements a common Remove method for use by various facades.
func NewRemover ¶
func NewRemover(st state.EntityFinder, callEnsureDead bool, getCanModify GetAuthFunc) *Remover
NewRemover returns a new Remover. The callEnsureDead flag specifies whether EnsureDead should be called on an entity before removing. The GetAuthFunc will be used on each invocation of Remove to determine current permissions.
type Resources ¶
type Resources struct {
// contains filtered or unexported fields
}
Resources holds all the resources for a connection. It allows the registration of resources that will be cleaned up when a connection terminates.
func NewResources ¶
func NewResources() *Resources
func (*Resources) Get ¶
Get returns the resource for the given id, or nil if there is no such resource.
func (*Resources) Register ¶
Register registers the given resource. It returns a unique identifier for the resource which can then be used in subsequent API requests to refer to the resource.
func (*Resources) RegisterNamed ¶
RegisterNamed registers the given resource. Callers must supply a unique name for the given resource. It is an error to try to register another resource with the same name as an already registered name. (This could be softened that you can overwrite an existing one and it will be Stopped and replaced, but we don't have a need for that yet.) It is also an error to supply a name that is an integer string, since that collides with the auto-naming from Register.
type StateAddresser ¶
type StateAddresser struct {
// contains filtered or unexported fields
}
StateAddresser implements a common set of methods for getting state server addresses, and the CA certificate used to authenticate them.
func NewStateAddresser ¶
func NewStateAddresser(getter AddressAndCertGetter) *StateAddresser
NewStateAddresser returns a new StateAddresser that uses the given st value to fetch its addresses.
func (*StateAddresser) StateAddresses ¶
func (a *StateAddresser) StateAddresses() (params.StringsResult, error)
StateAddresses returns the list of addresses used to connect to the state.
type StatusAndErr ¶
type StatusAndErr struct { Status status.StatusInfo Err error }
StatusAndErr pairs a StatusInfo with an error associated with retrieving it.
type StatusGetter ¶
type StatusGetter struct {
// contains filtered or unexported fields
}
StatusGetter implements a common Status method for use by various facades.
func NewStatusGetter ¶
func NewStatusGetter(st state.EntityFinder, getCanAccess GetAuthFunc) *StatusGetter
NewStatusGetter returns a new StatusGetter. The GetAuthFunc will be used on each invocation of Status to determine current permissions.
func (*StatusGetter) Status ¶
func (s *StatusGetter) Status(args params.Entities) (params.StatusResults, error)
Status returns the status of each given entity.
type StatusSetter ¶
type StatusSetter struct {
// contains filtered or unexported fields
}
StatusSetter implements a common SetStatus method for use by various facades.
func NewStatusSetter ¶
func NewStatusSetter(st state.EntityFinder, getCanModify GetAuthFunc) *StatusSetter
NewStatusSetter returns a new StatusSetter. The GetAuthFunc will be used on each invocation of SetStatus to determine current permissions.
func (*StatusSetter) SetStatus ¶
func (s *StatusSetter) SetStatus(args params.SetStatus) (params.ErrorResults, error)
SetStatus sets the status of each given entity.
func (*StatusSetter) UpdateStatus ¶
func (s *StatusSetter) UpdateStatus(args params.SetStatus) (params.ErrorResults, error)
UpdateStatus updates the status data of each given entity. TODO(fwereade): WTF. This method exists *only* for the convenience of the *client* API -- and is itself completely broken -- but we still expose it in every facade with a StatusSetter? FFS.
type StorageAccessor ¶
type StorageAccessor interface { StorageInstance(names.StorageTag) (state.StorageInstance, error) UnitStorageAttachments(names.UnitTag) ([]state.StorageAttachment, error) }
type StringResource ¶
type StringResource string
StringResource is just a regular 'string' that matches the Resource interface.
func (StringResource) Stop ¶
func (StringResource) Stop() error
func (StringResource) String ¶
func (s StringResource) String() string
type ToolsFinder ¶
type ToolsFinder struct {
// contains filtered or unexported fields
}
func NewToolsFinder ¶
func NewToolsFinder(c environs.EnvironConfigGetter, s ToolsStorageGetter, t ToolsURLGetter) *ToolsFinder
NewToolsFinder returns a new ToolsFinder, returning tools with their URLs pointing at the API server.
func (*ToolsFinder) FindTools ¶
func (f *ToolsFinder) FindTools(args params.FindToolsParams) (params.FindToolsResult, error)
FindTools returns a List containing all tools matching the given parameters.
type ToolsGetter ¶
type ToolsGetter struct {
// contains filtered or unexported fields
}
ToolsGetter implements a common Tools method for use by various facades.
func NewToolsGetter ¶
func NewToolsGetter(f state.EntityFinder, c environs.EnvironConfigGetter, s ToolsStorageGetter, t ToolsURLGetter, getCanRead GetAuthFunc) *ToolsGetter
NewToolsGetter returns a new ToolsGetter. The GetAuthFunc will be used on each invocation of Tools to determine current permissions.
func (*ToolsGetter) Tools ¶
func (t *ToolsGetter) Tools(args params.Entities) (params.ToolsResults, error)
Tools finds the tools necessary for the given agents.
type ToolsSetter ¶
type ToolsSetter struct {
// contains filtered or unexported fields
}
ToolsSetter implements a common Tools method for use by various facades.
func NewToolsSetter ¶
func NewToolsSetter(st state.EntityFinder, getCanWrite GetAuthFunc) *ToolsSetter
NewToolsSetter returns a new ToolsGetter. The GetAuthFunc will be used on each invocation of Tools to determine current permissions.
func (*ToolsSetter) SetTools ¶
func (t *ToolsSetter) SetTools(args params.EntitiesVersion) (params.ErrorResults, error)
SetTools updates the recorded tools version for the agents.
type ToolsStorageGetter ¶
type ToolsStorageGetter interface { // ToolsStorage returns a binarystorage.StorageCloser. ToolsStorage() (binarystorage.StorageCloser, error) }
ToolsStorageGetter is an interface providing the ToolsStorage method.
type ToolsURLGetter ¶
type ToolsURLGetter interface { // ToolsURLs returns URLs for the tools with // the specified binary version. ToolsURLs(v version.Binary) ([]string, error) }
ToolsURLGetter is an interface providing the ToolsURL method.
type UnitAgentFinder ¶
type UnitAgentFinder struct {
state.EntityFinder
}
UnitAgentFinder is a state.EntityFinder that finds unit agents.
func (*UnitAgentFinder) FindEntity ¶
func (ua *UnitAgentFinder) FindEntity(tag names.Tag) (state.Entity, error)
FindEntity implements state.EntityFinder and returns unit agents.
type UnitStatusGetter ¶
type UnitStatusGetter interface { AgentStatus() (status.StatusInfo, error) Status() (status.StatusInfo, error) AgentPresence() (bool, error) Name() string Life() state.Life }
UnitStatusGetter defines the unit functionality required to determine unit agent and workload status.
type UnitsWatcher ¶
type UnitsWatcher struct {
// contains filtered or unexported fields
}
UnitsWatcher implements a common WatchUnits method for use by various facades.
func NewUnitsWatcher ¶
func NewUnitsWatcher(st state.EntityFinder, resources facade.Resources, getCanWatch GetAuthFunc) *UnitsWatcher
NewUnitsWatcher returns a new UnitsWatcher. The GetAuthFunc will be used on each invocation of WatchUnits to determine current permissions.
func (*UnitsWatcher) WatchUnits ¶
func (u *UnitsWatcher) WatchUnits(args params.Entities) (params.StringsWatchResults, error)
WatchUnits starts a StringsWatcher to watch all units belonging to to any entity (machine or service) passed in args.
type ValueResource ¶
type ValueResource struct {
Value interface{}
}
ValueResource is a Resource with a no-op Stop method, containing an interface{} value.
func (ValueResource) Stop ¶
func (r ValueResource) Stop() error
Source Files ¶
- action.go
- addresses.go
- block.go
- charms.go
- controllerconfig.go
- defaulticon.go
- ensuredead.go
- environ_config.go
- errors.go
- getstatus.go
- instanceidgetter.go
- instancetypes.go
- interfaces.go
- life.go
- machine.go
- machinestatus.go
- modeldestroy.go
- modelmachineswatcher.go
- modelmanagerinterface.go
- modelstatus.go
- modeluser.go
- modelwatcher.go
- password.go
- permissions.go
- reboot.go
- registry.go
- remove.go
- resource.go
- setstatus.go
- storage.go
- tools.go
- unitstatus.go
- unitswatcher.go
- watch.go
Directories ¶
Path | Synopsis |
---|---|
Package storagecommon provides common storage-related services for API server facades.
|
Package storagecommon provides common storage-related services for API server facades. |