common

package
v0.0.0-...-2c36c94 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2025 License: AGPL-3.0 Imports: 51 Imported by: 622

Documentation

Overview

Package common is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CloudSpecToParams

func CloudSpecToParams(spec environscloudspec.CloudSpec) *params.CloudSpec

CloudSpecToParams constructs a params cloud spec from a cloud spec.

func ControllerAPIInfo

func ControllerAPIInfo(
	ctx context.Context,
	controllerConfigService ControllerConfigService,
	apiHostPortsGetter APIHostPortsForAgentsGetter,
) ([]string, string, error)

ControllerAPIInfo returns the local controller details for the given State.

func EntityStatusFromState

func EntityStatusFromState(statusInfo status.StatusInfo) params.EntityStatus

EntityStatusFromState converts a state.StatusInfo into a params.EntityStatus.

func HasPermission

func HasPermission(
	ctx context.Context,
	accessGetter UserAccessFunc,
	utag names.Tag,
	requestedPermission permission.Access,
	target names.Tag,
) (bool, error)

HasPermission returns true if the specified user has the specified permission on target.

func JujuClientVersionFromRequest

func JujuClientVersionFromRequest(req *http.Request) (semversion.Number, error)

JujuClientVersionFromRequest returns the Juju client version number from the HTTP request.

func MaxWait

func MaxWait(in *time.Duration) time.Duration

MaxWait is how far in the future the backstop force cleanup will be scheduled. Default is 1min if no value is provided.

func NewToolsFinder

func NewToolsFinder(
	urlGetter ToolsURLGetter,
	store objectstore.ObjectStore,
	agentBinaryService AgentBinaryService,
) *toolsFinder

NewToolsFinder returns a new ToolsFinder, returning tools with their URLs pointing at the API server.

func NewToolsURLGetter

func NewToolsURLGetter(modelUUID string, a APIHostPortsForAgentsGetter) *toolsURLGetter

NewToolsURLGetter creates a new ToolsURLGetter that returns tools URLs pointing at an API server.

func ToolsURL

func ToolsURL(serverRoot string, v string) string

ToolsURL returns a tools URL pointing the API server specified by the "serverRoot".

Types

type APIAddressAccessor

type APIAddressAccessor interface {
	// GetAPIHostPortsForAgents returns API HostPorts that are available for
	// agents. HostPorts are grouped by controller node, though each specific
	// controller is not identified.
	GetAPIHostPortsForAgents(ctx context.Context) ([]network.HostPorts, error)

	// GetAllAPIAddressesForAgents returns a string of api
	// addresses available for agents ordered to prefer local-cloud scoped
	// addresses and IPv4 over IPv6 for each machine.
	GetAllAPIAddressesForAgents(ctx context.Context) ([]string, error)

	// WatchControllerAPIAddresses returns a watcher that observes changes to the
	// controller ip addresses.
	WatchControllerAPIAddresses(context.Context) (watcher.NotifyWatcher, error)
}

APIAddressAccessor describes methods that allow agents to maintain up-to-date information on how to connect to the Juju API server.

type APIAddresser

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

APIAddresser implements the APIAddresses method. Note that the apiAddressAccessor backing for this implies that it is suitable for use by agents, which are bound by the configured controller management space. It is not suitable for callers requiring *all* available API addresses.

func NewAPIAddresser

func NewAPIAddresser(getter APIAddressAccessor, watcherRegistry facade.WatcherRegistry) *APIAddresser

NewAPIAddresser returns a new APIAddresser that uses the given apiAddressAccessor to fetch its addresses.

func (*APIAddresser) APIAddresses

func (a *APIAddresser) APIAddresses(ctx context.Context) (params.StringsResult, error)

APIAddresses returns the list of addresses used to connect to the API.

func (*APIAddresser) APIHostPorts

func (a *APIAddresser) APIHostPorts(ctx context.Context) (params.APIHostPortsResult, error)

APIHostPorts returns the API server addresses.

func (*APIAddresser) WatchAPIHostPorts

func (a *APIAddresser) WatchAPIHostPorts(ctx context.Context) (params.NotifyWatchResult, error)

WatchAPIHostPorts watches the API server addresses.

type APIHostPortsForAgentsGetter

