source

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package source owns configuration source adapters. It deliberately has no dependency on Pack or draft semantics.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrGitWorkspaceDirty = errors.New("git workspace is dirty")
	ErrRoundTripBlocked  = errors.New("git-json round-trip is blocked")
)
View Source
var DefaultGitExecutor = GitExecutor{Runner: execCommandRunner{}}
View Source
var ErrRevisionMismatch = errors.New("source revision mismatch")

Functions

This section is empty.

Types

type Adapter

type Adapter interface {
	Load() (Snapshot, error)
	Save(SaveInput) (Snapshot, error)
	Status() (Status, error)
	Capabilities() Capabilities
}

type Capabilities

type Capabilities struct {
	Read bool `json:"read"`
	Save bool `json:"save"`
}

type CommandRunner

type CommandRunner interface {
	Run(context.Context, string, []string) ([]byte, error)
}

CommandRunner executes a program using an argument vector. It deliberately has no shell-string entry point so callers cannot accidentally interpolate branch names, paths, or commit messages into a shell command.

type GitExecutor

type GitExecutor struct {
	Runner CommandRunner
}

GitExecutor centralizes every system Git invocation used by source adapters and the review workflow. Tests replace Runner to assert exact argument boundaries without starting a shell.

func (GitExecutor) Output

func (e GitExecutor) Output(ctx context.Context, workspace string, args ...string) ([]byte, error)

type GitJSON

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

func OpenGitJSON

func OpenGitJSON(workspace, profilePath string) (*GitJSON, error)

func (*GitJSON) Capabilities

func (g *GitJSON) Capabilities() Capabilities

func (*GitJSON) Inspect

func (g *GitJSON) Inspect() (InspectResult, error)

func (*GitJSON) Load

func (g *GitJSON) Load() (Snapshot, error)

func (*GitJSON) Preview

func (g *GitJSON) Preview(input SaveInput) (Preview, error)

func (*GitJSON) ReviewWorkspace

func (g *GitJSON) ReviewWorkspace() (GitWorkspace, []string, error)

ReviewWorkspace returns only the Git repository and declarative managed paths. Unlike Status, it does not read mapped documents, so a blocked round-trip can still be inspected and reported to the user.

func (*GitJSON) Save

func (g *GitJSON) Save(input SaveInput) (Snapshot, error)

func (*GitJSON) Status

func (g *GitJSON) Status() (Status, error)

type GitJSONField

type GitJSONField struct {
	Path      string `yaml:"path" json:"path"`
	Transform string `yaml:"transform" json:"transform"`
}

type GitJSONFile

type GitJSONFile struct {
	Path   string `yaml:"path" json:"path"`
	Format string `yaml:"format" json:"format"`
}

type GitJSONMapping

type GitJSONMapping struct {
	Name              string                  `yaml:"name" json:"name"`
	Collection        string                  `yaml:"collection" json:"collection"`
	Scope             string                  `yaml:"scope" json:"scope"`
	File              string                  `yaml:"file" json:"file"`
	RecordsPath       string                  `yaml:"records_path" json:"records_path"`
	IDPath            string                  `yaml:"id_path" json:"id_path"`
	EnvironmentIDPath string                  `yaml:"environment_id_path" json:"environment_id_path"`
	Fields            map[string]GitJSONField `yaml:"fields" json:"fields"`
}

type GitJSONProfile

type GitJSONProfile struct {
	Version  int              `yaml:"version" json:"version"`
	Files    []GitJSONFile    `yaml:"files" json:"files"`
	Mappings []GitJSONMapping `yaml:"mappings" json:"mappings"`
}

GitJSONProfile is a declarative bridge from a repository-owned document to the source-neutral configuration shape. Paths are RFC 6901 JSON pointers.

type GitWorkspace

type GitWorkspace struct {
	Root   string `json:"root"`
	Branch string `json:"branch"`
	Dirty  bool   `json:"dirty"`
}

GitWorkspace is deliberately limited to safe, user-visible repository state. The adapter only invokes read-only git commands.

type InspectResult

type InspectResult struct {
	Workspace   GitWorkspace        `json:"workspace"`
	ProfilePath string              `json:"profile_path"`
	Matched     bool                `json:"matched"`
	Diagnostics []MappingDiagnostic `json:"diagnostics"`
}

type ManagedFile

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

func OpenManagedFile

func OpenManagedFile(workspace string) *ManagedFile

func (*ManagedFile) Capabilities

func (m *ManagedFile) Capabilities() Capabilities

func (*ManagedFile) Load

func (m *ManagedFile) Load() (Snapshot, error)

func (*ManagedFile) Save

func (m *ManagedFile) Save(input SaveInput) (Snapshot, error)

func (*ManagedFile) Status

func (m *ManagedFile) Status() (Status, error)

type MappingDiagnostic

type MappingDiagnostic struct {
	Code    string `json:"code"`
	Path    string `json:"path"`
	Message string `json:"message"`
}

type Preview

type Preview struct {
	Digest string        `json:"source_digest"`
	Files  []PreviewFile `json:"files"`
}

type PreviewFile

type PreviewFile struct {
	Path    string `json:"path"`
	Diff    string `json:"diff"`
	Changed bool   `json:"changed"`
}

type SaveInput

type SaveInput struct {
	ExpectedRevision    string
	EnvironmentID       string
	Baseline            map[string]any
	EnvironmentOverride map[string]any
}

SaveInput replaces the two source layers visible to one draft save. A nil environment override removes the managed file for that environment.

type Snapshot

type Snapshot struct {
	Revision             string
	Baseline             map[string]any
	EnvironmentOverrides map[string]map[string]any
}

type Status

type Status struct {
	Type             string        `json:"type"`
	Digest           string        `json:"digest"`
	ExternalModified bool          `json:"external_modified"`
	Paths            []string      `json:"paths"`
	Git              *GitWorkspace `json:"git,omitempty"`
}

Jump to

Keyboard shortcuts

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