cloudaccess

package
v2.25.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: GPL-3.0 Imports: 27 Imported by: 0

Documentation

Overview

Package cloudaccess serves the calls Dagu Cloud carries to this server over a relay connection the server opens, within the role the server's administrator allows.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConfigured means configuration fixes the setting.
	ErrConfigured = errors.New("configuration sets this, so it cannot be changed here")
	// ErrUnknownLevel means a level other than off, viewer, operator, or
	// developer.
	ErrUnknownLevel = errors.New("unknown remote access level")
)

Functions

This section is empty.

Types

type Config

type Config struct {
	// Credentials returns the server's Dagu Cloud credentials, and false
	// while it is not connected.
	Credentials func() (license.CloudCredentials, bool)
	Settings    *Settings
	// Key verifies the assertions Dagu Cloud signs for calls.
	Key ed25519.PublicKey
	// HTTPClient reaches Dagu Cloud; nil means a client with a 30-second
	// timeout.
	HTTPClient *http.Client
	// Hello introduces the server to the relay; the service names its
	// process.
	Hello cloudrelay.Hello
}

Config is what the service works with.

type Service

type Service struct {
	*Settings
	// contains filtered or unexported fields
}

Service holds this process's relay connection for calls from Dagu Cloud while the server is connected to Dagu Cloud and remote access is on, as its Settings decide.

func New

func New(cfg Config) *Service

New creates a Service.

func (*Service) Run

func (s *Service) Run(ctx context.Context, mcp http.Handler)

Run holds the connection until ctx is done, and serves with mcp each call whose assertion holds, as the user it names. Turning remote access off closes the connection, which cancels the calls in flight.

func (*Service) State

func (s *Service) State() State

State returns how the connection stands.

type Settings

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

Settings decides how far calls from Dagu Cloud may go on this server: as configuration fixes, or else as an administrator chooses. Remote access stays off and approvals stay refused until either says otherwise.

func NewSettings

func NewSettings(cloud config.CloudConfig, store StateStore) *Settings

NewSettings returns the remote access settings of a server: those cloud configures, and the choices store keeps for the rest.

func (*Settings) Set

func (s *Settings) Set(ctx context.Context, level *config.RemoteAccessLevel, approvals *bool) error

Set chooses the highest role calls get, whether they may decide steps waiting for a person, or both, in one change; nil leaves either as it is. It fails, changing nothing, with ErrConfigured when configuration fixes a setting it was given, and with ErrUnknownLevel for an unknown level.

func (*Settings) Status

func (s *Settings) Status(ctx context.Context) (Status, error)

Status returns the settings in effect.

type State

type State struct {
	// Connected means calls from Dagu Cloud reach this process.
	Connected bool
	// Error says why the last connection failed or was refused.
	Error string
}

State is how this process's connection for calls stands.

type StateStore

type StateStore interface {
	Load(ctx context.Context) (data []byte, found bool, err error)
	Save(ctx context.Context, data []byte) error
}

StateStore keeps the choices an administrator made.

type Status

type Status struct {
	// Level is the highest role a call gets.
	Level config.RemoteAccessLevel
	// LevelConfigured means configuration fixes Level.
	LevelConfigured bool
	// Approvals lets calls decide steps waiting for a person.
	Approvals bool
	// ApprovalsConfigured means configuration fixes Approvals.
	ApprovalsConfigured bool
}

Status is how far calls from Dagu Cloud may go, and how it was decided.

Jump to

Keyboard shortcuts

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