Documentation
¶
Overview ¶
Package config loads HCL configuration and uses that to construct the cache backend, and proxy strategies.
Index ¶
- func InjectEnvars(schema *hcl.AST, config *hcl.AST, prefix string, vars map[string]string)
- func Load(ctx context.Context, cr *cache.Registry, mr *metadatadb.Registry, ...) (http.Handler, []strategy.Readier, error)
- func Schema[GlobalConfig any](cr *cache.Registry, mr *metadatadb.Registry, sr *strategy.Registry) *hcl.AST
- func Split[GlobalConfig any](ast *hcl.AST) (global, providers *hcl.AST)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InjectEnvars ¶
InjectEnvars resolves environment variables against the config AST in two passes:
- 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".
- 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 ¶
func Load( ctx context.Context, cr *cache.Registry, mr *metadatadb.Registry, sr *strategy.Registry, ast *hcl.AST, mux *http.ServeMux, vars map[string]string, ) (http.Handler, []strategy.Readier, error)
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.
Types ¶
This section is empty.