type APIHostPortsForAgentsGetter interface {
	// GetAllAPIAddressesForAgents returns a string of api
	// addresses available for agents ordered to prefer local-cloud scoped
	// addresses and IPv4 over IPv6 for each machine.
	GetAllAPIAddressesForAgents(ctx context.Context) ([]string, error)
}

APIHostPortsForAgentsGetter represents a way to get controller api addresses.

type AgentBinaryService

type AgentBinaryService interface {
	// GetEnvironAgentBinariesFinder returns the function to find agent binaries.
	// This is used to find the agent binaries.
	GetEnvironAgentBinariesFinder() agentbinaryservice.EnvironAgentBinariesFinderFunc

	// ListAgentBinaries lists all agent binaries in the controller and model stores.
	// It merges the two lists of agent binaries, with the model agent binaries
	// taking precedence over the controller agent binaries.
	// It returns a slice of agent binary metadata. The order of the metadata is not guaranteed.
	// An empty slice is returned if no agent binaries are found.
	ListAgentBinaries(ctx context.Context) ([]agentbinary.Metadata, error)
}

AgentBinaryService is an interface for getting the EnvironAgentBinariesFinder function.

type AgentPasswordService

type AgentPasswordService interface {
	// SetUnitPassword sets the password hash for the given unit.
	SetUnitPassword(context.Context, coreunit.Name, string) error

	// SetMachinePassword sets the password hash for the given machine.
	SetMachinePassword(context.Context, coremachine.Name, string) error

	// SetModelPassword sets the password for the model overriding any previously
	// set value.
	SetModelPassword(ctx context.Context, password string) error

	// SetControllerNodePassword sets the password hash for the given
	// controller node.
	SetControllerNodePassword(context.Context, string, string) error

	// IsMachineController returns whether the machine is a controller machine.
	// It returns a NotFound if the given machine doesn't exist.
	IsMachineController(ctx context.Context, machineName coremachine.Name) (bool, error)
}

AgentPasswordService defines the methods required to set an agent password hash.

type ApplicationService

type ApplicationService interface {
	GetUnitLife(ctx context.Context, name unit.Name) (life.Value, error)
	// GetApplicationLifeByName looks up the life of the specified application, returning
	// an error satisfying [applicationerrors.ApplicationNotFoundError] if the
	// application is not found.
	GetApplicationLifeByName(ctx context.Context, appName string) (life.Value, error)
}

ApplicationService defines the methods required to get the life of a unit.

type AuthFunc

type AuthFunc func(tag names.Tag) bool

AuthFunc returns whether the given entity is available to some operation.

type Authorizer

type Authorizer interface {

	// AuthController returns whether the authenticated entity is
	// a machine acting as a controller. Can't be removed from this
	// interface without introducing a dependency on something else
	// to look up that property: it's not inherent in the result of
	// GetAuthTag, as the other methods all are.
	AuthController() bool

	// AuthMachineAgent returns true if the entity is a machine agent.
	AuthMachineAgent() bool

	// GetAuthTag returns the entity's tag.
	GetAuthTag() names.Tag
}

Authorizer represents the authenticated entity using the API server.

type BlockChecker

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

BlockChecker checks for current blocks if any.

func NewBlockChecker

func NewBlockChecker(s BlockCommandService) *BlockChecker

NewBlockChecker returns a new BlockChecker.

func (*BlockChecker) ChangeAllowed

func (c *BlockChecker) ChangeAllowed(ctx context.Context) error

ChangeAllowed checks if change block is in place. Change block prevents all operations that may change current model in any way from running successfully.

func (*BlockChecker) DestroyAllowed

func (c *BlockChecker) DestroyAllowed(ctx context.Context) error

DestroyAllowed checks if destroy block is in place. Destroy block prevents destruction of current model.

func (*BlockChecker) RemoveAllowed

func (c *BlockChecker) RemoveAllowed(ctx context.Context) error

RemoveAllowed checks if remove block is in place. Remove block prevents removal of machine, service, unit and relation from current model.

type BlockCheckerGetter

type BlockCheckerGetter func(ctx context.Context) (*BlockChecker, error)

BlockCheckerGetter provides a signature of a function that can be used to late defer getting a BlockChecker. This allows block checkers to be made based on the context of the caller.

