config

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConfigBytesForSecret added in v1.3.0

func ConfigBytesForSecret(smName string) (ConfigBytes, SecretKind, error)

ConfigBytesForSecret gets the secrets from AWS secrets manager. It returns the secret as a `ConfigByte`, which can then be unmarshalled as JSON into a user-defined structure. Use this if your AWS credentials and options are already configured in either environment variables or as IAM roles

func ConfigBytesForSecretWithSession added in v1.3.0

func ConfigBytesForSecretWithSession(smName string, sess *session.Session) (ConfigBytes, SecretKind, error)

ConfigBytesForSecretWithSession gets the secrets from AWS secrets manager. It returns the secret as a `ConfigByte`, which can then be unmarshalled as JSON into a user-defined structure. Use this function if you want to provide your own aws session.

func GetSecrets added in v1.1.0

func GetSecrets(smName string) (map[string]string, []byte, error)

GetSecrets gets the secrets from AWS secrets manager. If the secrets are a string map, it will be returned as the first return value. If the secrets are binary data, it will be returned as the second return value.

Use this if your AWS credentials and options are already configured in either environment variables or as IAM roles

func GetSecretsWithSession added in v1.1.0

func GetSecretsWithSession(smName string, sess *session.Session) (map[string]string, []byte, error)

GetSecretsWithSession gets the secrets from AWS secrets manager. If the secrets are a string map, it will be returned as the first return value. If the secrets are binary data, it will be returned as the second return value. Use this function if you want to provide your own aws session.

func GetSession added in v1.3.2

func GetSession() (*session.Session, error)

GetSession gets a session based on the `AWS_ENDPOINT` env variable.

Might be useful to redirect aws requests to a localstack for testing purposes

func PopulateEnvConfig

func PopulateEnvConfig(c interface{})

PopulateEnvConfig uses the "env" tag for struct fields to load environment variable values into respective struct fields.

func SplitByCommaSpace

func SplitByCommaSpace(s string) []string

SplitByCommaSpace converts strings separated by comma's into a string slice. It can be used to convert comma-separated env values into a string slice.

func StringFromRef added in v1.2.4

func StringFromRef(ref string) (string, bool, error)

Returns the string associated with a reference to a secret Currently, only supports awssm Example of a ref awssm://dev/application/enterprise#redis.yml-password

func WriteSecretsToENV added in v1.1.0

func WriteSecretsToENV(smName string) error

WriteSecretsToENV will take ENV format keys (all uppercase characters and digits connected with underscores) and set them as environment variables.

func WriteSecretsToENVWithSession added in v1.1.0

func WriteSecretsToENVWithSession(smName string, sess *session.Session) error

WriteSecretsToENVWithSession will take ENV format keys (all uppercase characters and digits connected with underscores) and set them as environment variables. Use this function if you want to provide your own aws session.

Types

type ConfigBytes

type ConfigBytes []byte

- ConfigBytes Functions ------------------------------------------------------

func ReadConfigFile

func ReadConfigFile(file string) (ConfigBytes, error)

Reads the specified config file. Note that bedrock.Application will process the config file, using text/template, with the following extra functions:

{{.Env "ENVIRONMENT_VARIABLE"}}
{{.Cat "File name"}}
{{.Base64 "a string"}}

func (ConfigBytes) Bytes added in v1.3.0

func (c ConfigBytes) Bytes() []byte

func (ConfigBytes) Unmarshal

func (c ConfigBytes) Unmarshal(dst interface{}) error

func (ConfigBytes) UnmarshalAt

func (c ConfigBytes) UnmarshalAt(dst interface{}, key string) error

UnmarshalAt unmarshals a specific key in the config into dst

func (ConfigBytes) UnmarshalJson added in v1.3.0

func (c ConfigBytes) UnmarshalJson(dst interface{}) error

func (ConfigBytes) UnmarshalJsonAt added in v1.3.0

func (c ConfigBytes) UnmarshalJsonAt(dst interface{}, key string) error

UnmarshalJsonAt unmarshals a specific key in the config into dst

type SecretKind added in v1.3.0

type SecretKind int
const (
	None SecretKind = iota
	String
	Binary
)

type TemplateContext

type TemplateContext struct {
}

func (*TemplateContext) Cat

func (c *TemplateContext) Cat(file string) string

Returns the contents of the specified file. Useful for pulling secrets that are mounted on the filesystem into the config file.

func (*TemplateContext) Default

func (c *TemplateContext) Default(def string, data string) string

func (*TemplateContext) Env

func (c *TemplateContext) Env(key string) string

Returns an environment variable

func (*TemplateContext) ExpandEnv

func (c *TemplateContext) ExpandEnv(s string) string

Expands environment variables

func (*TemplateContext) Scanln

func (c *TemplateContext) Scanln(prompt string) string

Returns a upper-case representation of the specified string.

func (*TemplateContext) ToBase64

func (c *TemplateContext) ToBase64(s string) string

Returns a Base64 representation of the specified string.

func (*TemplateContext) ToLower

func (c *TemplateContext) ToLower(s string) string

Returns a lower-case representation of the specified string.

func (*TemplateContext) ToUnderscore

func (c *TemplateContext) ToUnderscore(s string) string

Returns an underscored representation of the specified string.

func (*TemplateContext) ToUpper

func (c *TemplateContext) ToUpper(s string) string

Returns a upper-case representation of the specified string.

Jump to

Keyboard shortcuts

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