juju

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 59 Imported by: 0

Documentation

Overview

Package juju is a facade to make interacting with Juju clients simpler. It also acts as an insulating layer protecting the provider package from upstream changes. The long-term intention is for this package to be removed. Eventually, it would be nice for this package to be replaced with more granular clients in Juju itself. Note that much of this code is duplicated from Juju CLI commands.

In comments and in code we refer to integrations which are known in juju 2.x as relations. calls to the upstream juju client currently reference relations

Index

Constants

View Source
const (
	PrefixCloud         = "cloud-"
	PrefixModel         = "model-"
	PrefixCharm         = "charm-"
	PrefixUser          = "user-"
	PrefixMachine       = "machine-"
	UnspecifiedRevision = -1
)
View Source
const (
	// IntegrationQueryTick defines the time to wait between ticks
	// when querying the API
	IntegrationApiTickWait = time.Second * 5
	// IntegrationAppAvailableTimeout indicates the time to wait
	// for applications to be available before integrating them
	IntegrationAppAvailableTimeout = time.Second * 60
)
View Source
const (
	// OfferAppAvailableTimeout is the time to wait for an app to be available
	// before creating an offer.
	OfferAppAvailableTimeout = time.Second * 60
	// OfferApiTickWait is the time to wait between consecutive requests
	// to the API
	OfferApiTickWait = time.Second * 5
)
View Source
const LogJujuClient = "client"

module names for logging @module=juju.<subsystem> e.g.:

@module=juju.client

Variables

View Source
var ApplicationNotFoundError = &applicationNotFoundError{}
View Source
var ModelNotFoundError = &modelNotFoundError{}
View Source
var NoIntegrationFoundError = &noIntegrationFoundError{}

Functions

func ConfigEntryToString added in v0.5.0

func ConfigEntryToString(input interface{}) string

ConfigEntryToString returns the string representation based on the current value.

func EqualConfigEntries added in v0.5.0

func EqualConfigEntries(a interface{}, b interface{}) bool

EqualConfigEntries compare two juju configuration entries. If both entries share the same type, otherwise they are considered to be different.

func GetCloudCredentialTag added in v0.5.0

func GetCloudCredentialTag(cloudName, currentUser, name string) (*names.CloudCredentialTag, error)

func GetLocalControllerConfig added in v0.4.0

func GetLocalControllerConfig() (map[string]string, error)

GetLocalControllerConfig runs the locally installed juju command, if available, to get the current controller configuration.

func WaitForAppsAvailable added in v0.7.0

func WaitForAppsAvailable(ctx context.Context, client *apiapplication.Client, appsName []string, tickTime time.Duration) error

WaitForAppAvailable blocks the execution flow and waits until all the application names can be queried before the context is done. The tickTime param indicates the frequency used to query the API.

Types

type Application added in v0.4.0

type Application struct {
	Name     string
	Endpoint string
	Role     string
	OfferURL *string
}

type ApplicationAPIClient added in v0.11.0

type ApplicationAPIClient interface {
	AddUnits(args apiapplication.AddUnitsParams) ([]string, error)
	ApplicationsInfo(applications []names.ApplicationTag) ([]params.ApplicationInfoResult, error)
	Deploy(args apiapplication.DeployArgs) error
	DestroyUnits(in apiapplication.DestroyUnitsParams) ([]params.DestroyUnitResult, error)
	DestroyApplications(in apiapplication.DestroyApplicationsParams) ([]params.DestroyApplicationResult, error)
	Expose(application string, exposedEndpoints map[string]params.ExposedEndpoint) error
	Get(branchName, application string) (*params.ApplicationGetResults, error)
	GetCharmURLOrigin(branchName, applicationName string) (*charm.URL, apicommoncharm.Origin, error)
	GetConstraints(applications ...string) ([]constraints.Value, error)
	MergeBindings(req params.ApplicationMergeBindingsArgs) error
	ScaleApplication(in apiapplication.ScaleApplicationParams) (params.ScaleApplicationResult, error)
	SetCharm(branchName string, cfg apiapplication.SetCharmConfig) error
	SetConfig(branchName, application, configYAML string, config map[string]string) error
	SetConstraints(application string, constraints constraints.Value) error
	Unexpose(application string, endpoints []string) error
}

type Client

type Client struct {
	Applications applicationsClient
	Machines     machinesClient
	Credentials  credentialsClient
	Integrations integrationsClient
	Models       modelsClient
	Offers       offersClient
	SSHKeys      sshKeysClient
	Users        usersClient
}

func NewClient

func NewClient(ctx context.Context, config ControllerConfiguration) (*Client, error)

NewClient returns a client which can talk to the juju controller represented by controllerConfig. A context is required for logging in the terraform framework.

type ClientAPIClient added in v0.11.0

type ClientAPIClient interface {
	Status(args *apiclient.StatusArgs) (*params.FullStatus, error)
}

type ConfigEntry added in v0.5.0

type ConfigEntry struct {
	Value     interface{}
	IsDefault bool
}