type BlockCheckerInterface

type BlockCheckerInterface interface {
	// ChangeAllowed checks if change block is in place.
	ChangeAllowed(context.Context) error
	// RemoveAllowed checks if remove block is in place.
	RemoveAllowed(context.Context) error
	// DestroyAllowed checks if destroy block is in place.
	DestroyAllowed(context.Context) error
}

BlockCheckerInterface defines methods of BlockChecker.

type BlockCommandService

type BlockCommandService interface {
	// GetBlockSwitchedOn returns the optional block message if it is switched
	// on for the given type.
	GetBlockSwitchedOn(ctx context.Context, t blockcommand.BlockType) (string, error)

	// GetBlocks returns all the blocks that are currently in place.
	GetBlocks(ctx context.Context) ([]blockcommand.Block, error)
}

BlockCommandService defines methods for interacting with block commands.

type CloudService

type CloudService interface {
	// Cloud returns the named cloud.
	Cloud(ctx context.Context, name string) (*cloud.Cloud, error)
}

CloudService provides access to clouds.

type ControllerConfigAPI

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

ControllerConfigAPI implements two common methods for use by various facades - eg Provisioner and ControllerConfig.

func NewControllerConfigAPI

func NewControllerConfigAPI(
	controllerConfigService ControllerConfigService,
	apiHostPortsForAgentsGetter APIHostPortsForAgentsGetter,
	externalControllerService ExternalControllerService,
	modelService ModelService,
) *ControllerConfigAPI

NewControllerConfigAPI returns a new ControllerConfigAPI.

func (*ControllerConfigAPI) ControllerAPIInfoForModels

func (s *ControllerConfigAPI) ControllerAPIInfoForModels(ctx context.Context, args params.Entities) (params.ControllerAPIInfoResults, error)

ControllerAPIInfoForModels returns the controller api connection details for the specified models.

func (*ControllerConfigAPI) ControllerConfig

ControllerConfig returns the controller's configuration.

type ControllerConfigService

type ControllerConfigService interface {
	ControllerConfig(context.Context) (controller.Config, error)
}

ControllerConfigService is an interface that provides the controller configuration for the model.

type ExternalControllerService

type ExternalControllerService interface {
	// ControllerForModel returns the controller record that's associated
	// with the modelUUID.
	ControllerForModel(ctx context.Context, modelUUID string) (*crossmodel.ControllerInfo, error)

	// UpdateExternalController persists the input controller
	// record.
	UpdateExternalController(ctx context.Context, ec crossmodel.ControllerInfo) error
}

ExternalControllerService defines the methods that the controller facade needs from the controller state.

type FindAgentsParams

type FindAgentsParams struct {
	// ControllerCfg is the controller config.
	ControllerCfg controller.Config

	// ModelType is the type of the model.
	ModelType coremodel.ModelType

	// Number will be used to match tools versions exactly if non-zero.
	Number semversion.Number

	// MajorVersion will be used to match the major version if non-zero.
	MajorVersion int

	// MinorVersion will be used to match the minor version if non-zero.
	MinorVersion int

	// Arch will be used to match tools by architecture if non-empty.
	Arch string

	// OSType will be used to match tools by os type if non-empty.
	OSType string

	// AgentStream will be used to set agent stream to search
	AgentStream string
}

FindAgentsParams defines parameters for the FindAgents method.

type GetAuthFunc

type GetAuthFunc func(ctx context.Context) (AuthFunc, error)

GetAuthFunc returns an AuthFunc.

func AuthAlways

func AuthAlways() GetAuthFunc

AuthAlways returns an authentication function that always returns true iff it is passed a valid tag.

func AuthAny

func AuthAny(getFuncs ...GetAuthFunc) GetAuthFunc

AuthAny returns an AuthFunc generator that returns an AuthFunc that accepts any tag authorized by any of its arguments. If no arguments are passed this is equivalent to AuthNever.

func AuthFuncForMachineAgent

func AuthFuncForMachineAgent(authorizer Authorizer) GetAuthFunc

AuthFuncForMachineAgent returns a GetAuthFunc which creates an AuthFunc allowing only machine agents and their controllers

func AuthFuncForTag

