integrations

package
v0.34.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IntegrationsFS embed.FS = integrationsfs.FS

IntegrationsFS is the embedded canonical + rendered integration tree. The //go:embed directive lives in package integrationsfs at the repository-root integrations/ directory because Go's embed machinery can only reach files rooted at the declaring package; this package re-exports the FS so callers keep a single import path.

Paths inside the FS are relative to the integrations/ directory: canonical content at "content/<file>" and adapter output at "rendered/<host>/...".

Functions

func Register

func Register(a Adapter)

Register adds a to the default adapter set. It is safe to call from init(). Duplicate names are rejected eagerly so a copy-paste bug in a new adapter fails during test setup rather than silently clobbering an earlier entry.

func RenderAll

func RenderAll(rt *toolkit.Runtime, content fs.FS, dst DestWriter, adapters []Adapter) error

RenderAll reads canonical content from content and dispatches each Adapter onto dst. Adapters are invoked in DefaultAdapters() order. The first adapter error aborts the render; partial writes to dst are left in place for inspection by the caller, which for DirWriter means they sit in the staging directory and never become user-visible. rt is required — it carries env, clock, and filesystem access that adapters consult for release-time configuration. Tests construct a sandbox runtime via sandbox.NewSandbox so environment lookups stay jailed.

Types

type Adapter

type Adapter interface {
	// Name returns the adapter's directory name under the rendered root.
	// Examples: "claude", "codex". It must be a single path segment.
	Name() string

	// Render reads canonical from content and writes every host-specific
	// file to dst with a path prefix of Name()+"/". The runtime carries
	// env, clock, and filesystem access for adapters that need them
	// (for example to consult release-time configuration through
	// rt.Env().Get). rt is required and must not be nil; tests that do
	// not want to touch the real process environment should use
	// sandbox.NewSandbox to construct a jailed runtime.
	Render(rt *toolkit.Runtime, content fs.FS, dst DestWriter) error
}

Adapter renders canonical content into a host-specific file tree under a DestWriter. Each adapter owns its own output namespace (a subdirectory of the rendered root keyed by Name()). Adapters must not read or write anything outside that namespace and must not import each other.

func DefaultAdapters

func DefaultAdapters() []Adapter

DefaultAdapters returns a copy of the registered adapter set, sorted by name so RenderAll is deterministic across runs and platforms.

type DestWriter

type DestWriter interface {
	// Write places b at the given relative path. Implementations must
	// create any missing parent directories. Calls with the same path
	// overwrite prior writes.
	Write(path string, b []byte) error
}

DestWriter is the write surface adapters use. Keeping it abstract lets RenderAll target either an on-disk staging directory (DirWriter) or an in-memory map (MemWriter) for byte-parity tests without touching the FS.

type DirWriter

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

DirWriter writes to an on-disk root directory through a toolkit.Runtime, so writes honor sandboxed test environments and respect the project's Runtime Abstraction Rule. Writes go to a sibling ".render-tmp" file and are then atomically renamed into place; a half-written file never becomes visible at the final rendered path.

func NewDirWriter

func NewDirWriter(rt *toolkit.Runtime, root string) *DirWriter

NewDirWriter returns a DirWriter that places files under root via rt. root is resolved relative to rt's working directory, so production callers pass a path like "integrations/rendered" and test sandboxes see writes confined to their jail.

func (*DirWriter) Write

func (d *DirWriter) Write(relPath string, b []byte) error

Write writes b to relPath under the DirWriter root. rt.WriteFile creates any missing parent directories internally; the temp-rename step gives callers atomic visibility.

type MemWriter

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

MemWriter buffers writes in memory for tests. Files() returns a stable snapshot of the accumulated writes keyed by forward-slash relative path.

func NewMemWriter

func NewMemWriter() *MemWriter

NewMemWriter allocates an empty MemWriter.

func (*MemWriter) Files

func (m *MemWriter) Files() map[string][]byte

Files returns the accumulated writes. Callers must not mutate the returned slices; treat the map as an immutable snapshot of the render.

func (*MemWriter) Paths

func (m *MemWriter) Paths() []string

Paths returns the sorted list of paths MemWriter has seen. Useful for deterministic test assertions.

func (*MemWriter) Write

func (m *MemWriter) Write(path string, b []byte) error

Write stores a copy of b at path. Paths are normalised to forward slashes.

Directories

Path Synopsis
Package renderdata embeds canonical host-specific source bytes that the render-integrations command overlays onto the canonical content tree.
Package renderdata embeds canonical host-specific source bytes that the render-integrations command overlays onto the canonical content tree.

Jump to

Keyboard shortcuts

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