envs

package
v0.27.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2026 License: Apache-2.0 Imports: 6 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrParse = errors.New("failed to parse environment variables")
View Source
var ErrParseWithPrefix = errors.New("failed to parse environment variables for the given prefix")

Functions

func IsCloud

func IsCloud() bool

func IsCommunity added in v0.12.5

func IsCommunity() bool

func IsDevelopment added in v0.14.0

func IsDevelopment() bool

func IsEnterprise

func IsEnterprise() bool

func IsEnterpriseOrCloud

func IsEnterpriseOrCloud() bool

func Parse added in v0.13.3

func Parse[T any]() (*T, error)

Parse parses the environment variables.

This function uses the envconfig package as its default backend, so it requires the struct to be annotated with the envconfig tags. Check the envconfig documentation for more information.

The T generic parameter must be a struct with the fields annotated with the envconfig tags, that will be returned with the values parsed from the environment variables.

func ParseWithPrefix added in v0.13.0

func ParseWithPrefix[T any](prefix string) (*T, error)

ParseWithPrefix parses the environment variables for the a given prefix.

This function uses the envconfig package as its default backend, so it requires the struct to be annotated with the envconfig tags. Check the envconfig documentation for more information.

The T generic parameter must be a struct with the fields annotated with the envconfig tags, that will be returned with the values parsed from the environment variables.

Types

type Backend

type Backend interface {
	Get(key string) string
	Process(prefix string, spec interface{}) error
}

Backend is an interface for any sort of underlying key/value store.

var DefaultBackend Backend

DefaultBackend define the backend to be used to get environment variables.

type Edition

type Edition string
const (
	Community  Edition = "community"
	Enterprise Edition = "enterprise"
	Cloud      Edition = "cloud"
)

func CurrentEdition

func CurrentEdition() Edition

CurrentEdition returns the resolved edition, panicking on an unrecognized value so a misconfigured instance fails rather than silently running as community. Entrypoints should call ResolveEdition at startup to surface the error cleanly; this panic is a last-resort invariant for the predicates below.

func ResolveEdition

func ResolveEdition() (Edition, error)

ResolveEdition reads SHELLHUB_EDITION, normalizes it (trim + lowercase) and defaults to Community when empty. It returns an error for any unrecognized value so entrypoints can validate the edition once at startup and fail fast with a clean message instead of relying on CurrentEdition's lazy panic.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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