func AuthFuncForTag(valid names.Tag) GetAuthFunc

AuthFuncForTag returns an authentication function that always returns true iff it is passed a specific tag.

func AuthFuncForTagKind

func AuthFuncForTagKind(kind string) GetAuthFunc

AuthFuncForTagKind returns a GetAuthFunc which creates an AuthFunc allowing only the given tag kind and denies all others. Passing an empty kind is an error.

type GetMachineUUID

type GetMachineUUID func(context.Context) (coremachine.UUID, error)

GetMachineUUID represents a function type that takes a context.Context as input and returns a string representation of the machine UUID and an error. It allows to smuggle machine identification to the watcher, because retrieving the machine UUID implies a machine service calls which requires a context.

type InstanceIdGetter

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

InstanceIdGetter implements a common InstanceId method for use by various facades.

func NewInstanceIdGetter

func NewInstanceIdGetter(machineService MachineService, getCanRead GetAuthFunc) *InstanceIdGetter

NewInstanceIdGetter returns a new InstanceIdGetter. The GetAuthFunc will be used on each invocation of InstanceId to determine current permissions.

func (*InstanceIdGetter) InstanceId

InstanceId returns the provider specific instance id for each given machine or an CodeNotProvisioned error, if not set.

type LifeGetter

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

LifeGetter implements a common Life method for use by various facades.

func NewLifeGetter

func NewLifeGetter(
	applicationService ApplicationService,
	machineService MachineService,
	getCanRead GetAuthFunc,
	logger corelogger.Logger,
) *LifeGetter

NewLifeGetter returns a new LifeGetter. The GetAuthFunc will be used on each invocation of Life to determine current permissions.

func (*LifeGetter) Life

Life returns the life status of every supplied entity, where available.

func (*LifeGetter) OneLife

func (lg *LifeGetter) OneLife(ctx context.Context, tag names.Tag) (life.Value, error)

OneLife returns the life of the specified entity.

type MachineRebootService

type MachineRebootService interface {
	// RequireMachineReboot sets the machine referenced by its UUID as requiring a reboot.
	RequireMachineReboot(ctx context.Context, uuid machine.UUID) error

	// ClearMachineReboot removes the reboot flag of the machine referenced by its UUID if a reboot has previously been required.
	ClearMachineReboot(ctx context.Context, uuid machine.UUID) error

	// IsMachineRebootRequired checks if the machine referenced by its UUID requires a reboot.
	IsMachineRebootRequired(ctx context.Context, uuid machine.UUID) (bool, error)

	// ShouldRebootOrShutdown determines whether a machine should reboot or shutdown
	ShouldRebootOrShutdown(ctx context.Context, uuid machine.UUID) (machine.RebootAction, error)

	// GetMachineUUID returns the UUID of a machine identified by its name.
	// It returns an errors.MachineNotFound if the machine does not exist.
	GetMachineUUID(ctx context.Context, machineName machine.Name) (machine.UUID, error)
}

MachineRebootService is an interface that defines methods for managing machine reboots.

type MachineService

type MachineService interface {
	// GetMachineUUID returns the UUID of a machine identified by its name.
	GetMachineUUID(ctx context.Context, name machine.Name) (machine.UUID, error)
	// GetInstanceID returns the cloud specific instance id for this machine.
	GetInstanceID(ctx context.Context, mUUID machine.UUID) (instance.Id, error)
	// GetMachineLife returns the lifecycle of the machine.
	GetMachineLife(ctx context.Context, name machine.Name) (life.Value, error)
}

MachineService defines the methods that the facade assumes from the Machine service.

type MachineWatcher

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

MachineWatcher is a struct that represents a watcher for various events produced by a specific machine. It uses the WatchableMachineService interface to watch for changes and the facade.WatcherRegistry interface to register and unregister watchers. The GetMachineUUID type is a function that returns the UUID of the machine.

func NewMachineRebootWatcher

func NewMachineRebootWatcher(service WatchableMachineService, watcherRegistry facade.WatcherRegistry, uuid GetMachineUUID) *MachineWatcher

NewMachineRebootWatcher creates a new MachineWatcher instance with the given dependencies. It takes a WatchableMachineService, a facade.WatcherRegistry, and a GetMachineUUID function as input. The returned MachineWatcher instance tracks changes in the machine domain and registers/unregisters watchers for a specific machine UUID.

