secrets

package
v0.10.5 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package secrets is EXPERIMENTAL — safe API key resolution for AXIS. It is subordinate to observed state and emits warnings automatically.

Package secrets is EXPERIMENTAL — safe API key resolution for AXIS. It is subordinate to observed state and emits warnings automatically.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("api key not found: neither env var nor file contained a value")

ErrNotFound is returned by Resolve when neither the environment variable nor the file path yields a non-empty value.

Functions

func IsConfigured

func IsConfigured(envVar, filePath string) bool

IsConfigured returns true if Resolve would succeed without error. It is a convenience wrapper for callers that only need to check presence.

func Resolve

func Resolve(envVar, filePath string) (string, error)

Resolve returns an API key by probing envVar then filePath.

  • If envVar is non-empty and the named environment variable is set and non-empty, its value is returned immediately.
  • If filePath is non-empty and the file exists and contains non-empty content (after trimming whitespace), that content is returned.
  • Otherwise ErrNotFound is returned.

File read errors (permissions, etc.) are surfaced as wrapped errors so the caller can distinguish "not configured" from "configured but broken". The error message never contains the key value.

func ResolveOrEmpty

func ResolveOrEmpty(envVar, filePath string) (string, error)

ResolveOrEmpty calls Resolve and returns an empty string instead of an error when the key is simply not configured (ErrNotFound). File read errors are still surfaced so misconfigured paths are not silently ignored.

Use this when missing credentials should degrade gracefully (e.g. skipping a cloud provider) rather than hard-failing.

Types

This section is empty.

Jump to

Keyboard shortcuts

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