Documentation
¶
Index ¶
- func ActionLogf(format string, args ...any) error
- func AddSecret(opts *AddSecretOptions) (string, error)
- func AddStorage(name string, count int) error
- func ClosePort(port int, protocol Protocol) error
- func DeleteState(key string) error
- func FailActionf(format string, args ...any) error
- func GetActionParams(params any) error
- func GetAppRelationData(id string, unitID string) (map[string]string, error)
- func GetConfig(config any) error
- func GetCredential() (map[string]string, error)
- func GetRelationApp(id string) (string, error)
- func GetRelationIDs(name string) ([]string, error)
- func GetRelationModelUUID(id string) (string, error)
- func GetResource(name string) (string, error)
- func GetSecretByID(id string, peek bool, refresh bool) (map[string]string, error)
- func GetSecretByLabel(label string, peek bool, refresh bool) (map[string]string, error)
- func GetSecretIDs() ([]string, error)
- func GetSecretInfoByID(id string) (map[string]SecretInfo, error)
- func GetSecretInfoByLabel(label string) (map[string]SecretInfo, error)
- func GetState(key string) (string, error)
- func GetUnitPrivateAddress() (string, error)
- func GetUnitPublicAddress() (string, error)
- func GetUnitRelationData(id string, unitID string) (map[string]string, error)
- func GrantSecretToRelation(id string, relation string) error
- func GrantSecretToUnit(id string, relation string, unit string) error
- func IsLeader() (bool, error)
- func ListRelationUnits(id string) ([]string, error)
- func ListStorage(name string) ([]string, error)
- func LogDebugf(format string, args ...any)
- func LogErrorf(format string, args ...any)
- func LogInfof(format string, args ...any)
- func LogWarningf(format string, args ...any)
- func OpenPort(port int, protocol Protocol) error
- func Reboot(now bool) error
- func RemoveSecret(id string) error
- func RevokeSecret(id string) error
- func RevokeSecretFromApp(id string, app string) error
- func RevokeSecretFromRelation(id string, relation string) error
- func RevokeSecretFromUnit(id string, unit string) error
- func SetActionResults(results map[string]string) error
- func SetAppRelationData(id string, data map[string]string) error
- func SetAppStatus(status StatusName, message ...string) error
- func SetAppVersion(version string) error
- func SetCommandRunner(runner CommandRunner)
- func SetEnvGetter(envGetter EnvironmentGetter)
- func SetPebbleGetter(getter PebbleGetter)
- func SetPorts(ports []*Port) error
- func SetSecret(opts *SetSecretOptions) error
- func SetState(key string, value string) error
- func SetUnitRelationData(id string, data map[string]string) error
- func SetUnitStatus(status StatusName, message ...string) error
- type AddSecretOptions
- type Address
- type AppStatus
- type BindAddress
- type CommandRunner
- type Container
- type Environment
- type EnvironmentGetter
- type GoalState
- type GoalStateStatusContents
- type Integration
- type JujuEnvironment
- type Level
- type Metadata
- type Mount
- type Network
- type PebbleClient
- type PebbleExecProcess
- type PebbleGetter
- type Port
- type Protocol
- type RelationModel
- type Resource
- type SecretInfo
- type SecretOwner
- type SecretRotate
- type SetSecretOptions
- type StatusName
- type Storage
- type StorageInfo
- type UnitStatus
- type UnitsGoalStateContents
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActionLogf ¶ added in v0.0.19
ActionLogf records a progress message for the current action. This functionality only works when the charm is running in an action hook.
func AddSecret ¶ added in v0.0.13
func AddSecret(opts *AddSecretOptions) (string, error)
AddSecret adds a new secret with the provided options.
func AddStorage ¶ added in v0.0.13
AddStorage adds a storage instance to the unit.
func ClosePort ¶ added in v0.0.13
ClosePort registers a request to close the specified port. The port must be between 0 and 65535, and the protocol must be one of tcp, udp, or icmp. If the protocol is icmp, the port argument is ignored.
func DeleteState ¶ added in v0.0.13
DeleteState deletes a state key.
func FailActionf ¶ added in v0.0.13
FailActionf fails the current action with a formatted message. This functionality only works when the charm is running in an action hook.
func GetActionParams ¶ added in v0.0.19
GetActionParams retrieves the parameters for the current action and unmarshals them into the provided params struct. This functionality only works when the charm is running in an action hook.
func GetAppRelationData ¶ added in v0.0.13
GetUnitRelationData retrieves the relation data for a specific app in a relation by its ID. unitID can either be: - The remote unit ID which can be retrieved via goops.ListRelationUnits() - The local unit ID which you can retrieve via goops.ReadEnv()
func GetConfig ¶ added in v0.0.13
GetConfig retrieves the Juju configuration options and unmarshals them into the provided config struct.
func GetCredential ¶ added in v0.0.13
GetCredential retrieves cloud credentials.
func GetRelationApp ¶ added in v0.0.14
GetRelationApp retrieves the remote application name for a relation by its ID.
func GetRelationIDs ¶ added in v0.0.13
GetRelationIDs retrieves the IDs of all relations for a given endpoint. The output is useful as input to: - ListRelationUnits - GetAppRelationData - GetUnitRelationData - SetUnitRelationData - SetAppRelationData - GetRelationModel
func GetRelationModelUUID ¶ added in v0.0.22
GetRelationModel retrieves the relation model UUID for a relation by its ID.
func GetResource ¶ added in v0.0.13
GetResource retrieves the local path to a resource file for the given resource name.
func GetSecretByID ¶ added in v0.0.13
GetSecretByID retrieves the secret content by its ID.
func GetSecretByLabel ¶ added in v0.0.13
GetSecretByLabel retrieves the secret content by its label.
func GetSecretIDs ¶ added in v0.0.13
GetSecretIDs retrieves the IDs for secrets owned by the application.
func GetSecretInfoByID ¶ added in v0.0.13
func GetSecretInfoByID(id string) (map[string]SecretInfo, error)
GetSecretInfoByID retrieves a secret metadata info by its ID.
func GetSecretInfoByLabel ¶ added in v0.0.13
func GetSecretInfoByLabel(label string) (map[string]SecretInfo, error)
GetSecretInfoByLabel retrieves a secret metadata info by its label.
func GetUnitPrivateAddress ¶ added in v0.0.13
GetUnitPrivateAddress returns the private IP address of the unit.
func GetUnitPublicAddress ¶ added in v0.0.13
GetUnitName returns the public IP address of the unit.
func GetUnitRelationData ¶ added in v0.0.13
GetUnitRelationData retrieves the relation data for a specific unit in a relation by its ID. unitID can either be: - The remote unit ID which can be retrieved via goops.ListRelationUnits() - The local unit ID which you can retrieve via goops.ReadEnv()
func GrantSecretToRelation ¶ added in v0.0.13
GrantSecretToRelation grants a secret to a specific relation. All units of the related application are granted access
func GrantSecretToUnit ¶ added in v0.0.13
GrantSecretToUnit grants a secret to a specific unit in a relation.
func ListRelationUnits ¶ added in v0.0.14
ListRelationUnits lists all remote units in a relation by its ID.
func ListStorage ¶ added in v0.0.13
ListStorage lists all storage IDs for a given storage name.
func LogDebugf ¶ added in v0.0.13
LogDebugf logs a debug message. Log messages can be read using `juju debug-log`.
func LogErrorf ¶ added in v0.0.13
LogErrorf logs an error message. Log messages can be read using `juju debug-log`.
func LogInfof ¶ added in v0.0.13
LogInfof logs an informational message. Log messages can be read using `juju debug-log`.
func LogWarningf ¶ added in v0.0.13
LogWarningf logs a warning message. Log messages can be read using `juju debug-log`.
func OpenPort ¶ added in v0.0.13
OpenPort registers a request to open the specified port. The port must be between 0 and 65535, and the protocol must be one of tcp, udp, or icmp. If the protocol is icmp, the port argument is ignored.
func Reboot ¶ added in v0.0.13
Reboot causes the host machine to reboot, after stopping all containers hosted on the machine.
func RemoveSecret ¶ added in v0.0.13
RemoveSecret removes a secret by its ID.
func RevokeSecret ¶ added in v0.0.13
RevokeSecret revokes a secret by its ID.
func RevokeSecretFromApp ¶ added in v0.0.13
RevokeSecretFromApp revokes a secret from a specific application.
func RevokeSecretFromRelation ¶ added in v0.0.13
RevokeSecretFromRelation revokes a secret from a specific relation.
func RevokeSecretFromUnit ¶ added in v0.0.13
RevokeSecretFromApp revokes a secret from a specific application.
func SetActionResults ¶ added in v0.0.13
SetActionResults sets action results. This functionality only works when the charm is running in an action hook.
func SetAppRelationData ¶ added in v0.0.13
SetAppRelationData sets the local application relation data in a relation by its ID.
func SetAppStatus ¶ added in v0.0.14
func SetAppStatus(status StatusName, message ...string) error
SetAppStatus sets the application status. Only the leader unit can set the application status.
func SetAppVersion ¶ added in v0.0.19
SetAppVersion sets the application version. The version set will be displayed in “juju status” output for the application.
func SetCommandRunner ¶ added in v0.0.19
func SetCommandRunner(runner CommandRunner)
func SetEnvGetter ¶ added in v0.0.19
func SetEnvGetter(envGetter EnvironmentGetter)
func SetPebbleGetter ¶ added in v0.0.20
func SetPebbleGetter(getter PebbleGetter)
func SetPorts ¶ added in v0.0.13
SetPorts sets the desired ports for the unit. It opens ports that are desired but not currently opened, and closes ports that are currently opened but not desired.
func SetSecret ¶ added in v0.0.19
func SetSecret(opts *SetSecretOptions) error
SetSecret updates an existing secret with new content and options.
func SetUnitRelationData ¶ added in v0.0.13
SetUnitRelationData sets the local unit relation data in a relation by its ID.
func SetUnitStatus ¶ added in v0.0.13
func SetUnitStatus(status StatusName, message ...string) error
SetUnitStatus sets the unit status.
Types ¶
type AddSecretOptions ¶ added in v0.0.13
type AddSecretOptions struct { Content map[string]string Description string Expire time.Time Label string Owner SecretOwner Rotate SecretRotate }
type AppStatus ¶ added in v0.0.22
type AppStatus struct { Name StatusName `json:"status"` Message string `json:"message"` Units map[string]UnitStatus `json:"units"` }
func GetAppStatus ¶ added in v0.0.19
GetAppStatus returns the application status information. Only the leader unit can retrieve the application status.
type BindAddress ¶ added in v0.0.13
type CommandRunner ¶ added in v0.0.13
CommandRunner is an interface for running commands. It allows for mocking in tests.
func GetCommandRunner ¶ added in v0.0.19
func GetCommandRunner() CommandRunner
type Environment ¶ added in v0.0.13
type Environment struct { ActionName string AgentSocketAddress string AgentSocketNetwork string APIAddresses string AvailabilityZone string CharmDir string CharmFTPProxy string CharmHTTPProxy string CharmHTTPSProxy string CharmNoProxy string CloudAPIVersion string ContextID string HookName string MachineID string ModelName string ModelUUID string Path string PrincipalUnit string UnitName string Version string }
func ReadEnv ¶ added in v0.0.13
func ReadEnv() Environment
ReadEnv reads the Juju related environment variables and returns an Environment struct
type EnvironmentGetter ¶ added in v0.0.13
func GetEnvGetter ¶ added in v0.0.19
func GetEnvGetter() EnvironmentGetter
type GoalState ¶ added in v0.0.13
type GoalState struct { Units UnitsGoalStateContents `json:"units"` Relations map[string]UnitsGoalStateContents `json:"relations"` }
func GetGoalState ¶ added in v0.0.13
GetGoalState retrieves the status of the charm's peers and related units.
type GoalStateStatusContents ¶ added in v0.0.22
type GoalStateStatusContents struct { Status StatusName `json:"status"` Since string `json:"since,omitempty"` }
type Integration ¶ added in v0.0.13
type Integration struct {
Interface string `yaml:"interface"`
}
type JujuEnvironment ¶ added in v0.0.13
type JujuEnvironment struct {
Getter EnvironmentGetter
}
type Metadata ¶ added in v0.0.13
type Metadata struct { Containers map[string]Container `yaml:"containers"` Description string `yaml:"description"` Name string `yaml:"name"` Provides map[string]Integration `yaml:"provides"` Resources map[string]Resource `yaml:"resources"` Storage map[string]Storage `yaml:"storage"` Summary string `yaml:"summary"` }
func ReadMetadata ¶ added in v0.0.13
ReadMetadata reads the metadata.yaml file from the charm directory and unmarshals it into a Metadata struct.
type Network ¶ added in v0.0.13
type Network struct { BindAddresses []BindAddress `json:"bind-addresses"` IngressAddresses []string `json:"ingress-addresses"` EgressSubnets []string `json:"egress-subnets"` }
func GetNetwork ¶ added in v0.0.13
GetNetwork retrieves the network configuration for a given binding name.
type PebbleClient ¶ added in v0.0.20
type PebbleClient interface { Stop(opts *client.ServiceOptions) (changeID string, err error) WaitChange(changeID string, options *client.WaitChangeOptions) (*client.Change, error) Exec(opts *client.ExecOptions) (PebbleExecProcess, error) SysInfo() (*client.SysInfo, error) Push(opts *client.PushOptions) error Pull(opts *client.PullOptions) error AddLayer(opts *client.AddLayerOptions) error Restart(opts *client.ServiceOptions) (changeID string, err error) Start(opts *client.ServiceOptions) (changeID string, err error) Replan(opts *client.ServiceOptions) (changeID string, err error) Services(opts *client.ServicesOptions) ([]*client.ServiceInfo, error) PlanBytes(_ *client.PlanOptions) (data []byte, err error) }
func Pebble ¶ added in v0.0.20
func Pebble(container string) PebbleClient
Pebble returns a PebbleClient for the specified container.
type PebbleExecProcess ¶ added in v0.0.20
type PebbleGetter ¶ added in v0.0.20
type PebbleGetter interface {
Pebble(container string) PebbleClient
}
type Port ¶ added in v0.0.13
func OpenedPorts ¶ added in v0.0.13
List all ports opened by the unit.
type RelationModel ¶ added in v0.0.13
type RelationModel struct {
UUID string `json:"uuid"`
}
type SecretInfo ¶ added in v0.0.13
type SecretOwner ¶ added in v0.0.22
type SecretOwner string
const ( OwnerApplication SecretOwner = "application" OwnerUnit SecretOwner = "unit" )
type SecretRotate ¶ added in v0.0.19
type SecretRotate string
const ( RotateHourly SecretRotate = "hourly" RotateDaily SecretRotate = "daily" RotateMonthly SecretRotate = "monthly" RotateNever SecretRotate = "never" )
type SetSecretOptions ¶ added in v0.0.13
type SetSecretOptions struct { ID string Content map[string]string Description string Expire time.Time Label string Owner SecretOwner Rotate SecretRotate }
type StatusName ¶ added in v0.0.22
type StatusName string
const ( StatusActive StatusName = "active" StatusBlocked StatusName = "blocked" StatusWaiting StatusName = "waiting" StatusMaintenance StatusName = "maintenance" StatusUnknown StatusName = "unknown" )
type StorageInfo ¶ added in v0.0.22
func GetStorageByID ¶ added in v0.0.13
func GetStorageByID(id string) (*StorageInfo, error)
GetStorageByID retrieves storage information by its ID.
type UnitStatus ¶ added in v0.0.13
type UnitStatus struct { Name StatusName `json:"status"` Message string `json:"message"` }
func GetUnitStatus ¶ added in v0.0.19
func GetUnitStatus() (*UnitStatus, error)
GetUnitStatus returns the unit status information.
type UnitsGoalStateContents ¶ added in v0.0.22
type UnitsGoalStateContents map[string]GoalStateStatusContents