application

package
v0.0.0-...-e6501ce Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: AGPL-3.0 Imports: 64 Imported by: 5

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 ClassifyDetachedStorage = storagecommon.ClassifyDetachedStorage
View Source
var (
	// ErrInvalidAgentVersions is a sentinal error for when we can no longer
	// upgrade juju using 2.5.x agents with 2.6 or greater controllers.
	ErrInvalidAgentVersions = errors.Errorf(
		"Unable to upgrade LXDProfile charms with the current model version. " +
			"Please run juju upgrade-model to upgrade the current model to match your controller.")
)
View Source
var (
	// Overridden by tests.
	SupportedFeaturesGetter = stateenvirons.SupportedFeatures
)

Functions

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 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 Register

func Register(registry facade.FacadeRegistry)

Register is called to expose a package of facades onto a given registry.

func StateCharmOrigin

func StateCharmOrigin(origin corecharm.Origin) (*state.CharmOrigin, error)

StateCharmOrigin returns a state layer CharmOrigin given a core Origin.

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.

func NewAPIBase

func NewAPIBase(
	backend Backend,
	storageAccess StorageInterface,
	authorizer facade.Authorizer,
	updateBase UpdateBase,
	repoDeploy DeployFromRepository,
	blockChecker BlockChecker,
	model Model,
	leadershipReader leadership.Reader,
	stateCharm func(Charm) *state.Charm,
	deployApplication func(ApplicationDeployer, Model, DeployApplicationParams) (Application, error),
	storagePoolManager poolmanager.PoolManager,
	registry storage.ProviderRegistry,
	resources facade.Resources,
	caasBroker CaasBrokerInterface,
) (*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) DeployFromRepository

DeployFromRepository is a one-stop deployment method for repository charms. Only a charm name is required to deploy. If argument validation fails, a list of all errors found in validation will be returned. If a local resource is provided, details required for uploading the validated resource will be returned.

func (*APIBase) Destroy

func (*APIBase) Destroy(_, _ struct{})

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 (*APIBase) DestroyUnits(_, _ struct{})

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) GetCharmURLOrigin

func (api *APIBase) GetCharmURLOrigin(args params.ApplicationGet) (params.CharmURLOriginResult, error)

GetCharmURLOrigin returns the charm URL and charm origin 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) Leader

func (api *APIBase) Leader(entity params.Entity) (params.StringResult, error)

Leader returns the unit name of the leader for the given application.

func (*APIBase) MergeBindings

MergeBindings merges operator-defined bindings with the current bindings for one or more applications.

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) SetCharm

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

SetCharm sets the charm for a given for the application.

func (*APIBase) SetConfigs

func (api *APIBase) SetConfigs(args params.ConfigSetArgs) (params.ErrorResults, error)

SetConfigs implements the server side of Application.SetConfig. Both application and charm config are set. It does not unset values in Config map that are set to an empty string. Unset should be used for that.

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. TODO (cderici) only used for metered charms in cmd MeteredDeployAPI, kept for client compatibility, remove in juju 4.0

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) UnitsInfo

func (api *APIBase) UnitsInfo(in params.Entities) (params.UnitInfoResults, error)

UnitsInfo returns unit information for the given entities (units or applications).

func (*APIBase) UnsetApplicationsConfig

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

UnsetApplicationsConfig implements the server side of Application.UnsetApplicationsConfig.

func (*APIBase) UpdateApplicationBase

func (api *APIBase) UpdateApplicationBase(args params.UpdateChannelArgs) (params.ErrorResults, error)

UpdateApplicationBase updates the application base. Base for subordinates is updated too.

type APIv15

type APIv15 struct {
	*APIv16
}

APIv15 provides the Application API facade for version 15.

func (*APIv15) DestroyApplication

DestroyApplication removes a given set of applications.

func (*APIv15) DestroyUnit

func (api *APIv15) DestroyUnit(argsV15 params.DestroyUnitsParamsV15) (params.DestroyUnitResults, error)

type APIv16

type APIv16 struct {
	*APIv17
}

