casemap

package
v1.223.0 Latest Latest
Warning

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

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

Documentation

Overview

Package casemap provides utilities for preserving original case of YAML map keys. Viper automatically lowercases all YAML map keys, which breaks case-sensitive configurations like environment variables (e.g., GITHUB_TOKEN becomes github_token). This package extracts original case from raw YAML before Viper processes it, allowing restoration of original key casing when needed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CaseMap

type CaseMap map[string]string

CaseMap stores lowercase -> original case mappings for YAML keys. Use this to restore original case after Viper lowercases map keys.

func CollectEnvKeysRecursive added in v1.222.0

func CollectEnvKeysRecursive(rawYAML []byte) (CaseMap, error)

CollectEnvKeysRecursive walks the raw YAML and returns a CaseMap of lowercase->original for every key found under any `env:` mapping at any depth: the top-level `env:`, plus custom-command and step-level `env:` blocks. Viper lowercases map keys, but environment variable names are case-sensitive, so this lets nested env sections (e.g. commands[].steps[].env) be restored the same way the top-level `env:` already is. Command-level `env:` written as a list of {key, value} pairs is unaffected by Viper and is intentionally not collected here.

type CaseMaps

type CaseMaps struct {
	// contains filtered or unexported fields
}

CaseMaps holds all case mappings for different config paths.

func ExtractFromYAML

func ExtractFromYAML(rawYAML []byte, paths []string) (*CaseMaps, error)

ExtractFromYAML extracts case mappings from raw YAML for specified paths. Paths is a list of dot-separated paths, e.g., ["env", "auth.identities"].

func New

func New() *CaseMaps

New creates a new CaseMaps instance.

func (*CaseMaps) ApplyCase

func (c *CaseMaps) ApplyCase(path string, lowercased map[string]string) map[string]string

ApplyCase returns a new map with keys converted to their original case. Keys not in the case map are returned unchanged.

func (*CaseMaps) Get

func (c *CaseMaps) Get(path string) CaseMap

Get retrieves the case map for a given path.

func (*CaseMaps) Set

func (c *CaseMaps) Set(path string, m CaseMap)

Set stores a case map for a given path.

Jump to

Keyboard shortcuts

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