deployer

package
v0.0.0-...-bfa9622 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: AGPL-3.0 Imports: 51 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// BundleOnlyFlags represents what flags are used for bundles only.
	BundleOnlyFlags = []string{
		"overlay", "map-machines",
	}
)
View Source
var SupportedJujuBases = corebase.WorkloadBases

For testing. TODO: unexport it if we don't need to patch it anymore.

Functions

func CharmOnlyFlags

func CharmOnlyFlags() []string

CharmOnlyFlags and BundleOnlyFlags are used to validate flags based on whether we are deploying a charm or a bundle.

func DeployResources

func DeployResources(
	applicationID string,
	chID resources.CharmID,
	filesAndRevisions map[string]string,

	res map[string]charmresource.Meta,
	conn base.APICallCloser,
	filesystem modelcmd.Filesystem,
) (ids map[string]string, err error)

DeployResources uploads the bytes for the given files to the server and creates pending resource metadata for the all resource mentioned in the metadata. It returns a map of resource name to pending resource IDs.

func UploadExistingPendingResources

func UploadExistingPendingResources(
	appName string,
	pendingResources []application.PendingResourceUpload,
	conn base.APICallCloser,
	filesystem modelcmd.Filesystem) error

UploadExistingPendingResources uploads local resources. Used after DeployFromRepository, where the resources have been added to the controller. Called after AddApplication so no pending resource IDs are necessary, see juju attach for more examples.

Types

type ApplicationAPI

type ApplicationAPI interface {
	AddMachines(machineParams []apiparams.AddMachineParams) ([]apiparams.AddMachinesResult, error)
	AddRelation(endpoints, viaCIDRs []string) (*apiparams.AddRelationResults, error)
	AddUnits(application.AddUnitsParams) ([]string, error)
	Expose(application string, exposedEndpoints map[string]apiparams.ExposedEndpoint) error

	GetAnnotations(tags []string) ([]apiparams.AnnotationsGetResult, error)
	SetAnnotation(annotations map[string]map[string]string) ([]apiparams.ErrorResult, error)

	GetCharmURLOrigin(string, string) (*charm.URL, commoncharm.Origin, error)
	SetCharm(string, application.SetCharmConfig) error

	GetConfig(branchName string, appNames ...string) ([]map[string]interface{}, error)
	SetConfig(branchName string, application, configYAML string, config map[string]string) error

	GetConstraints(appNames ...string) ([]constraints.Value, error)
	SetConstraints(application string, constraints constraints.Value) error

	ScaleApplication(application.ScaleApplicationParams) (apiparams.ScaleApplicationResult, error)
	Consume(arg crossmodel.ConsumeApplicationArgs) (string, error)

	ApplicationsInfo([]names.ApplicationTag) ([]apiparams.ApplicationInfoResult, error)

	DeployFromRepository(arg application.DeployFromRepositoryArg) (application.DeployInfo, []application.PendingResourceUpload, []error)
}

type Bundle

type Bundle interface {
	// Data returns the contents of the bundle's bundle.yaml file.
	Data() *charm.BundleData // yes
	// ReadMe returns the contents of the bundle's README.md file.
	ReadMe() string
	// ContainsOverlays returns true if the bundle contains any overlays.
	ContainsOverlays() bool
}

Bundle is a local version of the charm.Bundle interface, for test with the Resolver interface.

type CharmDeployAPI

type CharmDeployAPI interface {
	CharmInfo(string) (*apicharms.CharmInfo, error)
	ListCharmResources(curl string, origin commoncharm.Origin) ([]charmresource.Resource, error)
}

CharmDeployAPI represents the methods of the API the deploy command needs for charms.

type CharmReader

type CharmReader interface {
	// ReadCharm reads a given charm from the filesystem.
	ReadCharm(string) (charm.Charm, error)
}

CharmReader aims to read a charm from the filesystem.

type ConsumeDetails

type ConsumeDetails interface {
	GetConsumeDetails(url string) (apiparams.ConsumeOfferDetails, error)
	Close() error
}

ConsumeDetails represents methods needed to consume an offer.

type DeployConfigFlag

type DeployConfigFlag interface {
	// AbsoluteFileNames returns the absolute path of any file names specified.
	AbsoluteFileNames(ctx *cmd.Context) ([]string, error)

	// ReadConfigPairs returns just the k=v attributes
	ReadConfigPairs(ctx *cmd.Context) (map[string]interface{}, error)
}

DeployConfigFlag defines methods required for charm config when deploying a charm.

type DeployResourcesFunc

type DeployResourcesFunc func(
	applicationID string,
	chID resources.CharmID,
	filesAndRevisions map[string]string,
	resources map[string]charmresource.Meta,
	conn base.APICallCloser,
	filesystem modelcmd.Filesystem,
) (ids map[string]string, err error)

DeployResourcesFunc is the function type of DeployResources.

type Deployer

type Deployer interface {
	// PrepareAndDeploy finishes preparing to deploy a charm or bundle,
	// then deploys it.  This is done as one step to accommodate the
	// call being wrapped by block.ProcessBlockedError.
	PrepareAndDeploy(*cmd.Context, DeployerAPI, Resolver) error

	// String returns a string description of the deployer.
	String() string
}

Deployer defines the functionality of a deployer returned by the factory.

type DeployerAPI

