application

package
v0.0.0-...-8ff1004 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: AGPL-3.0 Imports: 46 Imported by: 0

Documentation

Overview

Package application contains api calls for functionality related to deploying and managing applications and their related charms.

Index

Constants

View Source
const TrustConfigOptionName = "trust"

TrustConfigOptionName is the option name used to set trust level in application configuration.

Variables

View Source
var NewCharmStoreRepo = newCharmStoreFromClient

NewCharmStoreRepo instantiates a new charm store repository. It is exported for testing purposes.

Functions

func AddCharmWithAuthorization

func AddCharmWithAuthorization(st State, args params.AddCharmWithAuthorization) error

AddCharmWithAuthorization adds the given charm URL (which must include revision) to the environment, if it does not exist yet. Local charms are not supported, only charm store URLs. See also AddLocalCharm().

The authorization macaroon, args.CharmStoreMacaroon, may be omitted, in which case this call is equivalent to AddCharm.

func AddCharmWithAuthorizationAndRepo

func AddCharmWithAuthorizationAndRepo(st State, args params.AddCharmWithAuthorization, repoFn func() (charmrepo.Interface, error)) error

AddCharmWithAuthorizationAndRepo adds the given charm URL (which must include revision) to the environment, if it does not exist yet. Local charms are not supported, only charm store URLs. See also AddLocalCharm(). Additionally a Repo (See charmrepo.Interface) function factory can be provided to help with overriding the source of downloading charms. The main benefit of this indirection is to help with testing (mocking)

The authorization macaroon, args.CharmStoreMacaroon, may be omitted, in which case this call is equivalent to AddCharm.

func AddTrustSchemaAndDefaults

func AddTrustSchemaAndDefaults(schema environschema.Fields, defaults schema.Defaults) (environschema.Fields, schema.Defaults, error)

AddTrustSchemaAndDefaults adds trust schema fields and defaults to an existing set of schema fields and defaults.

func ApplicationSetSettingsStrings

func ApplicationSetSettingsStrings(application Application, settings map[string]string) error

ApplicationSetSettingsStrings updates the settings for the given application, taking the configuration from a map of strings.

func CharmToStateCharm

func CharmToStateCharm(ch Charm) *state.Charm

CharmToStateCharm converts a Charm into a state.Charm. This is a hack that is required until the State interface methods we deal with stop accepting state.Charms, and start accepting charm.Charm and charm.URL.

func ResolveCharms

func ResolveCharms(st State, args params.ResolveCharms) (params.ResolveCharmResults, error)

ResolveCharm resolves the best available charm URLs with series, for charm locations without a series specified.

func StoreCharmArchive

func StoreCharmArchive(st State, archive CharmArchive) error

StoreCharmArchive stores a charm archive in environment storage.

Types

type APIBase

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

APIBase implements the shared application interface and is the concrete implementation of the api end point.

API provides the Application API facade for version 5.

func NewAPIBase

func NewAPIBase(
	backend Backend,
	storageAccess storageInterface,
	authorizer facade.Authorizer,
	blockChecker BlockChecker,
	modelTag names.ModelTag,
	modelType state.ModelType,
	modelName string,
	stateCharm func(Charm) *state.Charm,
	deployApplication func(ApplicationDeployer, DeployApplicationParams) (Application, error),
	storagePoolManager poolmanager.PoolManager,
	resources facade.Resources,
	caasBroker caas.Broker,
) (*APIBase, error)

NewAPIBase returns a new application API facade.

func (*APIBase) AddRelation

func (api *APIBase) AddRelation(args params.AddRelation) (_ params.AddRelationResults, err error)

AddRelation adds a relation between the specified endpoints and returns the relation info.

func (*APIBase) AddUnits

AddUnits adds a given number of units to an application.

func (*APIBase) ApplicationsInfo

func (api *APIBase) ApplicationsInfo(in params.Entities) (params.ApplicationInfoResults, error)

ApplicationsInfo returns applications information.

func (*APIBase) CharmConfig

CharmConfig returns charm config for the input list of applications and model generations.

func (*APIBase) CharmRelations

CharmRelations implements the server side of Application.CharmRelations.

func (*APIBase) Consume

Consume adds remote applications to the model without creating any relations.

func (*APIBase) Deploy

Deploy fetches the charms from the charm store and deploys them using the specified placement directives.

func (*APIBase) Destroy

func (api *APIBase) Destroy(in params.ApplicationDestroy) error

