execendpoints

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package execendpoints owns the operator-facing CRUD + test of per-agent SSH exec endpoints (declared by the agent via RegisterExecEndpoint, configured by the operator here).

Index

Constants

This section is empty.

Variables

View Source
var ErrKeypairAfterConfigure = errors.New("configured but keypair generation failed")

ErrKeypairAfterConfigure marks the specific 500 condition where the row was written but follow-up keypair gen failed.

Functions

This section is empty.

Types

type ConfigureRequest

type ConfigureRequest struct {
	Host        string
	Port        int32
	SSHUser     string
	DisplayName string
	CreateNew   bool
}

ConfigureRequest is the input for Configure. Port=0 defaults to 22.

type Dialer

type Dialer interface {
	Exec(ctx context.Context, ep *dbq.AgentExecEndpoint, req execproxy.ExecRequest, w http.ResponseWriter) error
	EvictCache(id uuid.UUID)
}

Dialer is the subset of execproxy.SSHDialer the service uses.

type Pool

type Pool interface {
	dbq.DBTX
	Begin(ctx context.Context) (pgx.Tx, error)
}

Pool is the minimal subset of *pgxpool.Pool dbq.New accepts. Kept generic so the constructor matches the existing handler-side pattern.

type Service

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

func New

func New(pool Pool, store secrets.Store, dialer Dialer, logger *zap.Logger) *Service

func (*Service) Configure

func (s *Service) Configure(ctx context.Context, p authz.Principal, agentID uuid.UUID, slug string, req ConfigureRequest) (dbq.AgentExecEndpoint, error)

Configure persists host/port/user for a declared endpoint and generates a keypair on first configure. The exec-endpoint resource is created (owned by the configuring principal) and bound to the agent's need on first configure. ErrInvalidInput for bad input, ErrNotFound when the slug wasn't declared.

func (*Service) List

List returns every exec-endpoint need the agent declares, joined to its bound resource (if configured) — keyed by the agent's need slug.

func (*Service) RotateKeypair

func (s *Service) RotateKeypair(ctx context.Context, p authz.Principal, agentID uuid.UUID, slug string) (dbq.AgentExecEndpoint, error)

RotateKeypair mints a new ED25519 keypair, replaces the secrets-store ref, and evicts the cached SSH client.

func (*Service) Test

func (s *Service) Test(ctx context.Context, p authz.Principal, agentID uuid.UUID, slug string) (TestResult, error)

Test runs `whoami` through the dialer and parses the buffered NDJSON stream into a one-shot TestResult. Caps each captured stream at 4 KiB.

func (*Service) UnpinHostKey

func (s *Service) UnpinHostKey(ctx context.Context, p authz.Principal, agentID uuid.UUID, slug string) error

UnpinHostKey clears the TOFU-pinned host key on this endpoint; the next successful connect re-pins whatever the remote presents.

type TestResult

type TestResult struct {
	OK         bool
	ExitCode   int
	DurationMs int64
	Stdout     string
	Stderr     string
	Error      string
}

TestResult is the parsed outcome of running `whoami` over the configured SSH transport, ready to render in the operator UI.

Jump to

Keyboard shortcuts

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