scope

package
v1.18.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

package: scope / config type: struct job: a resolution-free Section over a flat map, for known values and tests limits: flat leaves plus literal arrays; cfgSection resolves env()/vault() (-> config)

This file provides Literal: a Section whose values are already-known literals, with no env()/vault() resolution. The config-driven handout (config.cfgSection) is unexported, so an adapter test — which per the architecture must drive its real counterpart through the port's factory, not construct it directly — uses Literal to build the section it hands its constructor. LiteralArray adds array-valued keys (a backend's "keys" list, an endpoint's "auth" backends) for the same reason: a factory a test cannot reach any other way.

package: scope / config type: interface job: the navigable, lazily-resolved handoff between the composition root and one adapter limits: interfaces only; the concrete tree + env()/vault() resolution live in config (-> config)

Narrowing is by containment: a sibling's settings and another port's secrets are simply not in the object an adapter was handed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Section

type Section interface {
	// GetSection descends; a missing key yields an empty Section, never nil.
	GetSection(key string) Section

	// Get resolves the leaf at key, expanding an env()/vault() reference on demand, so a
	// rotating secret is fetched at use. The source (literal, env(), vault())
	// is chosen by config and opaque here. It errors when the key is absent, or
	// when resolving its source (an unset env var, an unreachable vault) fails; an
	// adapter judges required-ness from that error, or checks HasValue first.
	Get(ctx context.Context, key string) (string, error)

	// GetArray returns the elements of an array-valued key, each wrapped as a
	// Section. A missing key or a non-array value yields an empty slice. Config
	// arrays are always arrays of objects (a stack's layers, a partition's shards,
	// the endpoints, the accounts), so callers range over the result.
	GetArray(key string) []Section

	// HasValue reports whether key is present as a leaf value — not a nested
	// section and not an array. Use it to make an optional setting default cleanly.
	HasValue(key string) bool

	// HasSection reports whether key is present as a nested section.
	HasSection(key string) bool

	// HasArray reports whether key is present as an array.
	HasArray(key string) bool

	// HasKey reports whether a key is present at all.
	HasKey(key string) bool

	// Keys lists the present keys in this section, resolving nothing. It is for
	// structural iteration (e.g. a list of configured endpoints).
	Keys() []string
}

Section is one instance's slice of the launch config, reaching only inward.

func Literal

func Literal(values map[string]string) Section

Literal wraps a flat map of known values as a Section. Values resolve to themselves; there are no nested sections. Equivalent to LiteralArray(values, nil).

func LiteralArray added in v1.18.1

func LiteralArray(values map[string]string, arrays map[string][]Section) Section

LiteralArray is Literal plus array-valued keys, each already built as Sections — typically nested Literal calls. Config arrays are always arrays of objects, matching GetArray's own contract.

Jump to

Keyboard shortcuts

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