func (*MachineWatcher) WatchForRebootEvent

func (mrw *MachineWatcher) WatchForRebootEvent(ctx context.Context) (params.NotifyWatchResult, error)

WatchForRebootEvent starts a watcher to track if there is a new reboot request for a specific machine ID or its parent (in case we are a container).

type MockAPIAddressAccessor

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

MockAPIAddressAccessor is a mock of APIAddressAccessor interface.

func NewMockAPIAddressAccessor

func NewMockAPIAddressAccessor(ctrl *gomock.Controller) *MockAPIAddressAccessor

NewMockAPIAddressAccessor creates a new mock instance.

func (*MockAPIAddressAccessor) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockAPIAddressAccessor) GetAPIHostPortsForAgents

func (m *MockAPIAddressAccessor) GetAPIHostPortsForAgents(arg0 context.Context) ([]network.HostPorts, error)

GetAPIHostPortsForAgents mocks base method.

func (*MockAPIAddressAccessor) GetAllAPIAddressesForAgents

func (m *MockAPIAddressAccessor) GetAllAPIAddressesForAgents(arg0 context.Context) ([]string, error)

GetAllAPIAddressesForAgents mocks base method.

func (*MockAPIAddressAccessor) WatchControllerAPIAddresses

func (m *MockAPIAddressAccessor) WatchControllerAPIAddresses(arg0 context.Context) (watcher.Watcher[struct{}], error)

WatchControllerAPIAddresses mocks base method.

type MockAPIAddressAccessorGetAPIHostPortsForAgentsCall

type MockAPIAddressAccessorGetAPIHostPortsForAgentsCall struct {
	*gomock.Call
}

MockAPIAddressAccessorGetAPIHostPortsForAgentsCall wrap *gomock.Call

func (*MockAPIAddressAccessorGetAPIHostPortsForAgentsCall) Do

Do rewrite *gomock.Call.Do

func (*MockAPIAddressAccessorGetAPIHostPortsForAgentsCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockAPIAddressAccessorGetAPIHostPortsForAgentsCall) Return

Return rewrite *gomock.Call.Return

type MockAPIAddressAccessorGetAllAPIAddressesForAgentsCall

type MockAPIAddressAccessorGetAllAPIAddressesForAgentsCall struct {
	*gomock.Call
}

MockAPIAddressAccessorGetAllAPIAddressesForAgentsCall wrap *gomock.Call

func (*MockAPIAddressAccessorGetAllAPIAddressesForAgentsCall) Do

Do rewrite *gomock.Call.Do

func (*MockAPIAddressAccessorGetAllAPIAddressesForAgentsCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockAPIAddressAccessorGetAllAPIAddressesForAgentsCall) Return

Return rewrite *gomock.Call.Return

type MockAPIAddressAccessorMockRecorder

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

MockAPIAddressAccessorMockRecorder is the mock recorder for MockAPIAddressAccessor.

func (*MockAPIAddressAccessorMockRecorder) GetAPIHostPortsForAgents

GetAPIHostPortsForAgents indicates an expected call of GetAPIHostPortsForAgents.

func (*MockAPIAddressAccessorMockRecorder) GetAllAPIAddressesForAgents

GetAllAPIAddressesForAgents indicates an expected call of GetAllAPIAddressesForAgents.

func (*MockAPIAddressAccessorMockRecorder) WatchControllerAPIAddresses

WatchControllerAPIAddresses indicates an expected call of WatchControllerAPIAddresses.

type MockAPIAddressAccessorWatchControllerAPIAddressesCall

type MockAPIAddressAccessorWatchControllerAPIAddressesCall struct {
	*gomock.Call
}

MockAPIAddressAccessorWatchControllerAPIAddressesCall wrap *gomock.Call

func (*MockAPIAddressAccessorWatchControllerAPIAddressesCall) Do

Do rewrite *gomock.Call.Do

func (*MockAPIAddressAccessorWatchControllerAPIAddressesCall) DoAndReturn

DoAndReturn rewrite *gomock.Call.DoAndReturn

