controlsocket

package
v0.0.0-...-23dbee4 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package controlsocket defines the controlsocket worker, which exposes a Unix socket that the juju-controller charm can use to affect Juju state.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Manifold

func Manifold(config ManifoldConfig) dependency.Manifold

Manifold returns a Manifold that encapsulates the controlsocket worker.

func NewWorker

func NewWorker(config Config) (worker.Worker, error)

NewWorker returns a controlsocket worker with the given config.

Types

type AccessService

type AccessService interface {
	// AddUser will add a new user to the database and return the UUID of the
	// user if successful. If no password is set in the incoming argument,
	// the user will be added with an activation key.
	// The following error types are possible from this function:
	//   - usererrors.UserNameNotValid: When the username supplied is not valid.
	//   - usererrors.AlreadyExists: If a user with the supplied name already exists.
	//   - usererrors.CreatorUUIDNotFound: If a creator has been supplied for the user
	//     and the creator does not exist.
	//   - auth.ErrPasswordNotValid: If the password supplied is not valid.
	AddUser(ctx context.Context, arg service.AddUserArg) (user.UUID, []byte, error)

	// GetUserByName will find and return the user associated with name. If there is no
	// user for the user name then an error that satisfies usererrors.NotFound will
	// be returned. If supplied with an invalid user name then an error that satisfies
	// usererrors.UserNameNotValid will be returned.
	//
	// GetUserByName will not return users that have been previously removed.
	GetUserByName(ctx context.Context, name user.Name) (user.User, error)

	// GetUserByAuth will find and return the user with UUID. If there is no
	// user for the name and password, then an error that satisfies
	// usererrors.NotFound will be returned. If supplied with an invalid user name
	// then an error that satisfies usererrors.UserNameNotValid will be returned.
	// It will not return users that have been previously removed.
	GetUserByAuth(ctx context.Context, name user.Name, password auth.Password) (user.User, error)

	// RemoveUser marks the user as removed and removes any credentials or
	// activation codes for the current users. Once a user is removed they are no
	// longer usable in Juju and should never be un removed.
	// The following error types are possible from this function:
	// - usererrors.UserNameNotValid: When the username supplied is not valid.
	// - usererrors.NotFound: If no user by the given UUID exists.
	RemoveUser(ctx context.Context, name user.Name) error

	// ReadUserAccessLevelForTarget returns the user access level for the
	// given user on the given target. A NotValid error is returned if the
	// subject (user) string is empty, or the target is not valid. Any errors
	// from the state layer are passed through.
	// If the access level of a user cannot be found then
	// [accesserrors.AccessNotFound] is returned.
	ReadUserAccessLevelForTarget(ctx context.Context, subject user.Name, target permission.ID) (permission.Access, error)
}

AccessService is the interface for the access service.

type Config

type Config struct {
	// AccessService is the user access service for the model.
	AccessService AccessService
	// SocketName is the socket file descriptor.
	SocketName string
	// NewSocketListener is the function that creates a new socket listener.
	NewSocketListener func(socketlistener.Config) (SocketListener, error)
	// Logger is the logger used by the worker.
	Logger logger.Logger
	// ControllerModelUUID is the uuid of the controller model.
	ControllerModelUUID model.UUID
}

Config represents configuration for the controlsocket worker.

func (Config) Validate

func (config Config) Validate() error

Validate returns an error if config cannot drive the Worker.

type ManifoldConfig

type ManifoldConfig struct {
	DomainServicesName string
	Logger             logger.Logger
	NewWorker          func(Config) (worker.Worker, error)
	NewSocketListener  func(socketlistener.Config) (SocketListener, error)
	SocketName         string
}

ManifoldConfig describes the dependencies required by the controlsocket worker.

func (ManifoldConfig) Validate

func (cfg ManifoldConfig) Validate() error

Validate is called by start to check for bad configuration.

type PermissionService

type PermissionService interface {
	// AddUserPermission adds a user to the model with the given access.
	// If the user already has the given access, this is a no-op.
	AddUserPermission(ctx context.Context, username user.Name, access permission.Access) error
}

PermissionService is the interface for the permission service.

type SocketListener

type SocketListener interface {
	worker.Worker
}

SocketListener describes a worker that listens on a unix socket.

func NewSocketListener

func NewSocketListener(config socketlistener.Config) (SocketListener, error)

NewSocketListener is a function that creates a new socket listener.

type Worker

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

Worker is a controlsocket worker.

func (*Worker) Kill

func (w *Worker) Kill()

func (*Worker) Wait

func (w *Worker) Wait() error

Jump to

Keyboard shortcuts

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