ConfigEntry is an auxiliar struct to keep information about juju application config entries. Specially, we want to know if they have the default value.

func (*ConfigEntry) String added in v0.5.0

func (ce *ConfigEntry) String() string

type ConsumeRemoteOfferInput added in v0.4.0

type ConsumeRemoteOfferInput struct {
	ModelName string
	OfferURL  string
}

type ConsumeRemoteOfferResponse added in v0.4.0

type ConsumeRemoteOfferResponse struct {
	SAASName string
}

type ControllerConfiguration added in v0.9.0

type ControllerConfiguration struct {
	ControllerAddresses []string
	Username            string
	Password            string
	CACert              string
}

type CreateApplicationInput added in v0.2.0

type CreateApplicationInput struct {
	ApplicationName  string
	ModelName        string
	CharmName        string
	CharmChannel     string
	CharmBase        string
	CharmSeries      string
	CharmRevision    int
	Units            int
	Trust            bool
	Expose           map[string]interface{}
	Config           map[string]string
	Placement        string
	Constraints      constraints.Value
	EndpointBindings map[string]string
	Resources        map[string]int
}

type CreateApplicationResponse added in v0.2.0

type CreateApplicationResponse struct {
	AppName string
}

type CreateCredentialInput added in v0.5.0

type CreateCredentialInput struct {
	Attributes           map[string]string
	AuthType             string
	ClientCredential     bool
	CloudName            string
	ControllerCredential bool
	Name                 string
}

type CreateCredentialResponse added in v0.5.0

type CreateCredentialResponse struct {
	CloudCredential jujucloud.Credential
	CloudName       string
}

type CreateIntegrationResponse added in v0.4.0

type CreateIntegrationResponse struct {
	Applications []Application
}

type CreateMachineInput added in v0.6.0

type CreateMachineInput struct {
	ModelName   string
	Constraints string
	Disks       string
	Base        string
	Placement   string
	Series      string
	InstanceId  string

	// SSHAddress is the host address of a machine for manual provisioning
	// Note that it has the user too, e.g. user@host
	SSHAddress string

	// PublicKey is the file path to read the public key from
	PublicKeyFile string

	// PrivateKey is the file path to read the private key from
	PrivateKeyFile string
}

type CreateMachineResponse added in v0.6.0

type CreateMachineResponse struct {
	ID     string
	Base   string
	Series string
}

type CreateModelInput added in v0.4.0

type CreateModelInput struct {
	Name        string
	CloudName   string
	CloudRegion string
	Config      map[string]string
	Credential  string
	Constraints constraints.Value
}

type CreateModelResponse added in v0.4.0

type CreateModelResponse struct {
	Cloud               string
	CloudRegion         string
	CloudCredentialName string
	Type                string
	UUID                string
}

type CreateOfferInput added in v0.4.0

type CreateOfferInput struct {
	ApplicationName string
	Endpoint        string
	ModelName       string
	ModelOwner      string
	Name            string
}

type CreateOfferResponse added in v0.4.0

type CreateOfferResponse struct {
	Name     string
	OfferURL string
}

type CreateSSHKeyInput added in v0.5.0

type CreateSSHKeyInput struct {
	ModelName string
	Payload   string
}

type CreateUserInput added in v0.5.0

type CreateUserInput struct {
	Name        string
	DisplayName string
	Model       string
	Password    string
}

type CreateUserResponse added in v0.5.0

type CreateUserResponse struct {
	UserTag names.UserTag
	Secret  []byte
}

type DeleteSSHKeyInput added in v0.5.0

type DeleteSSHKeyInput struct {
	ModelName     string
	KeyIdentifier string
}

type DestroyAccessModelInput added in v0.5.0

type DestroyAccessModelInput struct {
	ModelName string
	Revoke    []string
	Access    string
}

type DestroyApplicationInput added in v0.2.0

type DestroyApplicationInput struct {
	ApplicationName string
	ModelName       string
}

type DestroyCredentialInput added in v0.5.0

type DestroyCredentialInput struct {
	ClientCredential     bool
	CloudName            string
	ControllerCredential bool
	Name                 string
}

type DestroyMachineInput added in v0.6.0

type DestroyMachineInput struct {
	ModelName string
	ID        string
}

type DestroyModelInput added in v0.4.0

type DestroyModelInput struct {
	UUID string
}

type DestroyOfferInput added in v0.4.0

type DestroyOfferInput struct {
	OfferURL string
}

type DestroyUserInput added in v0.5.0

type DestroyUserInput struct {
	Name string
}

type GrantModelInput added in v0.5.0

type GrantModelInput struct {
	User      string
	Access    string
	ModelName string
}

type IntegrationInput added in v0.3.0

type IntegrationInput struct {
	ModelName string
	Apps      []string
	Endpoints []string
	ViaCIDRs  string
}

type ModelConfigAPIClient added in v0.11.0

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

type Offer added in v0.4.0

type Offer struct {
	OfferURL string
}

type ReadApplicationInput added in v0.2.0