func (*MockAPIAddressAccessorWatchControllerAPIAddressesCall) Return

Return rewrite *gomock.Call.Return

type ModelAgentService

type ModelAgentService interface {
	// GetModelTargetAgentVersion returns the target agent version for the
	// entire model. The following errors can be returned:
	// - [github.com/juju/juju/domain/model/errors.NotFound] - When the model does
	// not exist.
	GetModelTargetAgentVersion(context.Context) (semversion.Number, error)

	// GetMachineTargetAgentVersion reports the target agent version that should
	// be running on the provided machine identified by name. The following
	// errors are possible:
	// - [github.com/juju/juju/domain/machine/errors.MachineNotFound]
	// - [github.com/juju/juju/domain/model/errors.NotFound]
	GetMachineTargetAgentVersion(context.Context, machine.Name) (coreagentbinary.Version, error)

	// GetUnitTargetAgentVersion reports the target agent version that should be
	// being run on the provided unit identified by name. The following errors
	// are possible:
	// - [github.com/juju/juju/domain/application/errors.UnitNotFound] - When
	// the unit in question does not exist.
	// - [github.com/juju/juju/domain/model/errors.NotFound] - When the model
	// the unit belongs to no longer exists.
	GetUnitTargetAgentVersion(context.Context, unit.Name) (coreagentbinary.Version, error)
}

ModelAgentService provides access to the Juju agent version for the model.

type ModelService

type ModelService interface {
	// CheckModelExists checks if a model exists within the controller. True or
	// false is returned indiciating of the model exists.
	CheckModelExists(ctx context.Context, modelUUID coremodel.UUID) (bool, error)

	// ModelRedirection returns redirection information for the current model. If it
	// is not redirected, [modelmigrationerrors.ModelNotRedirected] is returned.
	ModelRedirection(ctx context.Context, modelUUID coremodel.UUID) (model.ModelRedirection, error)
}

ModelService is an interface that provides information about hosted models.

type PasswordChanger

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

PasswordChanger implements a common SetPasswords method for use by various facades.

func NewPasswordChanger

func NewPasswordChanger(agentPasswordService AgentPasswordService, getCanChange GetAuthFunc) *PasswordChanger

NewPasswordChanger returns a new PasswordChanger. The GetAuthFunc will be used on each invocation of SetPasswords to determine current permissions.

func (*PasswordChanger) SetPasswords

SetPasswords sets the given password for each supplied entity, if possible.

type RebootActionGetter

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

RebootActionGetter implements the GetRebootAction API method

func NewRebootActionGetter

func NewRebootActionGetter(machineService MachineRebootService, auth GetAuthFunc) *RebootActionGetter

func (*RebootActionGetter) GetRebootAction

GetRebootAction returns the action a machine agent should take. If a reboot flag is set on the machine, then that machine is expected to reboot (params.ShouldReboot). a reboot flag set on the machine parent or grandparent, will cause the machine to shutdown (params.ShouldShutdown). If no reboot flag is set, the machine should do nothing (params.ShouldDoNothing).

type RebootFlagClearer

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

RebootFlagClearer implements the ClearReboot API call

func NewRebootFlagClearer

func NewRebootFlagClearer(machineService MachineRebootService, auth GetAuthFunc) *RebootFlagClearer

func (*RebootFlagClearer) ClearReboot

ClearReboot will clear the reboot flag on provided machines, if it exists.

type RebootRequester

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

RebootRequester implements the RequestReboot API method

func NewRebootRequester

func NewRebootRequester(machineService MachineRebootService, auth GetAuthFunc) *RebootRequester

func (*RebootRequester) RequestReboot

func (r *RebootRequester) RequestReboot(ctx context.Context, args params.Entities) (params.ErrorResults, error)

RequestReboot sets the reboot flag on the provided machines

type RelationUnitsWatcher

type RelationUnitsWatcher = watcher.Watcher[params.RelationUnitsChange]

RelationUnitsWatcher represents a relation.RelationUnitsWatcher at the apiserver level (different type for changes).

type StatusService

