Documentation
¶
Overview ¶
Package projections maps JSON source rows into YAML documents using CEL and JSONPath.
Index ¶
- func Syntax() string
- type LoadOptions
- type Options
- type Projection
- type ProjectionApplyResult
- type ProjectionExecQuery
- type ProjectionHTTPAccepted
- type ProjectionHTTPQuery
- type ProjectionMetadata
- type ProjectionQuery
- type ProjectionRunResult
- type ProjectionSet
- type ProjectionSource
- type ProjectionSpec
- type ProjectionTarget
- type ProjectionVerifyResult
- type ProjectionWarning
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type LoadOptions ¶
type Projection ¶
type Projection struct {
APIVersion string `json:"apiVersion" yaml:"apiVersion"`
Kind string `json:"kind" yaml:"kind"`
Metadata ProjectionMetadata `json:"metadata" yaml:"metadata"`
Spec ProjectionSpec `json:"spec" yaml:"spec"`
// contains filtered or unexported fields
}
func Load ¶
func Load(options LoadOptions) ([]Projection, error)
Load reads files and directories in order, enforcing unique names before selection.
type ProjectionApplyResult ¶
type ProjectionApplyResult struct {
Projection string `json:"projection" yaml:"projection"`
Status projectionStatus `json:"status" yaml:"status"`
// Error is the reason a failed projection stopped. It is carried on the result
// rather than returned so one projection's failure cannot hide the others.
Error string `json:"error,omitempty" yaml:"error,omitempty"`
Target string `json:"target" yaml:"target"`
Sources int `json:"sources" yaml:"sources"`
// Filtered counts sources dropped by spec.source.where, so a predicate that
// silently matches nothing is visible rather than looking like clean output.
Filtered int `json:"filtered" yaml:"filtered"`
Matched int `json:"matched" yaml:"matched"`
// Aggregated counts source applications beyond the first for each target,
// keeping the summary honest about fan-in under spec.target.aggregate.
Aggregated int `json:"aggregated" yaml:"aggregated"`
Changed []string `json:"changed" yaml:"changed"`
Created []string `json:"created" yaml:"created"`
Missing []string `json:"missing" yaml:"missing"`
Stale []string `json:"stale" yaml:"stale"`
Warnings []ProjectionWarning `json:"warnings,omitempty" yaml:"warnings,omitempty"`
DryRun bool `json:"dry_run" yaml:"dry_run"`
}
func Apply ¶
func Apply(ctx context.Context, projections []Projection, options Options) ([]ProjectionApplyResult, error)
Apply runs projections sequentially; an individual failure does not hide later results.
func (ProjectionApplyResult) Columns ¶
func (r ProjectionApplyResult) Columns() []api.ColumnDef
The table carries counts; the identities behind them live in RowDetail. Printing every changed identity as a cell wrapped hundreds of UUIDs across the summary and buried the one column that mattered.
func (ProjectionApplyResult) Row ¶
func (r ProjectionApplyResult) Row() map[string]any
func (ProjectionApplyResult) RowDetail ¶
func (r ProjectionApplyResult) RowDetail() api.Textable
type ProjectionExecQuery ¶
type ProjectionExecQuery struct {
Script string `json:"script" yaml:"script"`
Mode string `json:"mode,omitempty" yaml:"mode,omitempty"`
Connections connection.ExecConnections `json:"connections,omitempty" yaml:"connections,omitempty"`
Env []types.EnvVar `json:"env,omitempty" yaml:"env,omitempty"`
PassthroughEnv []string `json:"passthroughEnv,omitempty" yaml:"passthroughEnv,omitempty"`
Select string `json:"select,omitempty" yaml:"select,omitempty"`
Timeout time.Duration `json:"timeout,omitempty" yaml:"timeout,omitempty"`
}
type ProjectionHTTPAccepted ¶
type ProjectionHTTPQuery ¶
type ProjectionHTTPQuery struct {
connection.HTTPConnection `json:",inline" yaml:",inline"`
Method string `json:"method,omitempty" yaml:"method,omitempty"`
Select string `json:"select,omitempty" yaml:"select,omitempty"`
Accepted ProjectionHTTPAccepted `json:"accepted,omitempty" yaml:"accepted,omitempty"`
}
type ProjectionMetadata ¶
type ProjectionMetadata struct {
Name string `json:"name" yaml:"name"`
}
type ProjectionQuery ¶
type ProjectionQuery struct {
Exec *ProjectionExecQuery `json:"exec,omitempty" yaml:"exec,omitempty"`
HTTP *ProjectionHTTPQuery `json:"http,omitempty" yaml:"http,omitempty"`
}
type ProjectionRunResult ¶
type ProjectionRunResult struct {
Projection string `json:"projection" yaml:"projection"`
Context map[string]any `json:"context" yaml:"context"`
Items []map[string]any `json:"items" yaml:"items"`
Filtered int `json:"filtered" yaml:"filtered"`
Warnings []ProjectionWarning `json:"warnings,omitempty" yaml:"warnings,omitempty"`
}
func Run ¶
func Run(ctx context.Context, projections []Projection, options Options) ([]ProjectionRunResult, error)
Run fetches and filters source rows, leaving targets untouched.
type ProjectionSet ¶
type ProjectionSource ¶
type ProjectionSource struct {
Query ProjectionQuery `json:"query" yaml:"query"`
// Where is a CEL predicate over source and context evaluated per source item
// before matching. Items that evaluate false are dropped and counted in
// ProjectionApplyResult.Filtered.
Where string `json:"where,omitempty" yaml:"where,omitempty"`
}
type ProjectionSpec ¶
type ProjectionSpec struct {
Source ProjectionSource `json:"source" yaml:"source"`
Target *ProjectionTarget `json:"target,omitempty" yaml:"target,omitempty"`
Match []string `json:"match,omitempty" yaml:"match,omitempty"`
Set map[string]ProjectionSet `json:"set,omitempty" yaml:"set,omitempty"`
}
type ProjectionTarget ¶
type ProjectionTarget struct {
Path string `json:"path" yaml:"path"`
Schema string `json:"schema,omitempty" yaml:"schema,omitempty"`
Select string `json:"select" yaml:"select"`
Filter string `json:"filter,omitempty" yaml:"filter,omitempty"`
Create *bool `json:"create,omitempty" yaml:"create,omitempty"`
// Aggregate allows many sources to fold into one target. Scalar mappings must
// be guarded, and conflicting writes fail during application.
Aggregate bool `json:"aggregate,omitempty" yaml:"aggregate,omitempty"`
}
func (ProjectionTarget) CreatesTargets ¶
func (t ProjectionTarget) CreatesTargets() bool
type ProjectionVerifyResult ¶
type ProjectionVerifyResult struct {
Files []string `json:"files" yaml:"files"`
Projections []string `json:"projections" yaml:"projections"`
}
func Verify ¶
func Verify(projections []Projection) (ProjectionVerifyResult, error)
Verify checks manifests, targets and schemas without executing sources or resolving credentials.
type ProjectionWarning ¶
Click to show internal directories.
Click to hide internal directories.