Documentation
¶
Index ¶
- func GetSecret(name string) (string, error)
- func Input[T interface{ ... }, E any](args *Args, name string) (E, error)
- func LoadParams(base string) (map[string]any, error)
- func Param[T any](args *Args, name string) (T, error)
- func ReadBlockManifest(base string) map[string]any
- func Run[O IntoOutput](handler func(*Args) (O, error))
- func RunAt[O IntoOutput](base string, handler func(*Args) (O, error)) error
- func RunNoOutput(handler func(*Args) error)
- func RunNoOutputAt(base string, handler func(*Args) error) error
- func ScanInputs(base string) (map[string]InputEntry, error)
- func WriteOutputs(result IntoOutput, base string, manifestOutputs map[string]any) error
- type Args
- type BoolType
- type Directory
- func (d *Directory) DefaultOutputName() string
- func (d *Directory) FromDirectory(path string) error
- func (d *Directory) FromMultipleFiles(_ []string) error
- func (d *Directory) FromSingleFile(_ string) error
- func (d *Directory) ManifestEntry() ManifestInfo
- func (d *Directory) TypeName() string
- func (d *Directory) WriteTo(outputDir string) error
- type ErrEmptyInputDir
- type ErrInputNotFound
- type ErrParamNotFound
- type ErrTypeMismatch
- type File
- func (f *File) DefaultOutputName() string
- func (f *File) FromDirectory(_ string) error
- func (f *File) FromMultipleFiles(paths []string) error
- func (f *File) FromSingleFile(path string) error
- func (f *File) ManifestEntry() ManifestInfo
- func (f *File) TypeName() string
- func (f *File) WriteTo(outputDir string) error
- type FileCollection
- func (c *FileCollection) DefaultOutputName() string
- func (c *FileCollection) FromDirectory(_ string) error
- func (c *FileCollection) FromMultipleFiles(paths []string) error
- func (c *FileCollection) FromSingleFile(path string) error
- func (c *FileCollection) ManifestEntry() ManifestInfo
- func (c *FileCollection) TypeName() string
- func (c *FileCollection) WriteTo(outputDir string) error
- type FromInput
- type InputEntry
- type InputKind
- type IntoOutput
- type JsonFile
- func (f *JsonFile) DefaultOutputName() string
- func (f *JsonFile) FromDirectory(_ string) error
- func (f *JsonFile) FromMultipleFiles(paths []string) error
- func (f *JsonFile) FromSingleFile(path string) error
- func (f *JsonFile) ManifestEntry() ManifestInfo
- func (f *JsonFile) TypeName() string
- func (f *JsonFile) WriteTo(outputDir string) error
- type ManifestBuilder
- type ManifestInfo
- type NumberType
- type Outputs
- type RasterFile
- func (f *RasterFile) DefaultOutputName() string
- func (f *RasterFile) FromDirectory(_ string) error
- func (f *RasterFile) FromMultipleFiles(paths []string) error
- func (f *RasterFile) FromSingleFile(path string) error
- func (f *RasterFile) ManifestEntry() ManifestInfo
- func (f *RasterFile) TypeName() string
- func (f *RasterFile) WriteTo(outputDir string) error
- type RasterFileCollection
- func (c *RasterFileCollection) DefaultOutputName() string
- func (c *RasterFileCollection) FromDirectory(_ string) error
- func (c *RasterFileCollection) FromMultipleFiles(paths []string) error
- func (c *RasterFileCollection) FromSingleFile(path string) error
- func (c *RasterFileCollection) ManifestEntry() ManifestInfo
- func (c *RasterFileCollection) TypeName() string
- func (c *RasterFileCollection) WriteTo(outputDir string) error
- type SpadeType
- type StringType
- type TabularFile
- func (f *TabularFile) DefaultOutputName() string
- func (f *TabularFile) FromDirectory(_ string) error
- func (f *TabularFile) FromMultipleFiles(paths []string) error
- func (f *TabularFile) FromSingleFile(path string) error
- func (f *TabularFile) ManifestEntry() ManifestInfo
- func (f *TabularFile) TypeName() string
- func (f *TabularFile) WriteTo(outputDir string) error
- type TabularFileCollection
- func (c *TabularFileCollection) DefaultOutputName() string
- func (c *TabularFileCollection) FromDirectory(_ string) error
- func (c *TabularFileCollection) FromMultipleFiles(paths []string) error
- func (c *TabularFileCollection) FromSingleFile(path string) error
- func (c *TabularFileCollection) ManifestEntry() ManifestInfo
- func (c *TabularFileCollection) TypeName() string
- func (c *TabularFileCollection) WriteTo(outputDir string) error
- type VectorFile
- func (f *VectorFile) DefaultOutputName() string
- func (f *VectorFile) FromDirectory(_ string) error
- func (f *VectorFile) FromMultipleFiles(paths []string) error
- func (f *VectorFile) FromSingleFile(path string) error
- func (f *VectorFile) ManifestEntry() ManifestInfo
- func (f *VectorFile) TypeName() string
- func (f *VectorFile) WriteTo(outputDir string) error
- type VectorFileCollection
- func (c *VectorFileCollection) DefaultOutputName() string
- func (c *VectorFileCollection) FromDirectory(_ string) error
- func (c *VectorFileCollection) FromMultipleFiles(paths []string) error
- func (c *VectorFileCollection) FromSingleFile(path string) error
- func (c *VectorFileCollection) ManifestEntry() ManifestInfo
- func (c *VectorFileCollection) TypeName() string
- func (c *VectorFileCollection) WriteTo(outputDir string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetSecret ¶
GetSecret returns the secret bound to a logical name for this block. The mapping from logical name to a stored secret is declared in the pipeline (spec/secrets.md §3.2); the value is injected by the worker (cloud) or CLI (local). Returns an error if the name was not provided.
func Input ¶
Input retrieves a typed file/directory input by name from Args. T must be a pointer to a type implementing FromInput.
func LoadParams ¶
LoadParams reads and parses params.yaml from the given base directory. Returns an empty map if the file does not exist or is empty.
func ReadBlockManifest ¶
ReadBlockManifest reads the block manifest to get output declarations. Checks SPADE_BLOCK_MANIFEST env var first, then block.yaml in base dir. Returns nil if no manifest found.
func Run ¶
func Run[O IntoOutput](handler func(*Args) (O, error))
Run executes a handler function as a Spade block. It loads inputs and params, calls the handler, and writes outputs. On any error it prints to stderr and exits.
func RunAt ¶
func RunAt[O IntoOutput](base string, handler func(*Args) (O, error)) error
RunAt executes a handler at a specific base path. Used for testing.
func RunNoOutput ¶
RunNoOutput executes a handler that produces no output.
func RunNoOutputAt ¶
RunNoOutputAt executes a no-output handler at a specific base path. Used for testing.
func ScanInputs ¶
func ScanInputs(base string) (map[string]InputEntry, error)
ScanInputs reads the inputs/ directory at the given base path and returns a map of input name to InputEntry.
func WriteOutputs ¶
func WriteOutputs(result IntoOutput, base string, manifestOutputs map[string]any) error
WriteOutputs writes handler output(s) to <base>/outputs/.
Types ¶
type Args ¶
type Args struct {
// contains filtered or unexported fields
}
Args holds merged parameters and inputs for handler consumption.
func BuildArgs ¶
BuildArgs constructs an Args struct from the given base path by loading params.yaml and scanning the inputs/ directory.
type BoolType ¶
type BoolType struct{}
BoolType is a manifest-only type representing a boolean parameter.
func (BoolType) DefaultOutputName ¶
func (BoolType) ManifestEntry ¶
func (BoolType) ManifestEntry() ManifestInfo
type Directory ¶
type Directory struct {
Path string
}
Directory represents a directory-based input or output.
func NewDirectory ¶
func (*Directory) DefaultOutputName ¶
func (*Directory) FromDirectory ¶
func (*Directory) FromMultipleFiles ¶
func (*Directory) FromSingleFile ¶
func (*Directory) ManifestEntry ¶
func (d *Directory) ManifestEntry() ManifestInfo
type ErrEmptyInputDir ¶
type ErrEmptyInputDir struct {
Name string
}
ErrEmptyInputDir is returned when an input subdirectory exists but contains no files.
func (*ErrEmptyInputDir) Error ¶
func (e *ErrEmptyInputDir) Error() string
type ErrInputNotFound ¶
type ErrInputNotFound struct {
Name string
}
ErrInputNotFound is returned when Args.Input references a name not present in inputs/.
func (*ErrInputNotFound) Error ¶
func (e *ErrInputNotFound) Error() string
type ErrParamNotFound ¶
type ErrParamNotFound struct {
Name string
}
ErrParamNotFound is returned when Args.Param references a name not present in params.yaml.
func (*ErrParamNotFound) Error ¶
func (e *ErrParamNotFound) Error() string
type ErrTypeMismatch ¶
ErrTypeMismatch is returned when an input value cannot be converted to the requested type.
func (*ErrTypeMismatch) Error ¶
func (e *ErrTypeMismatch) Error() string
type File ¶
type File struct {
Path string
}
File represents a generic single-file input or output.
func (*File) DefaultOutputName ¶
func (*File) FromDirectory ¶
func (*File) FromMultipleFiles ¶
func (*File) FromSingleFile ¶
func (*File) ManifestEntry ¶
func (f *File) ManifestEntry() ManifestInfo
type FileCollection ¶
type FileCollection struct {
Paths []string
}
FileCollection represents a collection of generic files.
func NewFileCollection ¶
func NewFileCollection(paths []string) FileCollection
func (*FileCollection) DefaultOutputName ¶
func (c *FileCollection) DefaultOutputName() string
func (*FileCollection) FromDirectory ¶
func (c *FileCollection) FromDirectory(_ string) error
func (*FileCollection) FromMultipleFiles ¶
func (c *FileCollection) FromMultipleFiles(paths []string) error
func (*FileCollection) FromSingleFile ¶
func (c *FileCollection) FromSingleFile(path string) error
func (*FileCollection) ManifestEntry ¶
func (c *FileCollection) ManifestEntry() ManifestInfo
func (*FileCollection) TypeName ¶
func (c *FileCollection) TypeName() string
func (*FileCollection) WriteTo ¶
func (c *FileCollection) WriteTo(outputDir string) error
type FromInput ¶
type FromInput interface {
FromSingleFile(path string) error
FromMultipleFiles(paths []string) error
FromDirectory(path string) error
}
FromInput constructs a typed value from raw filesystem input data.
type InputEntry ¶
type InputEntry struct {
Kind InputKind
Path string // populated for InputSingle
Paths []string // populated for InputMultiple
}
InputEntry represents a scanned input from the inputs/ directory.
type InputKind ¶
type InputKind int
InputKind distinguishes single-file from multi-file input entries.
type IntoOutput ¶
IntoOutput writes a typed value to an output subdirectory.
type JsonFile ¶
type JsonFile struct {
Path string
}
JsonFile represents a JSON data file.
func NewJsonFile ¶
func (*JsonFile) DefaultOutputName ¶
func (*JsonFile) FromDirectory ¶
func (*JsonFile) FromMultipleFiles ¶
func (*JsonFile) FromSingleFile ¶
func (*JsonFile) ManifestEntry ¶
func (f *JsonFile) ManifestEntry() ManifestInfo
type ManifestBuilder ¶
type ManifestBuilder struct {
// contains filtered or unexported fields
}
ManifestBuilder provides a fluent API for generating block manifest dictionaries.
func ManifestInput ¶
func ManifestInput[T SpadeType](b *ManifestBuilder, name string) *ManifestBuilder
ManifestInput declares an input on the builder using a SpadeType's manifest metadata.
func ManifestOutput ¶
func ManifestOutput[T SpadeType](b *ManifestBuilder, name string) *ManifestBuilder
ManifestOutput declares an output on the builder using a SpadeType's manifest metadata.
func NewManifestBuilder ¶
func NewManifestBuilder() *ManifestBuilder
NewManifestBuilder creates a new empty manifest builder.
func (*ManifestBuilder) Build ¶
func (b *ManifestBuilder) Build() map[string]any
Build returns the manifest as a map suitable for YAML serialization.
func (*ManifestBuilder) Description ¶
func (b *ManifestBuilder) Description(desc string) *ManifestBuilder
Description sets the block description.
type ManifestInfo ¶
type ManifestInfo struct {
TypeName string
Format string // empty string = not set
ItemType string // empty string = not set
}
ManifestInfo holds metadata returned by SpadeType.ManifestEntry().
type NumberType ¶
type NumberType struct{}
NumberType is a manifest-only type representing a numeric parameter.
func (NumberType) DefaultOutputName ¶
func (NumberType) DefaultOutputName() string
func (NumberType) ManifestEntry ¶
func (NumberType) ManifestEntry() ManifestInfo
func (NumberType) TypeName ¶
func (NumberType) TypeName() string
type Outputs ¶
type Outputs struct {
// contains filtered or unexported fields
}
Outputs is a collection of named outputs for handlers that produce multiple results.
func (*Outputs) Add ¶
func (o *Outputs) Add(name string, value IntoOutput)
Add appends a named output to the collection.
func (*Outputs) DefaultOutputName ¶
DefaultOutputName returns a sentinel value for internal routing.
func (*Outputs) ManifestEntry ¶
func (o *Outputs) ManifestEntry() ManifestInfo
ManifestEntry returns a sentinel ManifestInfo.
type RasterFile ¶
type RasterFile struct {
Path string
}
RasterFile represents a raster data file (e.g., GeoTIFF).
func NewRasterFile ¶
func NewRasterFile(path string) RasterFile
func (*RasterFile) DefaultOutputName ¶
func (f *RasterFile) DefaultOutputName() string
func (*RasterFile) FromDirectory ¶
func (f *RasterFile) FromDirectory(_ string) error
func (*RasterFile) FromMultipleFiles ¶
func (f *RasterFile) FromMultipleFiles(paths []string) error
func (*RasterFile) FromSingleFile ¶
func (f *RasterFile) FromSingleFile(path string) error
func (*RasterFile) ManifestEntry ¶
func (f *RasterFile) ManifestEntry() ManifestInfo
func (*RasterFile) TypeName ¶
func (f *RasterFile) TypeName() string
func (*RasterFile) WriteTo ¶
func (f *RasterFile) WriteTo(outputDir string) error
type RasterFileCollection ¶
type RasterFileCollection struct {
Paths []string
}
RasterFileCollection represents a collection of raster data files.
func NewRasterFileCollection ¶
func NewRasterFileCollection(paths []string) RasterFileCollection
func (*RasterFileCollection) DefaultOutputName ¶
func (c *RasterFileCollection) DefaultOutputName() string
func (*RasterFileCollection) FromDirectory ¶
func (c *RasterFileCollection) FromDirectory(_ string) error
func (*RasterFileCollection) FromMultipleFiles ¶
func (c *RasterFileCollection) FromMultipleFiles(paths []string) error
func (*RasterFileCollection) FromSingleFile ¶
func (c *RasterFileCollection) FromSingleFile(path string) error
func (*RasterFileCollection) ManifestEntry ¶
func (c *RasterFileCollection) ManifestEntry() ManifestInfo
func (*RasterFileCollection) TypeName ¶
func (c *RasterFileCollection) TypeName() string
func (*RasterFileCollection) WriteTo ¶
func (c *RasterFileCollection) WriteTo(outputDir string) error
type SpadeType ¶
type SpadeType interface {
TypeName() string
DefaultOutputName() string
ManifestEntry() ManifestInfo
}
SpadeType provides metadata about a Spade type for manifest generation and output naming.
type StringType ¶
type StringType struct{}
StringType is a manifest-only type representing a string parameter.
func (StringType) DefaultOutputName ¶
func (StringType) DefaultOutputName() string
func (StringType) ManifestEntry ¶
func (StringType) ManifestEntry() ManifestInfo
func (StringType) TypeName ¶
func (StringType) TypeName() string
type TabularFile ¶
type TabularFile struct {
Path string
}
TabularFile represents a tabular data file (e.g., CSV).
func NewTabularFile ¶
func NewTabularFile(path string) TabularFile
func (*TabularFile) DefaultOutputName ¶
func (f *TabularFile) DefaultOutputName() string
func (*TabularFile) FromDirectory ¶
func (f *TabularFile) FromDirectory(_ string) error
func (*TabularFile) FromMultipleFiles ¶
func (f *TabularFile) FromMultipleFiles(paths []string) error
func (*TabularFile) FromSingleFile ¶
func (f *TabularFile) FromSingleFile(path string) error
func (*TabularFile) ManifestEntry ¶
func (f *TabularFile) ManifestEntry() ManifestInfo
func (*TabularFile) TypeName ¶
func (f *TabularFile) TypeName() string
func (*TabularFile) WriteTo ¶
func (f *TabularFile) WriteTo(outputDir string) error
type TabularFileCollection ¶
type TabularFileCollection struct {
Paths []string
}
TabularFileCollection represents a collection of tabular data files.
func NewTabularFileCollection ¶
func NewTabularFileCollection(paths []string) TabularFileCollection
func (*TabularFileCollection) DefaultOutputName ¶
func (c *TabularFileCollection) DefaultOutputName() string
func (*TabularFileCollection) FromDirectory ¶
func (c *TabularFileCollection) FromDirectory(_ string) error
func (*TabularFileCollection) FromMultipleFiles ¶
func (c *TabularFileCollection) FromMultipleFiles(paths []string) error
func (*TabularFileCollection) FromSingleFile ¶
func (c *TabularFileCollection) FromSingleFile(path string) error
func (*TabularFileCollection) ManifestEntry ¶
func (c *TabularFileCollection) ManifestEntry() ManifestInfo
func (*TabularFileCollection) TypeName ¶
func (c *TabularFileCollection) TypeName() string
func (*TabularFileCollection) WriteTo ¶
func (c *TabularFileCollection) WriteTo(outputDir string) error
type VectorFile ¶
type VectorFile struct {
Path string
}
VectorFile represents a vector data file (e.g., GeoJSON).
func NewVectorFile ¶
func NewVectorFile(path string) VectorFile
func (*VectorFile) DefaultOutputName ¶
func (f *VectorFile) DefaultOutputName() string
func (*VectorFile) FromDirectory ¶
func (f *VectorFile) FromDirectory(_ string) error
func (*VectorFile) FromMultipleFiles ¶
func (f *VectorFile) FromMultipleFiles(paths []string) error
func (*VectorFile) FromSingleFile ¶
func (f *VectorFile) FromSingleFile(path string) error
func (*VectorFile) ManifestEntry ¶
func (f *VectorFile) ManifestEntry() ManifestInfo
func (*VectorFile) TypeName ¶
func (f *VectorFile) TypeName() string
func (*VectorFile) WriteTo ¶
func (f *VectorFile) WriteTo(outputDir string) error
type VectorFileCollection ¶
type VectorFileCollection struct {
Paths []string
}
VectorFileCollection represents a collection of vector data files.
func NewVectorFileCollection ¶
func NewVectorFileCollection(paths []string) VectorFileCollection
func (*VectorFileCollection) DefaultOutputName ¶
func (c *VectorFileCollection) DefaultOutputName() string
func (*VectorFileCollection) FromDirectory ¶
func (c *VectorFileCollection) FromDirectory(_ string) error
func (*VectorFileCollection) FromMultipleFiles ¶
func (c *VectorFileCollection) FromMultipleFiles(paths []string) error
func (*VectorFileCollection) FromSingleFile ¶
func (c *VectorFileCollection) FromSingleFile(path string) error
func (*VectorFileCollection) ManifestEntry ¶
func (c *VectorFileCollection) ManifestEntry() ManifestInfo
func (*VectorFileCollection) TypeName ¶
func (c *VectorFileCollection) TypeName() string
func (*VectorFileCollection) WriteTo ¶
func (c *VectorFileCollection) WriteTo(outputDir string) error