expand

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package expand substitutes environment references into build tag, arg and annotation templates. The syntax is a small, strict subset of the shell's, so every template either expands as written or fails:

${VAR}                 the value of VAR; unset is an error
${VAR:-default}        VAR, or default when VAR is unset or empty
${VAR:offset:length}   a substring of VAR (${GITHUB_SHA:0:7})
$$                     a literal $

Any other $ is an error rather than a literal, so a forgotten brace fails the build instead of publishing a tag with a $ in it. PATCHY_TIMESTAMP is a built-in: a UTC yyyymmddhhmmss fixed once per run (Timestamp).

Everything here is pure; the caller supplies the lookup.

Index

Constants

View Source
const TimestampLayout = "20060102150405"

TimestampLayout is the built-in's format: UTC yyyymmddhhmmss.

View Source
const TimestampVar = "PATCHY_TIMESTAMP"

TimestampVar is the built-in run timestamp's name.

Variables

This section is empty.

Functions

func Expand

func Expand(s string, lookup Lookup) (string, error)

Expand substitutes every reference in s.

func Timestamp

func Timestamp(lookup Lookup, now time.Time) (string, error)

Timestamp resolves the run's PATCHY_TIMESTAMP once: an explicit PATCHY_TIMESTAMP wins (so several jobs can share one value), else SOURCE_DATE_EPOCH (so a rebuild of the same commit stamps the same tag), else now. The result is always UTC yyyymmddhhmmss.

Types

type Lookup

type Lookup func(name string) (value string, ok bool)

Lookup resolves one variable; ok is false when it is unset.

func WithBuiltins

func WithBuiltins(lookup Lookup, timestamp string) Lookup

WithBuiltins layers the built-in PATCHY_TIMESTAMP over lookup.

Jump to

Keyboard shortcuts

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