APIv16 provides the Application API facade for version 16.

func (*APIv16) Destroy

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

Destroy destroys a given application, local or remote.

TODO(jack-w-shaw) Drop this once facade 16 is not longer supported

func (*APIv16) DestroyUnits

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

DestroyUnits removes a given set of application units.

TODO(jack-w-shaw) Drop this once facade 16 is not longer supported

type APIv17

type APIv17 struct {
	*APIv18
}

APIv17 provides the Application API facade for version 17.

type APIv18

type APIv18 struct {
	*APIv19
}

APIv18 provides the Application API facade for version 18.

func (*APIv18) DeployFromRepository

DeployFromRepository for facade v18. The method was still not fully complete until v19. The NotImplemented error was for development purposes while use was behind a feature flag in the juju client.

type APIv19

type APIv19 struct {
	*APIv20
}

APIv19 provides the Application API facade for version 19.

func (*APIv19) Consume

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

type APIv20

type APIv20 struct {
	*APIBase
}

APIv20 provides the Application API facade for version 20.

type AgentTools

type AgentTools interface {
	AgentTools() (*tools.Tools, error)
}

AgentTools is a point of use agent tools requester.

type AgentVersioner

type AgentVersioner interface {
	AgentVersion() (version.Number, error)
}

AgentVersioner is a point of use agent version object.

type Application

type Application interface {
	Name() string
	AddUnit(state.AddUnitParams) (Unit, error)
	AllUnits() ([]Unit, error)
	ApplicationConfig() (coreconfig.ConfigAttributes, error)
	ApplicationTag() names.ApplicationTag
	Charm() (Charm, bool, error)
	CharmURL() (*string, bool)
	CharmOrigin() *state.CharmOrigin
	ClearExposed() error
	CharmConfig(string) (charm.Settings, error)
	Constraints() (constraints.Value, error)
	Destroy() error
	DestroyOperation() *state.DestroyApplicationOperation
	EndpointBindings() (Bindings, error)
	ExposedEndpoints() map[string]state.ExposedEndpoint
	Endpoints() ([]state.Endpoint, error)
	IsExposed() bool
	IsPrincipal() bool
	IsRemote() bool
	Life() state.Life
	SetCharm(state.SetCharmConfig) error
	SetConstraints(constraints.Value) error
	MergeExposeSettings(map[string]state.ExposedEndpoint) error
	UnsetExposeSettings([]string) error
	SetMetricCredentials([]byte) error
	SetMinUnits(int) error
	UpdateApplicationBase(state.Base, bool) error
	UpdateCharmConfig(string, charm.Settings) error
	UpdateApplicationConfig(coreconfig.ConfigAttributes, []string, environschema.Fields, schema.Defaults) error
	SetScale(int, int64, bool) error
	ChangeScale(int) (int, error)
	AgentTools() (*tools.Tools, error)
	MergeBindings(*state.Bindings, bool) error
	Relations() ([]Relation, 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, model Model, 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)
	ControllerConfig() (controller.Config, error)
}

type Backend

type Backend interface {
	AllModelUUIDs() ([]string, error)
	Application(string) (Application, error)
	ApplicationOfferForUUID(offerUUID string) (*crossmodel.ApplicationOffer, error)
	ApplyOperation(state.ModelOperation) error
	AddApplication(state.AddApplicationArgs) (Application, error)
	AddPendingResource(string, resource.Resource) (string, error)
	RemovePendingResources(applicationID string, pendingIDs map[string]string) error
	AddCharmMetadata(info state.CharmInfo) (Charm, error)
	RemoteApplication(string) (RemoteApplication, error)
	AddRemoteApplication(state.AddRemoteApplicationParams) (RemoteApplication, error)
	AddRelation(...state.Endpoint) (Relation, error)
	Charm(string) (Charm, error)
	Relation(int) (Relation, error)
	InferEndpoints(...string) ([]state.Endpoint, error)
	InferActiveRelation(...string) (Relation, error)
	Machine(string) (Machine, error)
	Model() (Model, error)
	Unit(string) (Unit, error)
	UnitsInError() ([]Unit, error)
	SaveController(info crossmodel.ControllerInfo, modelUUID string) (ExternalController, error)
	ControllerTag() names.ControllerTag
	ControllerConfig() (controller.Config, error)
	Resources() Resources
	OfferConnectionForRelation(string) (OfferConnection, error)
	SaveEgressNetworks(relationKey string, cidrs []string) (state.RelationNetworks, error)
	Branch(string) (Generation, error)
	state.EndpointBinding
	ModelConstraints() (constraints.Value, error)
	services.StateBackend
}

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 Bindings