type DeployerAPI interface {
	// APICallCloser is needed for the DeployResourcesFunc.
	base.APICallCloser

	ApplicationAPI
	store.CharmAdder
	CharmDeployAPI
	ModelAPI
	OfferAPI

	ListSpaces() ([]apiparams.Space, error)
	Deploy(application.DeployArgs) error
	Status(*client.StatusArgs) (*apiparams.FullStatus, error)
	WatchAll() (api.AllWatch, error)
}

type DeployerConfig

type DeployerConfig struct {
	Model                ModelCommand
	ApplicationName      string
	AttachStorage        []string
	Bindings             map[string]string
	BindToSpaces         string
	BundleDevices        map[string]map[string]devices.Constraints
	BundleMachines       map[string]string
	BundleOverlayFile    []string
	BundleStorage        map[string]map[string]storage.Constraints
	Channel              charm.Channel
	CharmOrBundle        string
	DefaultCharmSchema   charm.Schema
	ConfigOptions        common.ConfigFlag
	ConstraintsStr       string
	Constraints          constraints.Value
	ModelConstraints     constraints.Value
	Devices              map[string]devices.Constraints
	DeployResources      DeployResourcesFunc
	DryRun               bool
	FlagSet              *gnuflag.FlagSet
	Force                bool
	NewConsumeDetailsAPI func(url *charm.OfferURL) (ConsumeDetails, error)
	NumUnits             int
	PlacementSpec        string
	Placement            []*instance.Placement
	Resources            map[string]string
	Revision             int
	Base                 corebase.Base
	Storage              map[string]storage.Constraints
	Trust                bool
	UseExisting          bool
}

DeployerConfig is the data required to choose a deployer and then run PrepareAndDeploy. TODO (hml) 2020-08-14 Is there a better structure for this config?

type DeployerDependencies

type DeployerDependencies struct {
	DeployResources      DeployResourcesFunc
	Model                ModelCommand
	FileSystem           modelcmd.Filesystem
	CharmReader          CharmReader
	NewConsumeDetailsAPI func(url *charm.OfferURL) (ConsumeDetails, error)
	DeployKind           DeployerFactory
}

DeployerDependencies are required for any deployer to be run.

type DeployerFactory

type DeployerFactory interface {
	GetDeployer(DeployerConfig, ModelConfigGetter, Resolver) (Deployer, error)
}

DeployerFactory contains a method to get a deployer.

func NewDeployerFactory

func NewDeployerFactory(dep DeployerDependencies) DeployerFactory

NewDeployerFactory returns a factory setup with the API and function dependencies required by every deployer.

type DeployerKind

type DeployerKind interface {
	CreateDeployer(d factory) (Deployer, error)
}

DeployerKind is an interface that provides CreateDeployer function to attempt creation of the related deployer.

type DeploymentInfo

type DeploymentInfo struct {
	CharmID         application.CharmID
	ApplicationName string
	ModelUUID       string
	CharmInfo       *apicommoncharms.CharmInfo
	ApplicationPlan string
	Force           bool
}

DeploymentInfo is used to maintain all deployment information for deployment steps.

type ModelAPI

type ModelAPI interface {
	ModelUUID() (string, bool)
	ModelGet() (map[string]interface{}, error)
	Sequences() (map[string]int, error)
	GetModelConstraints() (constraints.Value, error)
}

type ModelCommand

type ModelCommand interface {
	// BakeryClient returns a macaroon bakery client that
	// uses the same HTTP client returned by HTTPClient.
	BakeryClient() (*httpbakery.Client, error)

	// ControllerName returns the name of the controller that contains
	// the model returned by ModelName().
	ControllerName() (string, error)

	// CurrentAccountDetails returns details of the account associated with
	// the current controller.
	CurrentAccountDetails() (*jujuclient.AccountDetails, error)

	// ModelDetails returns details from the file store for the model indicated by
	// the currently set controller name and model identifier.
	ModelDetails() (string, *jujuclient.ModelDetails, error)

	// ModelType returns the type of the model.
	ModelType() (model.ModelType, error)

	// Filesystem returns an instance that provides access to
	// the filesystem, either delegating to calling os functions
	// or functions which always return an error.
	Filesystem() modelcmd.Filesystem
}

type ModelConfigGetter

type ModelConfigGetter interface {
	ModelGet() (map[string]interface{}, error)
}

type OfferAPI

type OfferAPI interface {
	Offer(modelUUID, application string, endpoints []string, owner, offerName, descr string) ([]apiparams.ErrorResult, error)
	GrantOffer(user, access string, offerURLs ...string) error
}

OfferAPI represents the methods of the API the deploy command needs for creating offers.

type Resolver

type Resolver interface {
	GetBundle(*charm.URL, commoncharm.Origin, string) (charm.Bundle, error)
	ResolveBundleURL(*charm.URL, commoncharm.Origin) (*charm.URL, commoncharm.Origin, error)
	ResolveCharm(url *charm.URL, preferredOrigin commoncharm.Origin, switchCharm bool) (*charm.URL, commoncharm.Origin, []corebase.Base, error)
}

Resolver defines what we need to resolve a charm or bundle and read the bundle data.

type UploadExistingPendingResourcesFunc

type UploadExistingPendingResourcesFunc func(appName string,
	pendingResources []application.PendingResourceUpload,
	conn base.APICallCloser,
	filesystem modelcmd.Filesystem) error

type ValidateLXDProfileCharm

type ValidateLXDProfileCharm struct{}

ValidateLXDProfileCharm implements the DeployStep interface.

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