Skip to content

package runner

import "github.com/cloudboss/unobin/pkg/runner"

Package runner is the CLI scaffolding every compiled factory binary links into. The generated `main.go` stays tiny: it embeds the factory-specific constants and calls Run with them.

Constants

const EnvVarPrefix = "UB_INPUT_"

EnvVarPrefix is the prefix unobin reads fallback input values from. An env var like `UB_INPUT_cluster_name=web-prod` sets the `cluster-name` input only when the stack file omits it, with snake case converted to kebab case.

Functions

func Run

func Run(info Info)

Run builds the cobra command tree and executes it. The process exits with status code 1 on error.

Types

type Format

type Format string

Format is the wire form a subcommand emits. The text form is the existing human-facing rendering; json emits NDJSON envelopes (one per line); unobin emits the same envelope shape encoded as UB literals, one per line.

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat resolves the value of the --output flag. An empty string maps to text so commands with the flag-default of "" pick up the same behavior as commands without the flag.

type Info

type Info struct {
    FactoryName     string
    FactoryVersion  string
    ContentRevision string
    FactoryBody     *syntax.FactoryBody
    LibraryPath     string
    Libraries       map[string]*runtime.Library

    // UnobinVersion is the unobin version the factory was compiled
    // against, stamped at link time the way FactoryVersion is. Run
    // refuses to start when the binary links a different one; empty
    // (built outside the CLI) checks nothing.
    UnobinVersion string
}

Info bundles everything a generated factory binary passes into Run. FactoryBody is the generated factory syntax body. LibraryPath is the binary's library-path identity (the same form Go libraries use); the operator's stack file asserts the same value under `factory.pin.library-path`. An empty LibraryPath disables that identity check.