type Bindings interface {
	Map() map[string]string
	MapWithSpaceNames(network.SpaceInfos) (map[string]string, error)
}

Bindings defines a subset of the functionality provided by the state.Bindings type, as required by the application facade. For details on the methods, see the methods on state.Bindings 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 CaasBrokerInterface

type CaasBrokerInterface interface {
	ValidateStorageClass(config map[string]interface{}) error
	Version() (*version.Number, error)
}

type Charm

type Charm interface {
	CharmMeta
	Config() *charm.Config
	Metrics() *charm.Metrics
	Actions() *charm.Actions
	Revision() int
	IsUploaded() bool
}

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 CharmMeta

type CharmMeta interface {
	Manifest() *charm.Manifest
	Meta() *charm.Meta
}

CharmMeta describes methods that inform charm operation.

type CharmhubClient

type CharmhubClient interface {
	Refresh(ctx context.Context, config charmhub.RefreshConfig) ([]transport.RefreshResponse, error)
}

CharmhubClient represents a way for querying the charmhub api for information about the application charm.

type DeployApplicationParams

type DeployApplicationParams struct {
	ApplicationName   string
	Charm             *state.Charm
	CharmOrigin       corecharm.Origin
	ApplicationConfig *config.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

	// If set to true, any charm-specific requirements ("assumes" section)
	// will be ignored.
	Force bool
}

DeployApplicationParams contains the arguments required to deploy the referenced charm.

type DeployFromRepository

type DeployFromRepository interface {
	DeployFromRepository(arg params.DeployFromRepositoryArg) (params.DeployFromRepositoryInfo, []*params.PendingResourceUpload, []error)
}

DeployFromRepository defines an interface for deploying a charm from a repository.

func NewDeployFromRepositoryAPI

func NewDeployFromRepositoryAPI(state DeployFromRepositoryState, validator DeployFromRepositoryValidator) DeployFromRepository

NewDeployFromRepositoryAPI creates a new DeployFromRepositoryAPI.

type DeployFromRepositoryAPI

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

DeployFromRepositoryAPI provides the deploy from repository API facade for any given version. It is expected that any API parameter changes should be performed before entering the API.

type DeployFromRepositoryState

type DeployFromRepositoryState interface {
	AddApplication(state.AddApplicationArgs) (Application, error)
	AddPendingResource(string, resource.Resource) (string, error)
	RemovePendingResources(applicationID string, pendingIDs map[string]string) error
	AddCharmMetadata(info state.CharmInfo) (Charm, error)
	Charm(string) (Charm, error)
	ControllerConfig() (controller.Config, error)
	Machine(string) (Machine, error)
	ModelConstraints() (constraints.Value, error)

	services.StateBackend

	network.SpaceLookup
	DefaultEndpointBindingSpace() (string, error)
	Space(id string) (*state.Space, error)
}

DeployFromRepositoryState defines a common set of functions for retrieving state objects.

type DeployFromRepositoryValidator

type DeployFromRepositoryValidator interface {
	ValidateArg(params.DeployFromRepositoryArg) (deployTemplate, []error)
}

DeployFromRepositoryValidator defines an deploy config validator.

type ExternalController

type ExternalController state.ExternalController

type Generation

type Generation interface {
	AssignApplication(string) error
}

type Machine