type ReadApplicationInput struct {
	ModelName string
	AppName   string
}

type ReadApplicationResponse added in v0.2.0

type ReadApplicationResponse struct {
	Name             string
	Channel          string
	Revision         int
	Base             string
	Series           string
	Units            int
	Trust            bool
	Config           map[string]ConfigEntry
	Constraints      constraints.Value
	Expose           map[string]interface{}
	Principal        bool
	Placement        string
	EndpointBindings map[string]string
	Resources        map[string]int
}

type ReadCredentialInput added in v0.5.0

type ReadCredentialInput struct {
	Name                 string
	ClientCredential     bool
	CloudName            string
	ControllerCredential bool
}

type ReadCredentialResponse added in v0.5.0

type ReadCredentialResponse struct {
	CloudCredential jujucloud.Credential
}

type ReadIntegrationResponse added in v0.4.0

type ReadIntegrationResponse struct {
	Applications []Application
}

type ReadMachineInput added in v0.6.0

type ReadMachineInput struct {
	ModelName string
	ID        string
}

type ReadMachineResponse added in v0.6.0

type ReadMachineResponse struct {
	ID          string
	Base        string
	Constraints string
	Series      string
}

type ReadModelResponse added in v0.4.0

type ReadModelResponse struct {
	ModelInfo        params.ModelInfo
	ModelConfig      map[string]interface{}
	ModelConstraints constraints.Value
}

type ReadModelUserResponse added in v0.5.0

type ReadModelUserResponse struct {
	ModelUserInfo []params.ModelUserInfo
}

type ReadOfferInput added in v0.4.0

type ReadOfferInput struct {
	OfferURL string
}

type ReadOfferResponse added in v0.4.0

type ReadOfferResponse struct {
	ApplicationName string
	Endpoint        string
	ModelName       string
	Name            string
	OfferURL        string
}

type ReadSSHKeyInput added in v0.5.0

type ReadSSHKeyInput struct {
	ModelName     string
	KeyIdentifier string
}

type ReadSSHKeyOutput added in v0.5.0

type ReadSSHKeyOutput struct {
	ModelName string
	Payload   string
}

type ReadUserInput added in v0.5.0

type ReadUserInput struct {
	Name string
}

type ReadUserResponse added in v0.5.0

type ReadUserResponse struct {
	UserInfo params.UserInfo
}

type RemoveRemoteOfferInput added in v0.4.0

type RemoveRemoteOfferInput struct {
	ModelName string
	OfferURL  string
}

type ResourceAPIClient added in v0.11.0

type ResourceAPIClient interface {
	AddPendingResources(args apiresources.AddPendingResourcesArgs) ([]string, error)
	ListResources(applications []string) ([]resources.ApplicationResources, error)
}

type SharedClient added in v0.9.0

type SharedClient interface {
	AddModel(modelName, modelUUID string, modelType model.ModelType)
	GetConnection(modelName *string) (api.Connection, error)
	ModelType(modelName string) (model.ModelType, error)
	ModelUUID(modelName string) (string, error)
	RemoveModel(modelUUID string)

	Debugf(msg string, additionalFields ...map[string]interface{})
	Errorf(err error, msg string)
	Tracef(msg string, additionalFields ...map[string]interface{})
	Warnf(msg string, additionalFields ...map[string]interface{})

	JujuLogger() *jujuLoggerShim
}

type UpdateAccessModelInput added in v0.5.0

type UpdateAccessModelInput struct {
	ModelName string
	OldAccess string
	Grant     []string
	Revoke    []string
	Access    string
}

type UpdateApplicationInput added in v0.2.0

type UpdateApplicationInput struct {
	ModelName string
	ModelInfo *params.ModelInfo
	AppName   string
	Units     *int
	Revision  *int
	Channel   string
	Trust     *bool
	Expose    map[string]interface{}
	// Unexpose indicates what endpoints to unexpose
	Unexpose []string
	Config   map[string]string
	//Series    string // Unsupported today
	Placement        map[string]interface{}
	Constraints      *constraints.Value
	EndpointBindings map[string]string
	Resources        map[string]int
}

type UpdateCredentialInput added in v0.5.0

type UpdateCredentialInput struct {
	Attributes           map[string]string
	AuthType             string
	ClientCredential     bool
	CloudName            string
	ControllerCredential bool
	Name                 string
}

type UpdateIntegrationInput added in v0.3.0

type UpdateIntegrationInput struct {
	ModelName    string
	Endpoints    []string
	OldEndpoints []string
	ViaCIDRs     string
}

type UpdateIntegrationResponse added in v0.4.0

type UpdateIntegrationResponse struct {
	Applications []Application
}

type UpdateModelInput added in v0.4.0

type UpdateModelInput struct {
	Name        string
	CloudName   string
	Config      map[string]string
	Unset       []string
	Constraints *constraints.Value
	Credential  string
}

type UpdateUserInput added in v0.5.0

type UpdateUserInput struct {
	Name        string
	DisplayName string
	User        string
	Password    string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL