volumes

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 15, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package volumes resolves Tekton TaskSpec.Volumes into host directories the docker backend can bind-mount.

Four volume kinds are supported:

emptyDir   fresh per-Task tmpdir under the run cache
hostPath   literal host path (path mode honored only as diagnostic)
configMap  bytes from a Store (file-backed dir + inline overrides)
secret     same, with separate Store

The validator rejects any other kind before this package sees it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MaterializeForTask

func MaterializeForTask(
	taskName string,
	vs []tektontypes.Volume,
	baseDir string,
	cm, sec *Store,
) (map[string]string, error)

MaterializeForTask resolves every Volume in spec into a host directory and returns map[volumeName] -> hostPath. baseDir is a per-task scratch dir under which emptyDir / configMap / secret subdirs are created.

Types

type Store

type Store struct {
	Dir    string                       // <root>/<name>/<key> per source
	Inline map[string]map[string]string // name -> key -> value
	Bundle map[string]map[string][]byte // name -> key -> bytes
}

Store is a configMap-or-secret bytes-source.

Lookup precedence (highest first):

  1. Inline overrides (Add) — typically from `--configmap` / `--secret`.
  2. On-disk Dir layout — typically from `--configmap-dir` / `--secret-dir`.
  3. Bundle-loaded bytes (LoadBytes) — typically from `kind: ConfigMap` / `kind: Secret` resources found in the `-f` YAML stream.

Each layer is checked per (name, key); a key present at a higher layer hides the same key at lower layers.

func NewStore

func NewStore(dir string) *Store

NewStore returns an empty Store rooted at dir. Inline overrides may be added via Add and bundle-loaded data via LoadBytes. dir may be empty (no on-disk layout).

func (*Store) Add

func (s *Store) Add(name, key, value string)

Add records an inline override; later Lookup calls for (name, key) return the inline value instead of consulting the on-disk dir.

func (*Store) LoadBytes added in v1.5.0

func (s *Store) LoadBytes(name string, bytesByKey map[string][]byte)

LoadBytes records bundle-loaded bytes for every key under `name`. These sit at the lowest precedence layer: a key present here is shadowed by the same key in either the on-disk Dir layout or the inline overrides.

Calling LoadBytes twice for the same name is a merge (later keys overwrite earlier ones); duplicate-name detection happens at the loader layer, not here.

func (*Store) Reset added in v1.5.0

func (s *Store) Reset()

Reset clears every Inline and Bundle entry, leaving the Dir layout (which is on-disk state, not part of the in-memory mutable surface) untouched. Intended for test harnesses that share one Store across a table of subtests and need per-subtest isolation without rebuilding the Backend that holds a pointer to this Store.

Resetting is destructive of in-memory state (Inline + Bundle); the Dir layer is preserved. Callers that want to keep the existing entries must build a fresh Store with NewStore instead.

Intended for test use only.

func (*Store) Resolve

func (s *Store) Resolve(name string) (map[string][]byte, error)

Resolve returns the bytes for every key declared by source `name`. Layers are merged with this precedence (higher beats lower):

  1. Inline (Add)
  2. On-disk Dir
  3. Bundle (LoadBytes)

An error is returned only when no layer produced any keys.

Jump to

Keyboard shortcuts

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