config

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EnvFunc = function.New(&function.Spec{
	Params: []function.Parameter{
		{
			Name:         "key",
			Type:         cty.String,
			AllowNull:    false,
			AllowUnknown: false,
		},
	},
	Type: function.StaticReturnType(cty.String),
	Impl: func(args []cty.Value, retType cty.Type) (cty.Value, error) {
		key := args[0].AsString()
		value := os.Getenv(key)
		return cty.StringVal(value), nil
	},
})

shamelessly ripped from Packer EnvFunc constructs a function that returns a string representation of the env var behind a value

Functions

func Env added in v0.3.0

func Env(key cty.Value) (cty.Value, error)

Env returns a string representation of the env var behind key.

func FindConfigFile

func FindConfigFile(depth int, filename string) (string, error)

walks backwards depth n parent directories looking for filename

func ProcessConfig

func ProcessConfig(c *Config) error

Types

type Ad struct {
	Name           string            `hcl:",label"`
	Role           string            `hcl:"role"`
	Mount          string            `hcl:"mount,optional"`
	TargetProvider string            `hcl:"target_provider"`
	UsernameEnvVar string            `hcl:"username_env_var,optional"`
	PasswordEnvVar string            `hcl:"password_env_var,optional"`
	ExtraEnvVars   map[string]string `hcl:"extra_env_vars,optional"`
	ExpandEnv      bool              `hcl:"expand_env_vars,optional"`
}

type Auth

type Auth struct {
	Name        string   `hcl:",label"`
	Method      string   `hcl:"method"`
	Path        string   `hcl:"path"`
	When        *When    `hcl:"when,block"`
	Priority    int      `hcl:"priority,optional"`
	ExportToken bool     `hcl:"export_vault_token,optional"`
	Jwt         *AuthJwt `hcl:"jwt,block"`
}

func (*Auth) IsEmpty added in v0.3.0

func (a *Auth) IsEmpty() bool

type AuthJwt added in v0.3.0

type AuthJwt struct {
	Role  string `hcl:"role"`
	Token string `hcl:"token"`
}

type Aws

type Aws struct {
	Name         string            `hcl:",label"`
	Method       string            `hcl:"method"`
	Role         string            `hcl:"role"`
	RoleArn      string            `hcl:"role_arn,optional"`
	Ttl          string            `hcl:"ttl"`
	ExtraEnvVars map[string]string `hcl:"extra_env_vars,optional"`
	Mount        string            `hcl:"mount,optional"`
}

func (*Aws) IsEmpty

func (a *Aws) IsEmpty() bool

type Azure added in v0.3.0

type Azure struct {
	Name         string            `hcl:",label"`
	Role         string            `hcl:"role"`
	ExtraEnvVars map[string]string `hcl:"extra_env_vars,optional"`
	Mount        string            `hcl:"mount,optional"`
}

func (*Azure) IsEmpty added in v0.3.0

func (a *Azure) IsEmpty() bool

type Config

type Config struct {
	Auth     []*Auth     `hcl:"auth,block"`
	Ad       []*Ad       `hcl:"ad,block"`
	Aws      *Aws        `hcl:"aws,block"`
	Azure    *Azure      `hcl:"azure,block"`
	KvSecret []*KvSecret `hcl:"kv_secret,block"`
}

func ParseConfig

func ParseConfig(filename string) (c *Config, err error)

Parse will parse file content into valid config.

type KvSecret

type KvSecret struct {
	Name           string            `hcl:",label"`
	Path           string            `hcl:"path"`
	Mount          string            `hcl:"mount,optional"`
	TargetProvider string            `hcl:"target_provider"`
	AttributeMap   map[string]string `hcl:"attribute_map,optional"`
	ExtraEnvVars   map[string]string `hcl:"extra_env_vars,optional"`
	ExpandEnv      bool              `hcl:"expand_env_vars,optional"`
}

type When

type When struct {
	EnvPresent string `hcl:"env_present,optional"`
}

Jump to

Keyboard shortcuts

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