Documentation
¶
Overview ¶
mig_run_spec.go separates spec file handling from mig run execution.
This file contains Build, which parses YAML/JSON spec files and compiles Hydra file-record entries (in/out/home) into canonical shortHash:dst form. Specs use a single canonical shape:
- steps[] array with one entry per step (even single-step runs)
- global build gate policy under build_gate
Spec parsing includes validation and error handling for missing files. Isolating spec handling from execution flow enables focused testing of file I/O and parsing logic without coupling to HTTP submission.
mig_run_spec_bundle.go provides archive building and upload primitives for the Hydra file-record compiler.
buildSourceArchive creates deterministic tar.gz payloads from files and directories. uploadSpecBundle uploads payloads to the server's spec-bundle store with built-in deduplication by content hash.
mig_run_spec_hydra.go implements the Hydra file-record compiler for CLI spec processing.
The compiler resolves authoring-form in/out/home/tmp entries into canonical shortHash:dst form suitable for contract validation and server submission.
Authoring input formats:
- in: src:dst (right-biased split, dst treated as /in-relative)
- out: src:dst (right-biased split, dst treated as /out-relative)
- home: src:dst{:ro} (right-biased split, dst is $HOME-relative)
- tmp: src:dst (right-biased split, dst treated as /tmp-relative or /tmp absolute)
After compilation, entries are rewritten to:
- in: shortHash:/in/dst
- out: shortHash:/out/dst
- home: shortHash:dst{:ro}
- tmp: shortHash:/tmp/dst
Index ¶
- func Build(ctx context.Context, base *url.URL, client *http.Client, specFile string, ...) ([]byte, error)
- func BuildSelected(ctx context.Context, base *url.URL, client *http.Client, specFile string, ...) ([]byte, error)
- func Load(ctx context.Context, base *url.URL, client *http.Client, path string) (json.RawMessage, error)
- func Normalize(ctx context.Context, base *url.URL, client *http.Client, data []byte, ...) (json.RawMessage, error)
- func ValidateLocal(data []byte, specBaseDir string) (json.RawMessage, error)
- func ValidateLocalFile(path string) (json.RawMessage, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
func Build( ctx context.Context, base *url.URL, client *http.Client, specFile string, migEnvs []string, migImage string, retain bool, migCommand string, ) ([]byte, error)
Build loads a spec from file (YAML or JSON) and merges it with CLI flag overrides. CLI flags take precedence over spec file values. Returns raw JSON bytes.
Processing order:
- Load spec file (YAML or JSON format) if provided
- Preprocess: resolve !include composition, image env, envs expansion
- Compile Hydra records: in/out/home authoring entries → canonical shortHash:dst form
- Apply CLI flag overrides (higher precedence than spec file) to top-level fields
- Validate the current spec contract
Returns nil payload when neither spec file nor CLI overrides are provided.
Multi-step semantics (steps[] array):
- Each entry in steps[] represents a sequential transformation step.
- All steps share the same repository and global build_gate policy.
- The CLI preserves steps[] without modification; image/command overrides do not apply when len(steps) > 1.
- The server copies steps[] indexes into jobs.next_id and diffs.next_id.
func BuildSelected ¶
func Load ¶
func Load(ctx context.Context, base *url.URL, client *http.Client, path string) (json.RawMessage, error)
Load loads a spec from a file path or stdin when path is "-".
func ValidateLocal ¶
func ValidateLocal(data []byte, specBaseDir string) (json.RawMessage, error)
ValidateLocal validates a JSON/YAML spec without network bundle compilation.
func ValidateLocalFile ¶
func ValidateLocalFile(path string) (json.RawMessage, error)
ValidateLocalFile validates a JSON/YAML spec after local-only normalization.
Types ¶
This section is empty.