Documentation
¶
Overview ¶
Package domain contains Foundry's shared domain primitives.
This package is for value objects and pure helpers that are used across configuration loading, molding, casting, patching, and writing. Examples include structured materials, opaque blob materials, template wrappers, addresses, formats, pointer helpers, and serialization helpers.
Keep this package free of orchestration and side effects. It must not decide which pipeline phase runs, select deployment implementations, execute tools, write files, read user configuration, or contain platform-specific rendering behavior. Put that logic in the package that owns the behavior instead.
The only Foundry package this package may import is internal/errors. Do not import api/v1alpha1 or any internal orchestration, casting, molding, infrastructure, writer, tooler, config, or ledger package from here.
Index ¶
- Variables
- func MarshalYAML(v any) ([]byte, error)
- func MergeYAML(base, override string) (string, error)
- func MustMarshalYAML(v any) []byte
- func MustNewFileFromFS(fs embed.FS, path string) []byte
- func MustUnmarshalYAML(data []byte, v any) error
- func NewBoolPtr(i bool) *bool
- func NewIntPtr(i int) *int
- func UnmarshalYAML(data []byte, v any) error
- type Address
- type BlobMaterial
- type DistinctID
- type Event
- type Format
- type INIMaterial
- func (m INIMaterial) CloneWithJSONContents(contents []byte) StructuredMaterial
- func (m INIMaterial) FmtContents() []byte
- func (m INIMaterial) GetBytes(path string) ([]byte, error)
- func (m INIMaterial) GetStringSlice(path string) ([]string, error)
- func (m INIMaterial) HasMultipleDocuments() bool
- func (m INIMaterial) JSONContents() []byte
- func (m INIMaterial) Path() string
- type JSONMaterial
- func (m JSONMaterial) CloneWithJSONContents(contents []byte) StructuredMaterial
- func (m JSONMaterial) FmtContents() []byte
- func (m JSONMaterial) GetBytes(path string) ([]byte, error)
- func (m JSONMaterial) GetStringSlice(path string) ([]string, error)
- func (m JSONMaterial) HasMultipleDocuments() bool
- func (m JSONMaterial) JSONContents() []byte
- func (m JSONMaterial) Path() string
- type Material
- type Properties
- type StructuredMaterial
- type Template
- func MustNewTemplate(name string, contents []byte, format Format) *Template
- func MustNewTemplateFromFS(fs embed.FS, path string, format Format) *Template
- func NewTemplate(name string, contents []byte, format Format) (*Template, error)
- func NewTemplateFromFS(fs embed.FS, path string, format Format) (*Template, error)
- type YAMLMaterial
- func (m YAMLMaterial) CloneWithJSONContents(contents []byte) StructuredMaterial
- func (m YAMLMaterial) FmtContents() []byte
- func (m YAMLMaterial) GetBytes(path string) ([]byte, error)
- func (m YAMLMaterial) GetStringSlice(path string) ([]string, error)
- func (m YAMLMaterial) HasMultipleDocuments() bool
- func (m YAMLMaterial) JSONContents() []byte
- func (m YAMLMaterial) Path() string
Constants ¶
This section is empty.
Variables ¶
var ( EventGauge = Event{/* contains filtered or unexported fields */} EventForge = Event{/* contains filtered or unexported fields */} EventCast = Event{/* contains filtered or unexported fields */} EventCatalog = Event{/* contains filtered or unexported fields */} )
var ( FormatYAML = Format{/* contains filtered or unexported fields */} FormatJSON = Format{/* contains filtered or unexported fields */} FormatINI = Format{/* contains filtered or unexported fields */} FormatText = Format{/* contains filtered or unexported fields */} )
Functions ¶
func MarshalYAML ¶
func MergeYAML ¶
MergeYAML takes a base YAML string and an override YAML string, and returns a new YAML string with deep merge — override keys win at every level, base-only keys are preserved.
func MustMarshalYAML ¶
func MustUnmarshalYAML ¶
func NewBoolPtr ¶
func UnmarshalYAML ¶
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
func MustNewAddress ¶
func NewAddress ¶
NewAddress requires a non-empty scheme and host, and a port in [0, 65535] where 0 means no port.
func ParseAddress ¶
ParseAddress accepts "scheme://host[:port]"; IPv6 literals must be bracketed (e.g. "tcp://[::1]:9000" or "tcp://[::1]").
func ParseAddresses ¶
type BlobMaterial ¶
type BlobMaterial struct {
// contains filtered or unexported fields
}
func NewBlobMaterial ¶
func NewBlobMaterial(contents []byte, path string) BlobMaterial
func (BlobMaterial) FmtContents ¶
func (m BlobMaterial) FmtContents() []byte
func (BlobMaterial) Path ¶
func (m BlobMaterial) Path() string
type DistinctID ¶
type DistinctID struct {
// contains filtered or unexported fields
}
DistinctID is an anonymous, stable identifier for telemetry attribution. It is at most 32 characters and never reveals the source from which it was derived; values longer than 32 characters are truncated by NewDistinctID.
func MustNewDistinctID ¶
func MustNewDistinctID() DistinctID
func NewDistinctID ¶
func NewDistinctID() (DistinctID, error)
func UnknownDistinctID ¶
func UnknownDistinctID() DistinctID
UnknownDistinctID is the sentinel used when no stable raw identifier could be derived.
func (DistinctID) String ¶
func (d DistinctID) String() string
type Event ¶
type Event struct {
// contains filtered or unexported fields
}
Event names a foundryctl pipeline operation tracked by the ledger. An Event carries an optional past-tense outcome (succeeded or failed) so that ledger adapters see a finite, stable vocabulary like "forge succeeded" or "forge failed" rather than a single name disambiguated by a property.
func MustNewEvent ¶
func NewEvent ¶
NewEvent accepts only the names of declared base Event values. The returned Event has no outcome; use Succeeded or Failed to attach one.
type Format ¶
type Format struct {
// contains filtered or unexported fields
}
Format identifies the syntax of a Material's contents and carries the constructor that wraps a rendered byte stream in the matching concrete Material type. To register a new format, add a single entry above with its New* constructor — Template.Render picks it up automatically.
func (Format) NewMaterial ¶
NewMaterial wraps contents in the concrete Material type for this format.
type INIMaterial ¶
type INIMaterial struct {
// contains filtered or unexported fields
}
func MustNewINIMaterial ¶
func MustNewINIMaterial(contents []byte, path string) INIMaterial
func NewINIMaterial ¶
func NewINIMaterial(contents []byte, path string) (INIMaterial, error)
func (INIMaterial) CloneWithJSONContents ¶
func (m INIMaterial) CloneWithJSONContents(contents []byte) StructuredMaterial
func (INIMaterial) FmtContents ¶
func (m INIMaterial) FmtContents() []byte
func (INIMaterial) GetStringSlice ¶
func (m INIMaterial) GetStringSlice(path string) ([]string, error)
func (INIMaterial) HasMultipleDocuments ¶
func (m INIMaterial) HasMultipleDocuments() bool
func (INIMaterial) JSONContents ¶
func (m INIMaterial) JSONContents() []byte
func (INIMaterial) Path ¶
func (m INIMaterial) Path() string
type JSONMaterial ¶
type JSONMaterial struct {
// contains filtered or unexported fields
}
func MustNewJSONMaterial ¶
func MustNewJSONMaterial(contents []byte, path string) JSONMaterial
func NewJSONMaterial ¶
func NewJSONMaterial(contents []byte, path string) (JSONMaterial, error)
func (JSONMaterial) CloneWithJSONContents ¶
func (m JSONMaterial) CloneWithJSONContents(contents []byte) StructuredMaterial
func (JSONMaterial) FmtContents ¶
func (m JSONMaterial) FmtContents() []byte
func (JSONMaterial) GetStringSlice ¶
func (m JSONMaterial) GetStringSlice(path string) ([]string, error)
func (JSONMaterial) HasMultipleDocuments ¶
func (m JSONMaterial) HasMultipleDocuments() bool
func (JSONMaterial) JSONContents ¶
func (m JSONMaterial) JSONContents() []byte
func (JSONMaterial) Path ¶
func (m JSONMaterial) Path() string
type Material ¶
type Material interface {
Path() string
// FmtContents returns the bytes in their human-readable, on-disk form. This
// is the form Foundry writes out, distinct from the canonical form used for
// traversal and patching.
FmtContents() []byte
}
Material is a unit of output that Foundry produces. It carries the path it should be written to and the bytes to write there.
type Properties ¶
type Properties struct {
// contains filtered or unexported fields
}
Properties is a string-keyed bag of telemetry values with a fixed shape for the success/error envelope (see WithSuccess and WithError). Set, WithSuccess, and WithError mutate the underlying map and return the receiver for chaining.
func NewProperties ¶
func NewProperties() Properties
func (Properties) Map ¶
func (p Properties) Map() map[string]any
Map returns a copy of the underlying values, safe for callers to mutate.
func (Properties) Set ¶
func (p Properties) Set(key string, value any) Properties
func (Properties) WithError ¶
func (p Properties) WithError(err error) Properties
WithError records that the tracked operation failed and stores the typed error kind, its message, and the underlying cause so analytics can group failures by class while preserving the wrapped detail.
func (Properties) WithSuccess ¶
func (p Properties) WithSuccess() Properties
WithSuccess records that the tracked operation succeeded.
type StructuredMaterial ¶
type StructuredMaterial interface {
Material
// JSONContents returns the canonical JSON form used for traversal and
// patching. JSON is the contract: callers (e.g. jsonpatch) operate on it
// directly.
JSONContents() []byte
// HasMultipleDocuments reports whether the material groups multiple
// top-level documents under one path (currently only multi-document YAML).
// Callers use this to choose between scalar and array traversal of
// JSONContents.
HasMultipleDocuments() bool
CloneWithJSONContents(contents []byte) StructuredMaterial
// GetBytes returns the value at the given path as bytes. The path uses
// gjson dotted-key syntax (e.g. "service.name", "service.names.0"), not
// JSON Pointer.
GetBytes(path string) ([]byte, error)
// GetStringSlice returns the slice at the given path as strings. See
// GetBytes for path syntax.
GetStringSlice(path string) ([]string, error)
}
StructuredMaterial is a Material whose contents are structured data with a navigable shape, supporting in-place reads and patches against a canonical representation.
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template is a parsed text/template paired with the on-disk path it was loaded from and the Format its rendered output is expected to take. Format drives Render's choice of concrete Material type.
func MustNewTemplateFromFS ¶
func NewTemplateFromFS ¶
type YAMLMaterial ¶
type YAMLMaterial struct {
// contains filtered or unexported fields
}
func MustNewYAMLMaterial ¶
func MustNewYAMLMaterial(contents []byte, path string) YAMLMaterial
func NewYAMLMaterial ¶
func NewYAMLMaterial(contents []byte, path string) (YAMLMaterial, error)
func (YAMLMaterial) CloneWithJSONContents ¶
func (m YAMLMaterial) CloneWithJSONContents(contents []byte) StructuredMaterial
func (YAMLMaterial) FmtContents ¶
func (m YAMLMaterial) FmtContents() []byte
func (YAMLMaterial) GetStringSlice ¶
func (m YAMLMaterial) GetStringSlice(path string) ([]string, error)
func (YAMLMaterial) HasMultipleDocuments ¶
func (m YAMLMaterial) HasMultipleDocuments() bool
func (YAMLMaterial) JSONContents ¶
func (m YAMLMaterial) JSONContents() []byte
func (YAMLMaterial) Path ¶
func (m YAMLMaterial) Path() string