pack

package
v1.0.48403 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package pack merges a directory tree of YAML files into a single YAML document.

The merge rules are consistent across all CircleCI YAML packing (config and orbs):

  • Files at the pack root are merged at the top level of the output.
  • Subdirectory names become top-level YAML keys; files inside become entries under that key, keyed by filename without extension.
  • Deeper subdirectories are organisational only: their files join the top-level section their ancestor opened, so commands/aws/login.yml becomes commands.login. Two files that would claim the same key are an error.
  • Files whose names begin with "@" are merged at the current directory level rather than nested under a key (used for base files like @orb.yml).
  • Dotfiles and non-YAML files are skipped.
  • Packing a single file round-trips it through the YAML parser (normalising formatting) and returns the result.
  • Unquoted yes/no/on/off are booleans, as the CircleCI config compiler reads them, not strings as YAML 1.2 would.
  • A YAML anchor defined in one file may be aliased from any other file in the tree; the alias is replaced by the anchored value in the output.
  • Output is indented with four spaces, matching the 0.1.x CLI byte for byte.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*options)

Option configures a Pack call.

func WithIncludes

func WithIncludes() Option

WithIncludes enables resolution of `<< include(file) >>` directives: each such directive in a scalar is replaced with the contents of the referenced file, resolved relative to the pack root. This is an orb-authoring feature — config packing does not use it. See resolveIncludes.

type Warning

type Warning struct {
	// Path is the file the problem is in.
	Path string
	// Line is the 1-indexed line within Path.
	Line int
	// Message describes the problem and what to do about it.
	Message string
}

Warning is a problem found while packing that does not stop the pack. Packing is a mechanical merge, so anything it notices about the *meaning* of the input is advisory: the merge still produces output.

func Pack

func Pack(rootPath string, opts ...Option) (string, []Warning, error)

Pack reads all YAML files under rootPath and merges them into a single YAML document. If rootPath is a single file it is parsed and re-serialised.

The returned warnings describe anything noticed about the input that is suspicious but not fatal. They are ordered by the lexical file walk, so they are stable across runs, and callers that have nowhere to show them may discard them.

func (Warning) String

func (w Warning) String() string

String renders the warning with its location leading, in the file:line: form editors and terminals turn into a clickable link.

Jump to

Keyboard shortcuts

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