casemap

package
v1.210.0-test.21 Latest Latest
Warning

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

Go to latest
Published: Mar 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.

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