enroll

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package enroll keeps an enrolled agent's registration credential (P1 §6): the refresh token in the supervisor's state dir, 0600, and before the first registration the one-time enrollment token from the file the config names. Tokens are never logged, and errors never carry them.

Index

Constants

View Source
const RefreshFile = "agent-refresh-token"

RefreshFile is the refresh token's file in the state dir.

Variables

View Source
var ErrNoCredential = errors.New("no refresh token in the state dir and no enrollmentTokenFile: mint an enrollment with `factory agent enroll` and set enrollmentTokenFile to its token's file")

ErrNoCredential is Token's error when there is neither a refresh token nor an enrollment token file.

Functions

This section is empty.

Types

type Files

type Files struct {
	// StateDir holds RefreshFile (supervise's --state-dir, absolute).
	StateDir string
	// TokenFile is the config's enrollmentTokenFile: read only while StateDir has no refresh
	// token. "" when the config sets none.
	TokenFile string
}

Files is the enrollment credential on disk. It implements worker.Enrollment.

func (Files) Enrolled

func (f Files) Enrolled() bool

Enrolled reports whether the state dir holds a refresh token.

func (Files) Forget

func (f Files) Forget() error

Forget removes the refresh token (the dispatcher refused it), so the next start reads TokenFile.

func (Files) Save

func (f Files) Save(refresh string) error

Save writes the next refresh token to the state dir, 0600, atomically (a temp file renamed over the old one), before the registration that returned it is used.

func (Files) Token

func (f Files) Token() (string, bool, error)

Token returns the refresh token when the state dir has one (refresh true), else the enrollment token from TokenFile. Both files must be 0600 single lines.

Jump to

Keyboard shortcuts

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