type StatusService interface {
	// GetUnitWorkloadStatus returns the workload status of the specified unit, returning an
	// error satisfying [statuserrors.UnitNotFound] if the unit doesn't exist.
	GetUnitWorkloadStatus(context.Context, coreunit.Name) (corestatus.StatusInfo, error)

	// SetUnitWorkloadStatus sets the workload status of the specified unit, returning an
	// error satisfying [statuserrors.UnitNotFound] if the unit doesn't exist.
	SetUnitWorkloadStatus(context.Context, coreunit.Name, corestatus.StatusInfo) error
}

type ToolsFinder

type ToolsFinder interface {
	FindAgents(context.Context, FindAgentsParams) (coretools.List, error)
}

ToolsFinder defines methods for finding tools.

type ToolsGetter

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

ToolsGetter implements a common Tools method for use by various facades.

func NewToolsGetter

func NewToolsGetter(
	modelAgentService ModelAgentService,
	urlGetter ToolsURLGetter,
	toolsFinder ToolsFinder,
	getCanRead GetAuthFunc,
) *ToolsGetter

NewToolsGetter returns a new ToolsGetter. The GetAuthFunc will be used on each invocation of Tools to determine current permissions.

func (*ToolsGetter) Tools

Tools finds the tools necessary for the given agents.

type ToolsURLGetter

type ToolsURLGetter interface {
	// ToolsURLs returns URLs for the tools with
	// the specified binary version.
	ToolsURLs(context.Context, semversion.Binary) ([]string, error)
}

ToolsURLGetter is an interface providing the ToolsURL method.

type UnitStateAPI

type UnitStateAPI struct {
	AccessMachine GetAuthFunc
	// contains filtered or unexported fields
}

func NewUnitStateAPI

func NewUnitStateAPI(
	controllerConfigService ControllerConfigService,
	unitStateService UnitStateService,
	accessUnit GetAuthFunc,
	logger corelogger.Logger,
) *UnitStateAPI

NewUnitStateAPI returns a new UnitStateAPI. Currently both GetAuthFuncs can used to determine current permissions.

func (*UnitStateAPI) SetState

SetState sets the state persisted by the charm running in this unit and the state internal to the uniter for this unit.

func (*UnitStateAPI) State

State returns the state persisted by the charm running in this unit and the state internal to the uniter for this unit.

type UnitStateService

type UnitStateService interface {
	// SetState persists the input unit state.
	SetState(context.Context, unitstate.UnitState) error
	// GetState returns the internal state of the unit. The return data will be
	// empty if no hook has been run for this unit.
	GetState(ctx context.Context, name coreunit.Name) (unitstate.RetrievedUnitState, error)
}

UnitStateService describes the ability to retrieve and persist remote state for informing hook reconciliation.

type UnitStatusGetter

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

UnitStatusGetter defines the API used to get the workload status of a unit.

func NewUnitStatusGetter

func NewUnitStatusGetter(statusService StatusService, clock clock.Clock, getCanAccess GetAuthFunc) *UnitStatusGetter

NewUnitStatusGetter returns a new UnitStatusGetter.

func (*UnitStatusGetter) Status

Status returns the workload status of the specified units.

type UnitStatusSetter

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

UnitStatusSetter defines the API used to set the workload status of a unit.

func NewUnitStatusSetter

func NewUnitStatusSetter(statusService StatusService, clock clock.Clock, getCanModify GetAuthFunc) *UnitStatusSetter

NewUnitStatusSetter returns a new UnitStatusSetter.

func (*UnitStatusSetter) SetStatus

SetStatus sets the workload status of the specified units.

type UserAccessFunc

type UserAccessFunc func(ctx context.Context, userName coreuser.Name, target permission.ID) (permission.Access, error)

UserAccessFunc represents a func that can answer the question about what level of access a user has for a given target.

type WatchableMachineService

type WatchableMachineService interface {
	// WatchMachineReboot returns a NotifyWatcher that is subscribed to
	// the changes in the machine_requires_reboot table in the model.
	// It raises an event whenever the machine uuid or its parent is added to the reboot table.
	WatchMachineReboot(ctx context.Context, uuid coremachine.UUID) (watcher.NotifyWatcher, error)
}

WatchableMachineService is an interface that defines the methods related to watching changes in the machine domain

It contains a subset of method from github.com/juju/juju/domain/machine/service.Service, dedicated to watch various machine events.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
mocks
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