envutil

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package envutil provides shared helpers for building process environment variable slices from os.Environ() plus a caller-supplied override map.

It is intentionally small and depends only on the standard library so that any sub-package of internal/worker can import it without creating a cycle.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(overrides map[string]string) []string

Build constructs a process environment slice by starting from os.Environ() and applying overrides on top. Keys present in overrides take precedence over the inherited environment. When overrides is empty the raw os.Environ() slice is returned directly (no allocation).

The output format is "KEY=VALUE", matching exec.Cmd.Env expectations. Output order is non-deterministic (map iteration); callers must not rely on any specific ordering.

func BuildWithUnset

func BuildWithUnset(overrides map[string]string, unset map[string]bool) []string

BuildWithUnset is like Build but additionally removes every key in unset from the resulting environment — including keys inherited from os.Environ() and keys supplied via overrides. This implements OpenJD's openjd_unset_env directive, where a variable must be absent from a subsequent action's environment even if it was set by the worker's own environment or by a static environment Variables entry.

Removal is applied after overrides, so a key present in both overrides and unset is removed. When unset is empty the call is equivalent to Build.

The output format is "KEY=VALUE"; output order is non-deterministic.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL