Documentation
¶
Index ¶
- Constants
- Variables
- func DecodeDefinitionBody[T any](raw json.RawMessage) (T, error)
- func WorkspaceArtifactDiagnostics(locator artifactstore.Locator, code string, message string) []artifactstore.Diagnostic
- func WorkspaceArtifactErrorDiagnostics(locator artifactstore.Locator, err error) []artifactstore.Diagnostic
- type ArtifactSupport
- type AttachRequest
- type AttachmentData
- type CatalogView
- type DefinitionDecoder
- type DefinitionDocument
- type DefinitionLoader
- type DefinitionObservation
- type DiscoveryPreferences
- type DiscoveryProfile
- type DiscoveryProfiles
- type DiscoveryRoot
- type EmptyWorkspaceRequest
- type FilesystemWorkspaceRequest
- type LoadPlan
- type LoadPlanItem
- type Mode
- type Planner
- type QueryService
- func (q *QueryService) Catalog(ctx context.Context, rootID artifactstore.RootID) (CatalogView, error)
- func (q *QueryService) ComposeLoadPlan(ctx context.Context, rootID artifactstore.RootID, ...) (LoadPlan, error)
- func (q *QueryService) GetWorkspace(ctx context.Context, rootID artifactstore.RootID) (Workspace, error)
- func (q *QueryService) Resolve(ctx context.Context, rootID artifactstore.RootID, reference Reference) (Resource, error)
- type RecordPolicy
- type Reference
- type Refresher
- type Resource
- type ResourceGroup
- type RootData
- type Service
- func (s *Service) Attach(ctx context.Context, request AttachRequest) (Workspace, error)
- func (s *Service) CreateEmpty(ctx context.Context, request EmptyWorkspaceRequest) (Workspace, error)
- func (s *Service) CreateFilesystem(ctx context.Context, request FilesystemWorkspaceRequest) (Workspace, error)
- func (s *Service) Delete(ctx context.Context, rootID artifactstore.RootID, expectedRevision uint64) (root.Root, error)
- func (s *Service) Detach(ctx context.Context, rootID artifactstore.RootID, ...) (Workspace, error)
- func (s *Service) Get(ctx context.Context, rootID artifactstore.RootID) (Workspace, error)
- func (s *Service) List(ctx context.Context) ([]Workspace, error)
- func (s *Service) Update(ctx context.Context, request UpdateRequest) (Workspace, error)
- func (s *Service) UpdateAttachment(ctx context.Context, request UpdateAttachmentRequest) (Workspace, error)
- type UpdateAttachmentRequest
- type UpdateRequest
- type Workspace
Constants ¶
const ( DiagnosticCodeArtifactInvalid = "workspace.artifact.invalid" DiagnosticCodeContextInvalidContent = "workspace.context.invalid-content" DiagnosticCodeContextInvalidUTF8 = "workspace.context.invalid-utf8" DiagnosticCodeDefinitionInvalid = "workspace.definition.invalid" DiagnosticCodeRecordSchemaUnsupported = "workspace.record.schema-unsupported" DiagnosticCodeRecordKindMismatch = "workspace.record.kind-mismatch" DiagnosticCodeSkillInvalid = "workspace.skill.invalid" )
const ( RootKind artifactstore.RootKind = "workspace.root" RolePrimary artifactstore.AttachmentRole = "primary" RoleBuiltIn artifactstore.AttachmentRole = "built-in" RoleLibrary artifactstore.AttachmentRole = "library" RoleAttachedPackage artifactstore.AttachmentRole = "attached-package" RoleOverlay artifactstore.AttachmentRole = "overlay" DefinitionKind artifactstore.ArtifactKind = "workspace.definition" DefinitionSchemaID artifactstore.SchemaID = "workspace.definition.v1" DefinitionDecoderID artifactstore.DecoderID = "workspace.definition-json" CapabilityProfileVersion = "1" PrimaryPriority = 1_000_000 WorkspaceMetadataDirectory = ".flexigpt" WorkspaceMetadataLocator artifactstore.Locator = WorkspaceMetadataDirectory RepositoryRootLocator artifactstore.Locator = "." WorkspaceDefinitionFileName = "workspace.json" DefinitionLocator artifactstore.Locator = WorkspaceMetadataDirectory + "/" + WorkspaceDefinitionFileName )
Variables ¶
var ( ErrInvalidWorkspace = errors.New("workspace: invalid") ErrNotWorkspace = errors.New("workspace: root is not a Workspace") ErrPrimarySourceRequired = errors.New("workspace: primary source is required") ErrPrimarySourceImmutable = errors.New("workspace: primary source is immutable") ErrReferenceUnresolved = errors.New("workspace: reference unresolved") ErrReferenceAmbiguous = errors.New("workspace: reference ambiguous") ErrWorkspaceDefinitionInvalid = errors.New("workspace: definition invalid") )
Functions ¶
func DecodeDefinitionBody ¶
func DecodeDefinitionBody[T any]( raw json.RawMessage, ) (T, error)
DecodeDefinitionBody decodes the canonical body held by a definition.
Artifact adapters use this after QueryService has selected an already validated definition.
func WorkspaceArtifactDiagnostics ¶
func WorkspaceArtifactDiagnostics( locator artifactstore.Locator, code string, message string, ) []artifactstore.Diagnostic
func WorkspaceArtifactErrorDiagnostics ¶
func WorkspaceArtifactErrorDiagnostics( locator artifactstore.Locator, err error, ) []artifactstore.Diagnostic
Types ¶
type ArtifactSupport ¶
type ArtifactSupport struct {
Kind artifactstore.ArtifactKind
SchemaID artifactstore.SchemaID
DecoderID artifactstore.DecoderID
}
func (ArtifactSupport) Validate ¶
func (s ArtifactSupport) Validate() error
type AttachRequest ¶
type AttachRequest struct {
RootID artifactstore.RootID `json:"rootID"`
ExpectedRootRevision uint64 `json:"expectedRootRevision"`
SourceID artifactstore.SourceID `json:"sourceID"`
Role artifactstore.AttachmentRole `json:"role"`
Priority int `json:"priority"`
Enabled bool `json:"enabled"`
Data AttachmentData `json:"data"`
}
type AttachmentData ¶
type CatalogView ¶
type CatalogView struct {
Workspace Workspace `json:"-"`
Catalog catalog.Snapshot `json:"-"`
Resources []Resource `json:"-"`
Unrecorded []catalog.Occurrence `json:"-"`
UnresolvedRecords []record.Record `json:"-"`
Groups []ResourceGroup `json:"-"`
}
type DefinitionDecoder ¶
type DefinitionDecoder struct{}
func NewDefinitionDecoder ¶
func NewDefinitionDecoder() *DefinitionDecoder
func (*DefinitionDecoder) Decode ¶
func (*DefinitionDecoder) Decode( _ context.Context, candidate discovery.Candidate, ) ([]discovery.Decoded, []artifactstore.Diagnostic)
func (*DefinitionDecoder) ID ¶
func (*DefinitionDecoder) ID() artifactstore.DecoderID
func (*DefinitionDecoder) Recognize ¶
func (*DefinitionDecoder) Recognize( _ context.Context, candidate discovery.Candidate, ) discovery.Recognition
type DefinitionDocument ¶
type DefinitionDocument struct {
Discovery DiscoveryPreferences `json:"discovery"`
}
type DefinitionLoader ¶
type DefinitionLoader struct {
// contains filtered or unexported fields
}
DefinitionLoader reads the primary workspace definition before discovery so its discovery preferences can be incorporated into the generated plan.
func NewDefinitionLoader ¶
func NewDefinitionLoader( runtime source.Runtime, ) (*DefinitionLoader, error)
func (*DefinitionLoader) Load ¶
func (l *DefinitionLoader) Load( ctx context.Context, value Workspace, ) (DefinitionObservation, error)
type DefinitionObservation ¶
type DefinitionObservation struct {
Preferences DiscoveryPreferences
SourceID artifactstore.SourceID
Generation string
}
type DiscoveryPreferences ¶
type DiscoveryPreferences struct {
AdditionalLocators []artifactstore.Locator `json:"additionalLocators,omitempty"`
AdditionalRoots []DiscoveryRoot `json:"additionalRoots,omitempty"`
IncludeReadme bool `json:"includeReadme,omitempty"`
}
type DiscoveryProfile ¶
type DiscoveryProfile struct {
ExplicitLocators []artifactstore.Locator
ReadmeLocator artifactstore.Locator
DirectoryRoots []discovery.DirectoryRoot
}
DiscoveryProfile defines discovery rules for one attachment class.
Artifact adapters contribute their own conventions through this type.
type DiscoveryProfiles ¶
type DiscoveryProfiles struct {
Primary DiscoveryProfile
Attached DiscoveryProfile
}
func DefaultDiscoveryProfiles ¶
func DefaultDiscoveryProfiles() DiscoveryProfiles
type DiscoveryRoot ¶
type DiscoveryRoot struct {
Root artifactstore.Locator `json:"root"`
Recursive bool `json:"recursive"`
IncludePatterns []string `json:"includePatterns,omitempty"`
}
type EmptyWorkspaceRequest ¶
type EmptyWorkspaceRequest struct {
DisplayName string `json:"displayName"`
Description string `json:"description,omitempty"`
TrustReference string `json:"trustReference,omitempty"`
Discovery DiscoveryPreferences `json:"discovery"`
}
type FilesystemWorkspaceRequest ¶
type FilesystemWorkspaceRequest struct {
DisplayName string `json:"displayName"`
Description string `json:"description,omitempty"`
PrimarySourceID artifactstore.SourceID `json:"primarySourceID"`
TrustReference string `json:"trustReference,omitempty"`
Discovery DiscoveryPreferences `json:"discovery"`
}
type LoadPlan ¶
type LoadPlan struct {
RootID artifactstore.RootID `json:"-"`
CatalogRevision uint64 `json:"-"`
Items []LoadPlanItem `json:"-"`
Diagnostics []artifactstore.Diagnostic `json:"-"`
}
type LoadPlanItem ¶
type LoadPlanItem struct {
Record record.Record `json:"-"`
Definition definition.Definition `json:"-"`
Source source.Summary `json:"-"`
}
LoadPlanItem contains privileged materialized source state. It must be projected into an explicit adapter response before crossing an API boundary.
type Planner ¶
type Planner struct {
// contains filtered or unexported fields
}
func NewPlanner ¶
func NewPlanner( profiles DiscoveryProfiles, decoderIDs ...artifactstore.DecoderID, ) (*Planner, error)
type QueryService ¶
type QueryService struct {
// contains filtered or unexported fields
}
func NewQueryService ¶
func NewQueryService( workspaces *Service, catalogs catalogSnapshotReader, records recordLister, definitions definitionLookup, ) (*QueryService, error)
func (*QueryService) Catalog ¶
func (q *QueryService) Catalog( ctx context.Context, rootID artifactstore.RootID, ) (CatalogView, error)
func (*QueryService) ComposeLoadPlan ¶
func (q *QueryService) ComposeLoadPlan( ctx context.Context, rootID artifactstore.RootID, recordIDs []artifactstore.RecordID, ) (LoadPlan, error)
func (*QueryService) GetWorkspace ¶
func (q *QueryService) GetWorkspace( ctx context.Context, rootID artifactstore.RootID, ) (Workspace, error)
func (*QueryService) Resolve ¶
func (q *QueryService) Resolve( ctx context.Context, rootID artifactstore.RootID, reference Reference, ) (Resource, error)
type RecordPolicy ¶
type RecordPolicy struct {
// contains filtered or unexported fields
}
func NewRecordPolicy ¶
func NewRecordPolicy( supports ...ArtifactSupport, ) (*RecordPolicy, error)
func (*RecordPolicy) Derive ¶
func (p *RecordPolicy) Derive( _ context.Context, _ root.Root, occurrence catalog.Occurrence, value definition.Definition, ) (record.Draft, bool, []artifactstore.Diagnostic)
type Reference ¶
type Reference struct {
RecordID *artifactstore.RecordID `json:"-"`
Selector *definition.Selector `json:"-"`
}
type Refresher ¶
type Refresher struct {
// contains filtered or unexported fields
}
func NewRefresher ¶
func NewRefresher( workspaces *Service, loader *DefinitionLoader, planner *Planner, runner refresh.Runner, policy *RecordPolicy, ) (*Refresher, error)
type Resource ¶
type Resource struct {
Record record.Record `json:"-"`
Definition definition.Definition `json:"-"`
Occurrence *catalog.Occurrence `json:"-"`
Source source.Summary `json:"-"`
CatalogCurrent bool `json:"-"`
}
type ResourceGroup ¶
type ResourceGroup struct {
Kind artifactstore.ArtifactKind `json:"-"`
Resources []Resource `json:"-"`
Unrecorded []catalog.Occurrence `json:"-"`
}
type RootData ¶
type RootData struct {
Mode Mode `json:"mode"`
PrimarySourceID artifactstore.SourceID `json:"primarySourceID,omitempty"`
TrustReference string `json:"trustReference,omitempty"`
Discovery DiscoveryPreferences `json:"discovery"`
CapabilityProfileVersion string `json:"capabilityProfileVersion"`
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (*Service) CreateEmpty ¶
func (*Service) CreateFilesystem ¶
func (*Service) UpdateAttachment ¶
type UpdateAttachmentRequest ¶
type UpdateAttachmentRequest struct {
RootID artifactstore.RootID
SourceID artifactstore.SourceID
ExpectedRootRevision uint64
ExpectedAttachmentRevision uint64
Role artifactstore.AttachmentRole
Priority int
Enabled bool
Data AttachmentData
}
type UpdateRequest ¶
type UpdateRequest struct {
RootID artifactstore.RootID `json:"rootID"`
ExpectedRevision uint64 `json:"expectedRevision"`
DisplayName string `json:"displayName"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
TrustReference string `json:"trustReference,omitempty"`
Discovery DiscoveryPreferences `json:"discovery"`
}
type Workspace ¶
type Workspace struct {
Root root.Root `json:"-"`
Data RootData `json:"-"`
Attachments []root.Attachment `json:"-"`
Sources []source.Summary `json:"-"`
}
Workspace is an internal privileged aggregate. API packages must project it into explicit view models instead of serializing source configuration, root data, or attachment data.