application

package
v0.0.0-...-9ec3720 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2021 License: AGPL-3.0 Imports: 61 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 (
	// 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-juju to upgrade the current model to match your controller.")
)
View Source
var OpenCSRepo = func(args OpenCSRepoParams) (Repository, error) {
	csClient, err := openCSClient(args)
	if err != nil {
		return nil, err
	}
	repo := charmrepo.NewCharmStoreFromClient(csClient)
	return &charmRepoShim{repo}, nil
}

Functions

func AddCharmWithAuthorization

func AddCharmWithAuthorization(st State, args params.AddCharmWithAuthorization, openCSRepo OpenCSRepoFunc) 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.

NOTE: AddCharmWithAuthorization is deprecated as of juju 2.9 and charms facade version 3. Please discontinue use and move to the charms facade version.

TODO: remove in juju 3.0

func AddCharmWithAuthorizationAndRepo

func AddCharmWithAuthorizationAndRepo(st State, args params.AddCharmWithAuthorization, repoFn func() (Repository, 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 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, openCSRepo OpenCSRepoFunc) (params.ResolveCharmResults, error)

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

NOTE: ResolveCharms is deprecated as of juju 2.9 and charms facade version 3. Please discontinue use and move to the charms facade version.

TODO: remove in juju 3.0

func StoreCharmArchive

func StoreCharmArchive(st State, archive CharmArchive) error

StoreCharmArchive stores a charm archive in environment storage.

TODO: (hml) 2020-09-01 Move use of this function to the charms facade. A private version is currently in use there. It should be made public.

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,
	updateSeries UpdateSeries,
	blockChecker BlockChecker,
	model Model,
	leadershipReader leadership.Reader,
	stateCharm func(Charm) *state.Charm,
	deployApplication func(ApplicationDeployer, 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) 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) 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) 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.

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.

func (*APIBase) UnsetApplicationsConfig

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

UnsetApplicationsConfig implements the server side of Application.UnsetApplicationsConfig.

func (*APIBase) UpdateApplicationSeries

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

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

type APIv13

type APIv13 struct {
	*APIBase
}

APIv13 provides the Application API facade for version 13.

func NewFacadeV13

func NewFacadeV13(ctx facade.Context) (*APIv13, error)

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() (application.ConfigAttributes, error)
	Charm() (Charm, bool, error)
	CharmURL() (*charm.URL, bool)
	Channel() csparams.Channel
	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
	Series() string
	SetCharm(state.SetCharmConfig) error
	SetConstraints(constraints.Value) error
	MergeExposeSettings(map[string]state.ExposedEndpoint) error
	UnsetExposeSettings([]string) error
	SetMetricCredentials([]byte) error
	SetMinUnits(int) error
	UpdateApplicationSeries(string, bool) error
	UpdateCharmConfig(string, charm.Settings) error
	UpdateApplicationConfig(application.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, 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
	ControllerConfig() (controller.Config, error)
	Resources() (Resources, error)
	OfferConnectionForRelation(string) (OfferConnection, error)
	SaveEgressNetworks(relationKey string, cidrs []string) (state.RelationNetworks, error)
	Branch(string) (Generation, error)
	state.EndpointBinding
}

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 Charm

type Charm interface {
	charm.Charm
	URL() *charm.URL
	String() string
}

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 CharmMeta

type CharmMeta interface {
	ComputedSeries() []string
}

type CharmState

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

CharmState represents directives for accessing charm methods

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 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
	CharmOrigin       corecharm.Origin
	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 Generation

type Generation interface {
	AssignApplication(string) error
}

type Machine

type Machine interface {
	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 Model

type Model interface {
	ModelTag() names.ModelTag
	Name() string
	Owner() names.UserTag
	Tag() names.Tag
	Type() state.ModelType
	ModelConfig() (*config.Config, error)
	AgentVersion() (version.Number, error)
	OpenedPortRangesForMachine(string) (state.MachinePortRanges, error)
}

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 OpenCSRepoFunc

type OpenCSRepoFunc func(args OpenCSRepoParams) (Repository, error)

type OpenCSRepoParams

type OpenCSRepoParams struct {
	CSURL              string
	Channel            string
	CharmStoreMacaroon *macaroon.Macaroon
}

type Relation

type Relation interface {
	status.StatusSetter
	Tag() names.Tag
	Destroy() error
	DestroyWithForce(bool, time.Duration) ([]error, error)
	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
}

type Repository

type Repository interface {
	// FindDownloadURL returns a url from which a charm can be downloaded
	// based on the given charm url and charm origin.  A charm origin
	// updated with the ID and hash for the download is also returned.
	FindDownloadURL(curl *charm.URL, origin corecharm.Origin) (*url.URL, corecharm.Origin, error)

	// DownloadCharm reads the charm referenced by curl or downloadURL into
	// a file with the given path, which will be created if needed. Note
	// that the path's parent directory must already exist.
	DownloadCharm(resourceURL string, archivePath string) (*charm.CharmArchive, error)

	// Resolve a canonical URL for retrieving the charm includes the most
	// current revision, if none was provided and a slice  of series supported
	// by this charm.
	Resolve(ref *charm.URL) (canonRef *charm.URL, supportedSeries []string, err error)
}

Repository represents the necessary methods to resolve and download charms from a repository where they reside.

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

type UpdateSeries interface {

	// UpdateSeries attempts to update an application series for deploying new
	// units.
	UpdateSeries(string, string, bool) error
}

UpdateSeries defines an interface for interacting with updating a series.

type UpdateSeriesAPI

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

UpdateSeriesAPI 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 NewUpdateSeriesAPI

func NewUpdateSeriesAPI(
	state UpdateSeriesState,
	validator UpdateSeriesValidator,
) *UpdateSeriesAPI

NewUpdateSeriesAPI creates a new UpdateSeriesAPI

func (*UpdateSeriesAPI) UpdateSeries

func (a *UpdateSeriesAPI) UpdateSeries(tag, series string, force bool) error

type UpdateSeriesState

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

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

type UpdateSeriesValidator

type UpdateSeriesValidator interface {
	// ValidateApplication attempts to validate an application for
	// a given series. 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, series string, force bool) error
}

UpdateSeriesValidator 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