Documentation
¶
Overview ¶
Package cisinkwrite emits CI variable-set and step-output exports in the dialect of the active CI provider. It is the WRITER half of the CI-export pattern; its sibling ci-sink-go is the READER that detects the provider and resolves the cisink.Sink this package writes into.
Each provider exports variables and outputs through a different mechanism:
- GitHub Actions appends `NAME=value` (with heredoc framing for multiline values) to the files named by $GITHUB_ENV and $GITHUB_OUTPUT.
- GitLab CI has no per-step env-append file; the portable channel is a dotenv file (`NAME=value` lines) declared via artifacts:reports:dotenv.
- Bitbucket Pipelines exports via shell `export NAME=value` lines on stdout.
- Buildkite sets build metadata via `buildkite-agent meta-data set` and exports env via shell `export NAME=value` lines on stdout.
This package writes the *bytes* of each dialect to an io.Writer; it never shells out (Buildkite's metadata command is emitted as the line a caller runs or appends). That keeps it pure stdlib + errors-go and hermetically testable.
The model is borealis-style (BOREALIS.md §3.5): New(required…, opts…) / FromConfig(cfg); errors are typed and code-carrying via errors-go.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Provider, when non-empty, pins the emit dialect. Valid values are the
// cisink.Provider string constants ("github"/"gitlab"/"bitbucket"/
// "buildkite"). Empty means the caller must supply a sink via
// [WithSink] (typically the one ci-sink-go's reader resolved), and an
// unconfigured emit is then a codeUnsupported error.
Provider string `yaml:"provider"`
}
Config is the typed, shikumi-loadable knob surface for a Writer. It exists so a tool that already loads a config file can pin the dialect declaratively rather than threading a Provider through code.
type Option ¶
type Option func(*Writer)
Option configures a Writer during New / FromSink. Options apply in order; a later option of the same kind overrides an earlier one.
func WithSink ¶
WithSink overrides the destination cisink.Sink of the writer. The Sink's Provider selects the dialect, and its file paths are informational only — the emitted bytes go to the configured io.Writer, never to the Sink's files directly (the caller owns file opening, so the writer stays pure and testable). The default sink (when constructed via New without this option) is an empty Sink with cisink.ProviderUnknown, which makes every emit a codeUnsupported error until a real sink is supplied.
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer emits CI exports in the dialect of its cisink.Sink's provider to a caller-supplied io.Writer. Construct it with New (provider + io.Writer) or FromSink (a resolved sink + io.Writer). A Writer is stateless across emits and safe to reuse.
func FromConfig ¶
FromConfig constructs a Writer from an already-loaded Config and a destination (§3.5). It does NOT call shikumi.Load — the caller loads cfg once at main and hands this the sub-struct. When cfg.Provider is empty the writer is constructed for cisink.ProviderUnknown; supply WithSink (e.g. from a ci-sink-go read) to give it a real dialect.
func FromSink ¶
FromSink constructs a Writer from an already-resolved cisink.Sink (the value ci-sink-go's reader produces) and a destination. It is the canonical reader→writer hand-off:
ctx, _ := cisink.Read() w := cisinkwrite.FromSink(ctx.Sink, os.Stdout)
func New ¶
New constructs a Writer that emits the dialect for provider p to out (§3.5 Construct shape: New(required…, opts…)). The required positional args are the provider and the destination; options refine the sink (e.g. to carry file paths through). For most callers FromSink is more direct.
func (*Writer) SetOutput ¶
SetOutput emits an export that makes name=value available as a named step output (the KindOutput channel). Providers without a distinct output channel (GitLab/Bitbucket/Buildkite) fall back to their variable dialect.
func (*Writer) SetVariable ¶
SetVariable emits an export that makes name=value available as an environment variable to subsequent steps, in the active provider's dialect. It is the most common verb (the KindEnv channel).