Destroy destroys a given application, local or remote.

NOTE(axw) this exists only for backwards compatibility, for API facade versions 1-3; clients should prefer its successor, DestroyApplication, below. Until all consumers have been updated, or we bump a major version, we can't drop this.

TODO(axw) 2017-03-16 #1673323 Drop this in Juju 3.0.

func (*APIBase) DestroyApplication

DestroyApplication removes a given set of applications.

func (*APIBase) DestroyConsumedApplications

func (api *APIBase) DestroyConsumedApplications(args params.DestroyConsumedApplicationsParams) (params.ErrorResults, error)

DestroyConsumedApplications removes a given set of consumed (remote) applications.

func (*APIBase) DestroyRelation

func (api *APIBase) DestroyRelation(args params.DestroyRelation) (err error)

DestroyRelation removes the relation between the specified endpoints or an id.

func (*APIBase) DestroyUnit

func (api *APIBase) DestroyUnit(args params.DestroyUnitsParams) (params.DestroyUnitResults, error)

DestroyUnit removes a given set of application units.

func (*APIBase) DestroyUnits

func (api *APIBase) DestroyUnits(args params.DestroyApplicationUnits) error

DestroyUnits removes a given set of application units.

NOTE(axw) this exists only for backwards compatibility, for API facade versions 1-3; clients should prefer its successor, DestroyUnit, below. Until all consumers have been updated, or we bump a major version, we can't drop this.

TODO(axw) 2017-03-16 #1673323 Drop this in Juju 3.0.

func (*APIBase) Expose

func (api *APIBase) Expose(args params.ApplicationExpose) error

Expose changes the juju-managed firewall to expose any ports that were also explicitly marked by units as open.

func (*APIBase) Get

Get returns the charm configuration for an application.

func (*APIBase) GetCharmURL

func (api *APIBase) GetCharmURL(args params.ApplicationGet) (params.StringResult, error)

GetCharmURL returns the charm URL the given application is running at present.

func (*APIBase) GetConfig

GetConfig returns the charm config for each of the input applications.

func (*APIBase) GetConstraints

func (api *APIBase) GetConstraints(args params.Entities) (params.ApplicationGetConstraintsResults, error)

GetConstraints returns the constraints for a given application.

func (*APIBase) ResolveUnitErrors

func (api *APIBase) ResolveUnitErrors(p params.UnitsResolved) (params.ErrorResults, error)

ResolveUnitErrors marks errors on the specified units as resolved.

func (*APIBase) ScaleApplications

ScaleApplications scales the specified application to the requested number of units.

func (*APIBase) Set

func (api *APIBase) Set(p params.ApplicationSet) error

Set implements the server side of Application.Set. It does not unset values that are set to an empty string. Unset should be used for that.

func (*APIBase) SetApplicationsConfig

func (api *APIBase) SetApplicationsConfig(args params.ApplicationConfigSetArgs) (params.ErrorResults, error)

SetApplicationsConfig implements the server side of Application.SetApplicationsConfig. It does not unset values that are set to an empty string. Unset should be used for that.

func (*APIBase) SetCharm

func (api *APIBase) SetCharm(args params.ApplicationSetCharm) error

SetCharm sets the charm for a given for the application.

func (*APIBase) SetConstraints

func (api *APIBase) SetConstraints(args params.SetConstraints) error

SetConstraints sets the constraints for a given application.

func (*APIBase) SetMetricCredentials

func (api *APIBase) SetMetricCredentials(args params.ApplicationMetricCredentials) (params.ErrorResults, error)

SetMetricCredentials sets credentials on the application.

func (*APIBase) SetRelationsSuspended

func (api *APIBase) SetRelationsSuspended(args params.RelationSuspendedArgs) (params.ErrorResults, error)

SetRelationsSuspended sets the suspended status of the specified relations.

func (*APIBase) Unexpose

func (api *APIBase) Unexpose(args params.ApplicationUnexpose) error

Unexpose changes the juju-managed firewall to unexpose any ports that were also explicitly marked by units as open.

func (*APIBase) Unset

func (api *APIBase) Unset(p params.ApplicationUnset) error

Unset implements the server side of Client.Unset.

func (*APIBase) UnsetApplicationsConfig

func (api *APIBase) UnsetApplicationsConfig(args params.ApplicationConfigUnsetArgs) (params.ErrorResults, error)

UnsetApplicationsConfig implements the server side of Application.UnsetApplicationsConfig.

