Documentation
¶
Overview ¶
Package environmenttemplates owns Environment Templates: saved, tenant-owned hosted Environment configuration that Sessions reference at creation. It owns the Template vocabulary, the rules for Template input and the create, update and delete operations. Reader reads Templates, including the decrypted configuration Session creation composes over.
Index ¶
Constants ¶
const MaxListLimit = 100
MaxListLimit is the largest page a list returns.
const MaxNameLength = 256
MaxNameLength is the longest Template name, in characters.
Variables ¶
var ( // ErrNotFound reports a Template, or a list cursor, that names no Template of // the tenant. Missing, malformed and foreign IDs are indistinguishable. ErrNotFound = errors.New("environment template not found") // ErrInvalidInput reports input that is not a valid Template, or a saved // Template whose configuration no longer passes validation. ErrInvalidInput = errors.New("invalid environment template") )
Functions ¶
func ValidateName ¶
ValidateName accepts no name or a valid UTF-8 name of 1 to MaxNameLength characters.
Types ¶
type CreateCommand ¶
type DeleteCommand ¶
type Input ¶
type Input struct {
Name *string
SetName bool
NetworkAccess string
AllowedDomains []string
SetNetwork bool
Files []environmentconfig.InitialFile
SetFiles bool
Setup environmentconfig.Setup
SetEnv bool
SetCommands bool
SetPackages bool
SetSkills bool
SetPlugins bool
SetDirectories bool
}
Input is Template configuration as a create or update request states it. Create saves every field. Update replaces exactly the fields whose Set flag is true, each atomically, and keeps the others.
type ListQuery ¶
ListQuery selects one page of a tenant's Templates in creation order, with ID tie-breaking. After is the previous page's last Template ID, or empty.
type Reader ¶
type Reader interface {
Get(ctx context.Context, tenantID, templateID string) (Template, error)
List(ctx context.Context, tenantID string, query ListQuery) (Page, error)
Resolve(ctx context.Context, tenantID, templateID string) (Resolved, error)
}
Reader reads a tenant's Templates. Get and List return safe metadata without the credential key. Resolve decrypts the configuration for Session creation. An unknown Template or cursor returns ErrNotFound.
type Resolved ¶
type Resolved struct {
Template Template
Setup environmentconfig.Setup
Files []environmentconfig.InitialFile
}
Resolved is a Template with its decrypted configuration, read in one snapshot for Session creation. Skill references keep the selectors the Template saved.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service runs the Template write operations.
func NewService ¶
func (*Service) Create ¶
Create saves a new Template. Input without a network policy gets the default.
type Storage ¶
type Storage interface {
Create(ctx context.Context, tenantID string, in Input) (Template, error)
Update(ctx context.Context, tenantID, templateID string, in Input) (Template, error)
Delete(ctx context.Context, tenantID, templateID string) (string, error)
}
Storage saves Templates. Each method runs in one transaction that also records the write audit, so a failed audit leaves nothing changed. Update and Delete return ErrNotFound for a Template the tenant does not own.
type Template ¶
type Template struct {
ID string
Name *string
NetworkAccess string
AllowedDomains []string
Packages v1.EnvironmentPackages
Files []environmentconfig.InitialFileMetadata
Skills []environmentconfig.SkillMetadata
Plugins []agentplugin.Metadata
CapabilityDirectories []string
CreatedAt time.Time
UpdatedAt time.Time
}
Template is a saved Template's safe metadata: it holds no confidential setup, file contents or archives.