config

package
v0.0.0-...-54f4ef6 Latest Latest
Warning

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

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

Documentation

Overview

Package config loads HCL configuration and uses that to construct the cache backend, and proxy strategies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InjectEnvars

func InjectEnvars(schema *hcl.AST, config *hcl.AST, prefix string, vars map[string]string)

InjectEnvars resolves environment variables against the config AST in two passes:

  1. Schema-driven injection: walks the schema and for each attribute not already present in the config, checks for a corresponding environment variable and inserts it as a new attribute. Environment variable names are derived from the path to the attribute: prefix + block names + attribute name, joined with "_", uppercased, hyphens replaced with "_". E.g. prefix="CACHEW", path=["scheduler", "concurrency"] resolves to "CACHEW_SCHEDULER_CONCURRENCY".
  2. Placeholder expansion: walks the resulting AST and substitutes `${VAR}` references inside `*hcl.String` and `*hcl.Heredoc` attribute values using `os.Expand` semantics (unset names collapse to empty). This covers placeholders the operator wrote into the config file directly, including those inside heredocs (e.g. an OPA policy block).

Both passes operate on the same `vars` map. Pass (1) only ever inserts attributes that were absent, so it cannot overwrite operator-written values that pass (2) then expands.

func Load

Load HCL configuration and use that to construct the cache backend, and proxy strategies. It returns an http.Handler that wraps mux — any loaded strategies that implement strategy.Interceptor are applied as middleware before ServeMux route matching, so that they can inspect r.RequestURI rather than the path-only r.URL.Path.

func Schema

func Schema[GlobalConfig any](cr *cache.Registry, mr *metadatadb.Registry, sr *strategy.Registry) *hcl.AST

Schema returns the configuration file schema.

func Split

func Split[GlobalConfig any](ast *hcl.AST) (global, providers *hcl.AST)

Split configuration into global config and provider-specific config.

At this point we don't know what config the providers require, so we just pull out the global config and assume everything else is for the providers.

Types

This section is empty.

Jump to

Keyboard shortcuts

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