func (*APIBase) Update

func (api *APIBase) Update(args params.ApplicationUpdate) error

Update updates the application attributes, including charm URL, minimum number of units, charm config and constraints. All parameters in params.ApplicationUpdate except the application name are optional.

func (*APIBase) UpdateApplicationSeries

func (api *APIBase) UpdateApplicationSeries(args params.UpdateSeriesArgs) (params.ErrorResults, error)

UpdateApplicationSeries updates the application series. Series for subordinates updated too.

type APIv4

type APIv4 struct {
	*APIv5
}

APIv4 provides the Application API facade for versions 1-4.

func NewFacadeV4

func NewFacadeV4(ctx facade.Context) (*APIv4, error)

NewFacadeV4 provides the signature required for facade registration for versions 1-4.

func (*APIv4) DestroyApplication

func (api *APIv4) DestroyApplication(args params.Entities) (params.DestroyApplicationResults, error)

DestroyApplication removes a given set of applications.

NOTE(axw) this provides backwards compatibility for facade version 4.

func (*APIv4) DestroyUnit

func (api *APIv4) DestroyUnit(args params.Entities) (params.DestroyUnitResults, error)

DestroyUnit removes a given set of application units.

NOTE(axw) this provides backwards compatibility for facade version 4.

func (*APIv4) Get

Get returns the charm configuration for an application. This used the confusing "default" boolean to mean the value was set from the charm defaults. Needs to be kept for backwards compatibility.

func (*APIv4) GetConfig

func (u *APIv4) GetConfig(_, _ struct{})

GetConfig isn't on the V4 API.

func (*APIv4) GetConstraints

GetConstraints returns the v4 implementation of GetConstraints.

func (*APIv4) UpdateApplicationSeries

func (u *APIv4) UpdateApplicationSeries(_, _ struct{})

UpdateApplicationSeries isn't on the V4 API.

type APIv5

type APIv5 struct {
	*APIv6
}

APIv5 provides the Application API facade for version 5.

func NewFacadeV5

func NewFacadeV5(ctx facade.Context) (*APIv5, error)

NewFacadeV5 provides the signature required for facade registration for version 5.

func (*APIv5) AddUnits

AddUnits adds a given number of units to an application.

func (*APIv5) CharmConfig

func (u *APIv5) CharmConfig(_, _ struct{})

CharmConfig isn't on the v5 API.

func (*APIv5) Deploy

Deploy fetches the charms from the charm store and deploys them using the specified placement directives. V5 deploy did not support policy, so pass through an empty string.

func (*APIv5) Get

Get returns the charm configuration for an application. It zeros out any application config as that was not supported in v5.

func (*APIv5) ResolveUnitErrors

func (u *APIv5) ResolveUnitErrors(_, _ struct{})

ResolveUnitErrors isn't on the v5 API.

func (*APIv5) SetApplicationsConfig

func (u *APIv5) SetApplicationsConfig(_, _ struct{})

SetApplicationsConfig isn't on the v5 API.

func (*APIv5) UnsetApplicationsConfig

func (u *APIv5) UnsetApplicationsConfig(_, _ struct{})

UnsetApplicationsConfig isn't on the v5 API.

type APIv6

type APIv6 struct {
	*APIv7
}

APIv6 provides the Application API facade for version 6.

func NewFacadeV6

func NewFacadeV6(ctx facade.Context) (*APIv6, error)

NewFacadeV6 provides the signature required for facade registration for version 6.

func (*APIv6) Deploy

Deploy fetches the charms from the charm store and deploys them using the specified placement directives. V6 deploy did not support devices, so pass through an empty map.

type APIv7

type APIv7 struct {
	*APIv8
}

APIv7 provides the Application API facade for version 7.

func NewFacadeV7

func NewFacadeV7(ctx facade.Context) (*APIv7, error)

NewFacadeV7 provides the signature required for facade registration for version 7.

func (*APIv7) ScaleApplications

func (u *APIv7) ScaleApplications(_, _ struct{})

ScaleApplications isn't on the V7 API.

type APIv8

type APIv8 struct {
	*APIv9
}

APIv8 provides the Application API facade for version 8.

func NewFacadeV8

func NewFacadeV8(ctx facade.Context) (*APIv8, error)

NewFacadeV8 provides the signature required for facade registration for version 8.

func (*APIv8) ApplicationInfo

func (u *APIv8) ApplicationInfo(_, _ struct{})

ApplicationInfo isn't on the v8 API.