type Machine interface {
	Base() state.Base
	HardwareCharacteristics() (*instance.HardwareCharacteristics, error)
	Id() string
	PublicAddress() (network.SpaceAddress, error)
	IsLockedForSeriesUpgrade() (bool, error)
	IsParentLockedForSeriesUpgrade() (bool, 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 MachinePlacementBackend

type MachinePlacementBackend interface {
	Machine(string) (Machine, error)
}

type Model

type Model interface {
	ModelTag() names.ModelTag
	Name() string
	Owner() names.UserTag
	Tag() names.Tag
	Type() state.ModelType
	UUID() string
	ModelConfig() (*config.Config, error)
	AgentVersion() (version.Number, error)
	OpenedPortRangesForMachine(string) (state.MachinePortRanges, error)
	// The following methods are required for querying the featureset
	// supported by the model.
	Config() (*config.Config, error)
	CloudName() string
	Cloud() (cloud.Cloud, error)
	CloudCredential() (state.Credential, bool, error)
	CloudRegion() string
	ControllerUUID() string
}

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 OfferConnection

type OfferConnection interface {
	UserName() string
	OfferUUID() string
}

type Relation

type Relation interface {
	status.StatusSetter
	Tag() names.Tag
	Destroy() error
	DestroyWithForce(bool, time.Duration) ([]error, error)
	Id() int
	Endpoints() []state.Endpoint
	RelatedEndpoints(applicationname string) ([]state.Endpoint, error)
	ApplicationSettings(appName string) (map[string]interface{}, error)
	AllRemoteUnits(appName string) ([]RelationUnit, error)
	Unit(string) (RelationUnit, 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 RelationUnit

type RelationUnit interface {
	UnitName() string
	InScope() (bool, error)
	Settings() (map[string]interface{}, error)
}

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
	DestroyOperation(force bool) *state.DestroyRemoteApplicationOperation
	Status() (status.StatusInfo, error)
	Life() state.Life
}

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 StorageInterface

type StorageInterface interface {
	storagecommon.StorageAccess
	VolumeAccess() storagecommon.VolumeAccess
	FilesystemAccess() storagecommon.FilesystemAccess
}

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
	ApplicationName() string
	Destroy() error
	DestroyOperation() *state.DestroyUnitOperation
	IsPrincipal() bool
	Life() state.Life
	Resolve(retryHooks bool) error
	AgentTools() (*tools.Tools, error)

	AssignedMachineId() (string, error)
	WorkloadVersion() (string, error)
	AssignWithPolicy(state.AssignmentPolicy) error
	AssignWithPlacement(*instance.Placement) error
	ContainerInfo() (state.CloudContainer, 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)
}

type UpdateBase

type UpdateBase interface {

	// UpdateBase attempts to update an application base for deploying new
	// units.
	UpdateBase(string, corebase.Base, bool) error
}

UpdateBase defines an interface for interacting with updating a base.

type UpdateBaseAPI

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

UpdateBaseAPI provides the update series API facade for any given version. It is expected that any API parameter changes should be performed before entering the API.

func NewUpdateBaseAPI

func NewUpdateBaseAPI(
	state UpdateBaseState,
	validator UpdateBaseValidator,
) *UpdateBaseAPI

NewUpdateBaseAPI creates a new UpdateBaseAPI

func (*UpdateBaseAPI) UpdateBase

func (a *UpdateBaseAPI) UpdateBase(tag string, base corebase.Base, force bool) error

type UpdateBaseState

type UpdateBaseState interface {
	// Application returns a list of all the applications for a
	// given machine. This includes all the subordinates.
	Application(string) (Application, error)
}

UpdateBaseState defines a common set of functions for retrieving state objects.

type UpdateBaseValidator

type UpdateBaseValidator interface {
	// ValidateApplication attempts to validate an application for
	// a given base. Using force to allow the overriding of the error to
	// ensure all application validate.
	//
	// I do question if you actually need to validate anything if force is
	// employed here?
	ValidateApplication(application Application, base corebase.Base, force bool) error
}

UpdateBaseValidator defines an application validator.

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