Documentation
¶
Overview ¶
Package application provides access to the application API facade. This facade contains API calls that are specific to applications. As a rule of thumb, if the argument for an API requires an application name and affects only that application then the call belongs here.
Index ¶
- Variables
- type AddUnitsParams
- type CharmID
- type Client
- func (c *Client) AddRelation(ctx context.Context, endpoints, viaCIDRs []string) (*params.AddRelationResults, error)
- func (c *Client) AddUnits(ctx context.Context, args AddUnitsParams) ([]string, error)
- func (c *Client) ApplicationsInfo(ctx context.Context, applications []names.ApplicationTag) ([]params.ApplicationInfoResult, error)
- func (c *Client) CharmRelations(ctx context.Context, application string) ([]string, error)
- func (c *Client) Consume(ctx context.Context, arg crossmodel.ConsumeApplicationArgs) (string, error)
- func (c *Client) Deploy(ctx context.Context, args DeployArgs) error
- func (c *Client) DeployFromRepository(ctx context.Context, arg DeployFromRepositoryArg) (DeployInfo, []PendingResourceUpload, []error)
- func (c *Client) DestroyApplications(ctx context.Context, in DestroyApplicationsParams) ([]params.DestroyApplicationResult, error)
- func (c *Client) DestroyConsumedApplication(ctx context.Context, in DestroyConsumedApplicationParams) ([]params.ErrorResult, error)
- func (c *Client) DestroyRelation(ctx context.Context, force *bool, maxWait *time.Duration, endpoints ...string) error
- func (c *Client) DestroyRelationId(ctx context.Context, relationId int, force *bool, maxWait *time.Duration) error
- func (c *Client) DestroyUnits(ctx context.Context, in DestroyUnitsParams) ([]params.DestroyUnitResult, error)
- func (c *Client) Expose(ctx context.Context, application string, ...) error
- func (c *Client) Get(ctx context.Context, application string) (*params.ApplicationGetResults, error)
- func (c *Client) GetCharmURLOrigin(ctx context.Context, applicationName string) (*charm.URL, apicharm.Origin, error)
- func (c *Client) GetConfig(ctx context.Context, appNames ...string) ([]map[string]interface{}, error)
- func (c *Client) GetConstraints(ctx context.Context, applications ...string) ([]constraints.Value, error)
- func (c *Client) Leader(ctx context.Context, app string) (string, error)
- func (c *Client) MergeBindings(ctx context.Context, req params.ApplicationMergeBindingsArgs) error
- func (c *Client) ModelUUID() string
- func (c *Client) ResolveUnitErrors(ctx context.Context, units []string, all, retry bool) error
- func (c *Client) ScaleApplication(ctx context.Context, in ScaleApplicationParams) (params.ScaleApplicationResult, error)
- func (c *Client) SetCharm(ctx context.Context, cfg SetCharmConfig) error
- func (c *Client) SetConfig(ctx context.Context, application, configYAML string, config map[string]string) error
- func (c *Client) SetConstraints(ctx context.Context, application string, constraints constraints.Value) error
- func (c *Client) SetRelationSuspended(ctx context.Context, relationIds []int, suspended bool, message string) error
- func (c *Client) Unexpose(ctx context.Context, application string, endpoints []string) error
- func (c *Client) UnitsInfo(ctx context.Context, units []names.UnitTag) ([]UnitInfo, error)
- func (c *Client) UnsetApplicationConfig(ctx context.Context, application string, options []string) error
- type DeployArgs
- type DeployFromRepositoryArg
- type DeployInfo
- type DestroyApplicationsParams
- type DestroyConsumedApplicationParams
- type DestroyUnitsParams
- type EndpointRelationData
- type Option
- type PendingResourceUpload
- type RelationData
- type ScaleApplicationParams
- type SetCharmConfig
- type UnitInfo
Constants ¶
This section is empty.
Variables ¶
var WithTracer = base.WithTracer
WithTracer returns an Option that configures the Client to use the supplied tracer.
Functions ¶
This section is empty.
Types ¶
type AddUnitsParams ¶
type AddUnitsParams struct { // ApplicationName is the name of the application to which units // will be added. ApplicationName string // NumUnits is the number of units to deploy. NumUnits int // Placement directives on where the machines for the unit must be // created. Placement []*instance.Placement // Policy represents how a machine for the unit is determined. // This value is ignored on any Juju server before 2.4. Policy string // AttachStorage contains IDs of existing storage that should be // attached to the application unit that will be deployed. This // may be non-empty only if NumUnits is 1. AttachStorage []string }
AddUnitsParams contains parameters for the AddUnits API method.
type CharmID ¶
type CharmID struct { // URL of the given charm, includes the reference name and a revision. URL string // Origin holds the origin of a charm. This includes the source of the // charm, along with the revision and channel to identify where the charm // originated from. Origin apicharm.Origin }
CharmID represents the underlying charm for a given application. This includes both the URL and the origin.
type Client ¶
type Client struct { base.ClientFacade // contains filtered or unexported fields }
Client allows access to the application API end point.
func NewClient ¶
func NewClient(st base.APICallCloser, options ...Option) *Client
NewClient creates a new client for accessing the application api.
func (*Client) AddRelation ¶
func (c *Client) AddRelation(ctx context.Context, endpoints, viaCIDRs []string) (*params.AddRelationResults, error)
AddRelation adds a relation between the specified endpoints and returns the relation info.
func (*Client) AddUnits ¶
AddUnits adds a given number of units to an application using the specified placement directives to assign units to machines.
func (*Client) ApplicationsInfo ¶
func (c *Client) ApplicationsInfo(ctx context.Context, applications []names.ApplicationTag) ([]params.ApplicationInfoResult, error)
ApplicationsInfo retrieves applications information.
func (*Client) CharmRelations ¶
CharmRelations returns the application's charms relation names.
func (*Client) Consume ¶
func (c *Client) Consume(ctx context.Context, arg crossmodel.ConsumeApplicationArgs) (string, error)
Consume adds a remote application to the model.
func (*Client) Deploy ¶
func (c *Client) Deploy(ctx context.Context, args DeployArgs) error
Deploy obtains the charm, either locally or from the charm store, and deploys it. Placement directives, if provided, specify the machine on which the charm is deployed.
func (*Client) DeployFromRepository ¶
func (c *Client) DeployFromRepository(ctx context.Context, arg DeployFromRepositoryArg) (DeployInfo, []PendingResourceUpload, []error)
DeployFromRepository deploys a charm from a repository based on the provided arguments. Returned in info on application was deployed, data required to upload any local resources and errors returned. Where possible, more than all errors regarding argument validation are returned.
func (*Client) DestroyApplications ¶
func (c *Client) DestroyApplications(ctx context.Context, in DestroyApplicationsParams) ([]params.DestroyApplicationResult, error)
DestroyApplications destroys the given applications.
func (*Client) DestroyConsumedApplication ¶
func (c *Client) DestroyConsumedApplication(ctx context.Context, in DestroyConsumedApplicationParams) ([]params.ErrorResult, error)
DestroyConsumedApplication destroys the given consumed (remote) applications.
func (*Client) DestroyRelation ¶
func (c *Client) DestroyRelation(ctx context.Context, force *bool, maxWait *time.Duration, endpoints ...string) error
DestroyRelation removes the relation between the specified endpoints.
func (*Client) DestroyRelationId ¶
func (c *Client) DestroyRelationId(ctx context.Context, relationId int, force *bool, maxWait *time.Duration) error
DestroyRelationId removes the relation with the specified id.
func (*Client) DestroyUnits ¶
func (c *Client) DestroyUnits(ctx context.Context, in DestroyUnitsParams) ([]params.DestroyUnitResult, error)
DestroyUnits decreases the number of units dedicated to one or more applications.
func (*Client) Expose ¶
func (c *Client) Expose(ctx context.Context, application string, exposedEndpoints map[string]params.ExposedEndpoint) error
Expose changes the juju-managed firewall to expose any ports that were also explicitly marked by units as open. The exposedEndpoints argument can be used to restrict the set of ports that get exposed and at the same time specify which spaces and/or CIDRs should be able to access these ports on a per endpoint basis.
If the exposedEndpoints parameter is empty, the controller will expose *all* open ports of the application to 0.0.0.0/0. This matches the behavior of pre-2.9 juju controllers.
func (*Client) Get ¶
func (c *Client) Get(ctx context.Context, application string) (*params.ApplicationGetResults, error)
Get returns the configuration for the named application.
func (*Client) GetCharmURLOrigin ¶
func (c *Client) GetCharmURLOrigin(ctx context.Context, applicationName string) (*charm.URL, apicharm.Origin, error)
GetCharmURLOrigin returns the charm URL along with the charm Origin for the given application is running at present. The charm origin gives more information about the location of the charm and what revision/channel it came from.
func (*Client) GetConfig ¶
func (c *Client) GetConfig(ctx context.Context, appNames ...string) ([]map[string]interface{}, error)
GetConfig returns the charm configuration settings for each of the applications. If any of the applications are not found, an error is returned.
func (*Client) GetConstraints ¶
func (c *Client) GetConstraints(ctx context.Context, applications ...string) ([]constraints.Value, error)
GetConstraints returns the constraints for the given applications.
func (*Client) MergeBindings ¶
MergeBindings merges an operator-defined bindings list with the existing application bindings.
func (*Client) ResolveUnitErrors ¶
ResolveUnitErrors clears errors on one or more units. Either specify one or more units, or all.
func (*Client) ScaleApplication ¶
func (c *Client) ScaleApplication(ctx context.Context, in ScaleApplicationParams) (params.ScaleApplicationResult, error)
ScaleApplication sets the desired unit count for one or more applications.
func (*Client) SetCharm ¶
func (c *Client) SetCharm(ctx context.Context, cfg SetCharmConfig) error
SetCharm sets the charm for a given application.
func (*Client) SetConfig ¶
func (c *Client) SetConfig(ctx context.Context, application, configYAML string, config map[string]string) error
SetConfig sets configuration options on an application and the charm.
func (*Client) SetConstraints ¶
func (c *Client) SetConstraints(ctx context.Context, application string, constraints constraints.Value) error
SetConstraints specifies the constraints for the given application.
func (*Client) SetRelationSuspended ¶
func (c *Client) SetRelationSuspended(ctx context.Context, relationIds []int, suspended bool, message string) error
SetRelationSuspended updates the suspended status of the relation with the specified id.
func (*Client) Unexpose ¶
Unexpose changes the juju-managed firewall to unexpose any ports that were also explicitly marked by units as open.
type DeployArgs ¶
type DeployArgs struct { // CharmID identifies the charm to deploy. CharmID CharmID // CharmOrigin holds information about where the charm originally came from, // this includes the store. CharmOrigin apicharm.Origin // ApplicationName is the name to give the application. ApplicationName string // NumUnits is the number of units to deploy. NumUnits int // ConfigYAML is a string that overrides the default config.yml. ConfigYAML string // Config are values that override those in the default config.yaml // or configure the application itself. Config map[string]string // Cons contains constraints on where units of this application // may be placed. Cons constraints.Value // Placement directives on where the machines for the unit must be // created. Placement []*instance.Placement // Storage contains Directives specifying how storage should be // handled. Storage map[string]storage.Directive // Devices contains Constraints specifying how devices should be // handled. Devices map[string]devices.Constraints // AttachStorage contains IDs of existing storage that should be // attached to the application unit that will be deployed. This // may be non-empty only if NumUnits is 1. AttachStorage []string // EndpointBindings EndpointBindings map[string]string // Collection of resource names for the application, with the // value being the unique ID of a pre-uploaded resources in // storage. Resources map[string]string // Force can be set to true to bypass any checks for charm-specific // requirements ("assumes" sections in charm metadata) Force bool }
DeployArgs holds the arguments to be sent to Client.ApplicationDeploy.
type DeployFromRepositoryArg ¶
type DeployFromRepositoryArg struct { // CharmName is a string identifying the name of the thing to deploy. // Required. CharmName string // ApplicationName is the name to give the application. Optional. By // default, the charm name and the application name will be the same. ApplicationName string // AttachStorage contains IDs of existing storage that should be // attached to the application unit that will be deployed. This // may be non-empty only if NumUnits is 1. AttachStorage []string // Base describes the OS base intended to be used by the charm. Base *corebase.Base // Channel is the channel in the repository to deploy from. // This is an optional value. Required if revision is provided. // Defaults to “stable” if not defined nor required. Channel *string // ConfigYAML is a string that overrides the default config.yml. ConfigYAML string // Cons contains constraints on where units of this application // may be placed. Cons constraints.Value // Devices contains Constraints specifying how devices should be // handled. Devices map[string]devices.Constraints // DryRun just shows what the deploy would do, including finding the // charm; determining version, channel and base to use; validation // of the config. Does not actually download or deploy the charm. DryRun bool // EndpointBindings EndpointBindings map[string]string // Force can be set to true to bypass any checks for charm-specific // requirements ("assumes" sections in charm metadata, supported series, // LXD profile allow list) Force bool // NumUnits is the number of units to deploy. Defaults to 1 if no // value provided. Synonymous with scale for kubernetes charms. NumUnits *int // Placement directives define on which machines the unit(s) must be // created. Placement []*instance.Placement // Revision is the charm revision number. Requires the channel // be explicitly set. Revision *int // Resources is a collection of resource names for the // application, with the value being the revision of the // resource to use if default revision is not desired. Resources map[string]string // Storage contains Directives specifying how storage should be // handled. Storage map[string]storage.Directive // Trust allows charm to run hooks that require access credentials Trust bool }
type DeployInfo ¶
type DeployInfo struct { // Architecture is the architecture used to deploy the charm. Architecture string // Base is the base used to deploy the charm. Base corebase.Base // Channel is a string representation of the channel used to // deploy the charm. Channel string // EffectiveChannel is the channel actually deployed from as determined // by the charmhub response. EffectiveChannel *string // Is the name of the application deployed. This may vary from // the charm name provided if differs in the metadata.yaml and // no provided on the cli. Name string // Revision is the revision of the charm deployed. Revision int }
type DestroyApplicationsParams ¶
type DestroyApplicationsParams struct { // Applications holds the names of applications to destroy. Applications []string // DestroyStorage controls whether or not storage attached // to units of the applications will be destroyed. DestroyStorage bool // Force controls whether or not the removal of applications // will be forced, i.e. ignore removal errors. Force bool // MaxWait specifies the amount of time that each step in application removal // will wait before forcing the next step to kick-off. This parameter // only makes sense in combination with 'force' set to 'true'. MaxWait *time.Duration // DryRun specifies whether this should perform this destroy // action or just return what this action will destroy DryRun bool }
DestroyApplicationsParams contains parameters for the DestroyApplications API method.
type DestroyConsumedApplicationParams ¶
type DestroyConsumedApplicationParams struct { // SaasNames holds the names of the consumed applications // that are being destroyed SaasNames []string // Force controls whether or not the removal of applications // will be forced, i.e. ignore removal errors. Force bool // MaxWait specifies the amount of time that each step in application removal // will wait before forcing the next step to kick-off. This parameter // only makes sense in combination with 'force' set to 'true'. MaxWait *time.Duration }
type DestroyUnitsParams ¶
type DestroyUnitsParams struct { // Units holds the IDs of units to destroy. Units []string // DestroyStorage controls whether or not storage attached // to the units will be destroyed. DestroyStorage bool // Force controls whether or not the removal of applications // will be forced, i.e. ignore removal errors. Force bool // MaxWait specifies the amount of time that each step in unit removal // will wait before forcing the next step to kick-off. This parameter // only makes sense in combination with 'force' set to 'true'. MaxWait *time.Duration // DryRun specifies whether to perform the destroy action or // just return what this action will destroy DryRun bool }
DestroyUnitsParams contains parameters for the DestroyUnits API method.
type EndpointRelationData ¶
type EndpointRelationData struct { RelationId int Endpoint string CrossModel bool RelatedEndpoint string ApplicationData map[string]interface{} UnitRelationData map[string]RelationData }
EndpointRelationData holds information about a relation to a given endpoint.
type PendingResourceUpload ¶
type RelationData ¶
RelationData holds information about a unit's relation.
type ScaleApplicationParams ¶
type ScaleApplicationParams struct { // ApplicationName is the application to scale. ApplicationName string // Scale is the target number of units which should should be running. Scale int // ScaleChange is the amount of change to the target number of existing units. ScaleChange int // Force controls whether or not the removal of applications // will be forced, i.e. ignore removal errors. Force bool }
ScaleApplicationParams contains parameters for the ScaleApplication API method.
type SetCharmConfig ¶
type SetCharmConfig struct { // ApplicationName is the name of the application to set the charm on. ApplicationName string // CharmID identifies the charm. CharmID CharmID // ConfigSettings is the charm settings to set during the upgrade. // This field is only understood by Application facade version 2 // and greater. ConfigSettings map[string]string // ConfigSettingsYAML is the charm settings in YAML format to set // during the upgrade. If this is non-empty, it will take precedence // over ConfigSettings. This field is only understood by Application // facade version 2 ConfigSettingsYAML string // Force forces the use of the charm in the following scenarios: // overriding a lxd profile upgrade. // In the future, we should deprecate ForceBase and ForceUnits and just // use Force for all instances. // TODO (stickupkid): deprecate ForceBase and ForceUnits in favour of // just using Force. Force bool // ForceBase forces the use of the charm even if it doesn't match the // series of the unit. ForceBase bool // ForceUnits forces the upgrade on units in an error state. ForceUnits bool // ResourceIDs is a map of resource names to resource IDs to activate during // the upgrade. ResourceIDs map[string]string // StorageDirectives is a map of storage names to storage directives to // update during the upgrade. This field is only understood by Application // facade version 2 and greater. StorageDirectives map[string]storage.Directive // EndpointBindings is a map of operator-defined endpoint names to // space names to be merged with any existing endpoint bindings. EndpointBindings map[string]string }
SetCharmConfig holds the configuration for setting a new revision of a charm on a application.
type UnitInfo ¶
type UnitInfo struct { Error error Tag string WorkloadVersion string Machine string OpenedPorts []string PublicAddress string Charm string Leader bool Life string RelationData []EndpointRelationData // The following are for CAAS models. ProviderId string Address string }
UnitInfo holds information about a unit.