environmenttemplates

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
const MaxListLimit = 100

MaxListLimit is the largest page a list returns.

View Source
const MaxNameLength = 256

MaxNameLength is the longest Template name, in characters.

Variables

View Source
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 decodes as one.
	ErrInvalidInput = errors.New("invalid environment template")
)

Functions

func ValidateName

func ValidateName(name *string) error

ValidateName accepts no name or a valid UTF-8 name of 1 to MaxNameLength characters.

Types

type CreateCommand

type CreateCommand struct {
	TenantID string
	Input    Input
}

type DeleteCommand

type DeleteCommand struct {
	TenantID   string
	TemplateID string
}

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.

func (Input) Validate

func (in Input) Validate() error

Validate reports whether the input is valid Template configuration. The network policy is checked only when the input sets one.

type ListQuery

type ListQuery struct {
	After     string
	Limit     int
	Ascending bool
}

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.

func (ListQuery) Validate

func (q ListQuery) Validate() error

Validate accepts a Limit from 1 to MaxListLimit.

type Page

type Page struct {
	Templates []Template
	HasMore   bool
}

Page is one page of Templates.

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 NewService(storage Storage) (*Service, error)

func (*Service) Create

func (s *Service) Create(ctx context.Context, cmd CreateCommand) (Template, error)

Create saves a new Template. Input without a network policy gets the default.

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, cmd DeleteCommand) (string, error)

Delete deletes a Template and returns its ID. Sessions created from it keep their frozen configuration.

func (*Service) Update

func (s *Service) Update(ctx context.Context, cmd UpdateCommand) (Template, error)

Update replaces the fields the input sets. Invalid input is rejected before the Template is looked up.

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, so reading it needs no credential key.

type UpdateCommand

type UpdateCommand struct {
	TenantID   string
	TemplateID string
	Input      Input
}

Jump to

Keyboard shortcuts

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