Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrParse = errors.New("failed to parse environment variables")
ErrParse is joined with the backend's error when Parse fails, so a caller can tell a configuration problem from anything else with errors.Is.
var ErrParseWithPrefix = errors.New("failed to parse environment variables for the given prefix")
ErrParseWithPrefix is joined with the backend's error when ParseWithPrefix fails, so a caller can tell a configuration problem from anything else with errors.Is.
Functions ¶
func AnnouncementFor ¶
AnnouncementFor returns the SSH connection banner for the given edition.
func IsCloud ¶
func IsCloud() bool
IsCloud reports whether this instance runs the hosted edition. Billing and namespace limits are the features that turn on here and nowhere else.
func IsCommunity ¶ added in v0.12.5
func IsCommunity() bool
IsCommunity reports whether this instance runs the community edition. It panics on an unrecognized SHELLHUB_EDITION, as CurrentEdition does.
func IsDevelopment ¶ added in v0.14.0
func IsDevelopment() bool
IsDevelopment reports whether SHELLHUB_ENV is "development". It gates developer conveniences only; never use it to relax a security decision, as the variable is attacker-controlled in any deployment that passes the environment through.
func IsEnterprise ¶
func IsEnterprise() bool
IsEnterprise reports whether this instance runs the enterprise edition, which is not the same question as "may it use a paid feature" — see IsEnterpriseOrCloud.
func IsEnterpriseOrCloud ¶
func IsEnterpriseOrCloud() bool
IsEnterpriseOrCloud reports whether the paid feature set is available. This is the check a feature gate wants, so that a feature added for cloud stays available to enterprise.
func Parse ¶ added in v0.13.3
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
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 ¶
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
Edition is the ShellHub edition an instance runs as. It decides which features the server exposes, so it is read at startup and never per request.
const ( // Community is the open-source edition, and the edition an instance falls back to when // SHELLHUB_EDITION is unset. Community Edition = "community" // Enterprise is the self-hosted paid edition, gated by a licence file. Enterprise Edition = "enterprise" // Cloud is the hosted edition, which adds billing and the multi-tenant surface on top of // 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 ¶
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.