func (*APIv8) CharmConfig

func (api *APIv8) CharmConfig(args params.Entities) (params.ApplicationGetConfigResults, error)

CharmConfig is a shim to GetConfig on APIv5. It returns only charm config. Version 8 and below accept params.Entities, where later versions must accept a model generation

type APIv9

type APIv9 struct {
	*APIBase
}

APIv9 provides the Application API facade for version 9.

func NewFacadeV9

func NewFacadeV9(ctx facade.Context) (*APIv9, error)

type Application

type Application interface {
	AddUnit(state.AddUnitParams) (Unit, error)
	AllUnits() ([]Unit, error)
	ApplicationConfig() (application.ConfigAttributes, error)
	Charm() (Charm, bool, error)
	CharmURL() (*charm.URL, bool)
	ChangeScale(int) (int, error)
	Channel() csparams.Channel
	ClearExposed() error
	CharmConfig() (charm.Settings, error)
	Constraints() (constraints.Value, error)
	Destroy() error
	DestroyOperation() *state.DestroyApplicationOperation
	EndpointBindings() (map[string]string, error)
	Endpoints() ([]state.Endpoint, error)
	IsExposed() bool
	IsPrincipal() bool
	IsRemote() bool
	Scale(int) error
	Series() string
	SetCharm(state.SetCharmConfig) error
	SetConstraints(constraints.Value) error
	SetExposed() error
	SetCharmProfile(string) error
	SetMetricCredentials([]byte) error
	SetMinUnits(int) error
	UpdateApplicationSeries(string, bool) error
	UpdateCharmConfig(charm.Settings) error
	UpdateApplicationConfig(application.ConfigAttributes, []string, environschema.Fields, schema.Defaults) error
}

Application defines a subset of the functionality provided by the state.Application type, as required by the application facade. For details on the methods, see the methods on state.Application with the same names.

func DeployApplication

func DeployApplication(st ApplicationDeployer, args DeployApplicationParams) (Application, error)

DeployApplication takes a charm and various parameters and deploys it.

func NewStateApplication

func NewStateApplication(st *state.State, app *state.Application) Application

NewStateApplication converts a state.Application into an Application.

type ApplicationDeployer

type ApplicationDeployer interface {
	AddApplication(state.AddApplicationArgs) (Application, error)
}

type Backend

type Backend interface {
	AllModelUUIDs() ([]string, error)
	Application(string) (Application, error)
	ApplyOperation(state.ModelOperation) error
	AddApplication(state.AddApplicationArgs) (Application, error)
	RemoteApplication(string) (RemoteApplication, error)
	AddRemoteApplication(state.AddRemoteApplicationParams) (RemoteApplication, error)
	AddRelation(...state.Endpoint) (Relation, error)
	Charm(*charm.URL) (Charm, error)
	EndpointsRelation(...state.Endpoint) (Relation, error)
	Relation(int) (Relation, error)
	InferEndpoints(...string) ([]state.Endpoint, error)
	Machine(string) (Machine, error)
	Unit(string) (Unit, error)
	UnitsInError() ([]Unit, error)
	SaveController(info crossmodel.ControllerInfo, modelUUID string) (ExternalController, error)
	ControllerTag() names.ControllerTag
	Resources() (Resources, error)
	OfferConnectionForRelation(string) (OfferConnection, error)
	SaveEgressNetworks(relationKey string, cidrs []string) (state.RelationNetworks, error)
}

Backend defines the state functionality required by the application facade. For details on the methods, see the methods on state.State with the same names.

type BlockChecker

type BlockChecker interface {
	ChangeAllowed() error
	RemoveAllowed() error
}

BlockChecker defines the block-checking functionality required by the application facade. This is implemented by apiserver/common.BlockChecker.

type Charm

type Charm interface {
	charm.Charm
}

Charm defines a subset of the functionality provided by the state.Charm type, as required by the application facade. For details on the methods, see the methods on state.Charm with the same names.

type CharmArchive

type CharmArchive struct {
	// ID is the charm URL for which we're storing the archive.
	ID *charm.URL

	// Charm is the metadata about the charm for the archive.
	Charm charm.Charm

	// Data contains the bytes of the archive.
	Data io.Reader

	// Size is the number of bytes in Data.
	Size int64

	// SHA256 is the hash of the bytes in Data.
	SHA256 string

	// Macaroon is the authorization macaroon for accessing the charmstore.
	Macaroon macaroon.Slice

	// Charm Version contains semantic version of charm, typically the output of git describe.
	CharmVersion string
}

