Documentation ¶
Overview ¶
A small library for creating typed, consistent and documented environmental variable accesses.
Declaring a variable is as simple as declaring a module level constant.
var Var = env.Bool("VAR", "A boolean variable")
Typed values can be retrieved by calling `Var.Value()`.
Index ¶
Constants ¶
const Prefix = "PULUMI_"
The default prefix for a environmental variable.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BoolValue ¶
type BoolValue struct {
// contains filtered or unexported fields
}
A boolean retrieved from the environment.
func Bool ¶
Declare a new environmental value of type bool.
`name` is the runtime name of the variable. Unless `NoPrefix` is passed, name is pre-appended with `Prefix`. For example, a variable named "FOO" would be set by declaring "PULUMI_FOO=1" in the enclosing environment.
`description` is the string description of what the variable does.
func (BoolValue) Underlying ¶
func (BoolValue) Validate ¶
func (b BoolValue) Validate() ValidateError
type Env ¶
type Env interface { GetString(val StringValue) string GetBool(val BoolValue) bool GetInt(val IntValue) int }
A strongly typed environment.
type IntValue ¶
type IntValue struct {
// contains filtered or unexported fields
}
An integer retrieved from the environment.
func Int ¶
Declare a new environmental value of type integer.
`name` is the runtime name of the variable. Unless `NoPrefix` is passed, name is pre-appended with `Prefix`. For example, a variable named "FOO" would be set by declaring "PULUMI_FOO=1" in the enclosing environment.
`description` is the string description of what the variable does.
func (IntValue) Underlying ¶
func (IntValue) Validate ¶
func (i IntValue) Validate() ValidateError
type Store ¶
type Store interface { // Retrieve a raw value from the Store. If the value is not present, "", false should // be returned. Raw(key string) (string, bool) }
Store holds a collection of key, value? pairs.
Store acts like the environment that values are drawn from.
var Global Store = envStore{}
The global store of values that Value.Value() uses.
Setting this value is not thread safe, and should be restricted to testing.
type StringValue ¶
type StringValue struct {
// contains filtered or unexported fields
}
A string retrieved from the environment.
func String ¶
func String(name, description string, opts ...Option) StringValue
Declare a new environmental value.
`name` is the runtime name of the variable. Unless `NoPrefix` is passed, name is pre-appended with `Prefix`. For example, a variable named "FOO" would be set by declaring "PULUMI_FOO=val" in the enclosing environment.
`description` is the string description of what the variable does.
func (StringValue) Type ¶
func (StringValue) Type() string
func (StringValue) Underlying ¶
func (StringValue) Validate ¶
func (StringValue) Validate() ValidateError
func (StringValue) Value ¶
func (s StringValue) Value() string
The string value of the variable.
If the variable is unset, "" is returned.
type ValidateError ¶
type Value ¶
type Value interface { fmt.Stringer // Retrieve the underlying string value associated with the variable. // // If the variable was not set, ("", false) is returned. Underlying() (string, bool) // Retrieve the Var associated with this value. Var() Var Validate() ValidateError // contains filtered or unexported methods }
The value of a environmental variable.
In general, `Value`s should only be used in collections. For specific values, used the typed version (StringValue, BoolValue).
Every implementer of Value also includes a `Value() T` method that returns a typed representation of the value.