CharmArchive is the data that needs to be stored for a charm archive in state.

type CharmState

type CharmState interface {
	UpdateUploadedCharm(info state.CharmInfo) (*state.Charm, error)
	PrepareStoreCharmUpload(curl *charm.URL) (StateCharm, error)
}

CharmState represents directives for accessing charm methods

type ControllerState

type ControllerState interface {
	ControllerConfig() (controller.Config, error)
}

ControllerState represents information defined for accessing controller configuration

type DeployApplicationParams

type DeployApplicationParams struct {
	ApplicationName   string
	Series            string
	Charm             *state.Charm
	Channel           csparams.Channel
	ApplicationConfig *application.Config
	CharmConfig       charm.Settings
	Constraints       constraints.Value
	NumUnits          int
	// Placement is a list of placement directives which may be used
	// instead of a machine spec.
	Placement        []*instance.Placement
	Storage          map[string]storage.Constraints
	Devices          map[string]devices.Constraints
	AttachStorage    []names.StorageTag
	EndpointBindings map[string]string
	// Resources is a map of resource name to IDs of pending resources.
	Resources map[string]string
}

DeployApplicationParams contains the arguments required to deploy the referenced charm.

type ExternalController

type ExternalController state.ExternalController

type Machine

type Machine interface {
	IsLockedForSeriesUpgrade() (bool, error)
	IsParentLockedForSeriesUpgrade() (bool, error)
	UpgradeCharmProfileComplete() (string, error)
	RemoveUpgradeCharmProfileData() error
}

Machine defines a subset of the functionality provided by the state.Machine type, as required by the application facade. For details on the methods, see the methods on state.Machine with the same names.

type Model

type Model interface {
	ModelTag() names.ModelTag
	Name() string
	Owner() names.UserTag
	Tag() names.Tag
	Type() state.ModelType
}

Model defines a subset of the functionality provided by the state.Model type, as required by the application facade. For details on the methods, see the methods on state.Model with the same names.

type ModelState

type ModelState interface {
	Model() (StateModel, error)
	ModelUUID() string
}

ModelState represents methods for accessing model definitions

type OfferConnection

type OfferConnection interface{}

type Relation

type Relation interface {
	status.StatusSetter
	Tag() names.Tag
	Destroy() error
	Endpoint(string) (state.Endpoint, error)
	SetSuspended(bool, string) error
	Suspended() bool
	SuspendedReason() string
}

Relation defines a subset of the functionality provided by the state.Relation type, as required by the application facade. For details on the methods, see the methods on state.Relation with the same names.

type RemoteApplication

type RemoteApplication interface {
	Name() string
	SourceModel() names.ModelTag
	Endpoints() ([]state.Endpoint, error)
	AddEndpoints(eps []charm.Relation) error
	Bindings() map[string]string
	Spaces() []state.RemoteSpace
	Destroy() error
}

type Resources

type Resources interface {
	RemovePendingAppResources(string, map[string]string) error
}

Resources defines a subset of the functionality provided by the state.Resources type, as required by the application facade. See the state.Resources type for details on the methods.

type Space

type Space interface {
	Name() string
	ProviderId() network.Id
}

type State

State represents the access patterns for the charm store methods.

func NewStateShim

func NewStateShim(st *state.State) State

type StateCharm

type StateCharm interface {
	IsUploaded() bool
}

StateCharm represents a Charm from the state package

type StateModel

type StateModel interface {
	ModelConfig() (*config.Config, error)
}

StateModel represents a Model from the state package

type Subnet

type Subnet interface {
	CIDR() string
	VLANTag() int
	ProviderId() network.Id
	ProviderNetworkId() network.Id
}

type Unit

type Unit interface {
	Name() string
	Tag() names.Tag
	UnitTag() names.UnitTag
	Destroy() error
	DestroyOperation() *state.DestroyUnitOperation
	IsPrincipal() bool
	Life() state.Life
	Resolve(retryHooks bool) error

	AssignedMachineId() (string, error)
	AssignWithPolicy(state.AssignmentPolicy) error
	AssignWithPlacement(*instance.Placement) error
}

Unit defines a subset of the functionality provided by the state.Unit type, as required by the application facade. For details on the methods, see the methods on state.Unit with the same names.

type UnitAdder

type UnitAdder interface {
	AddUnit(state.AddUnitParams) (Unit, error)
}

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