config

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 13 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DecryptionKey string

applications that use encrypted secrets must set this as a package global

Functions

func BoD

func BoD(t time.Time) time.Time

BoD returns returns the time at midnight of the given time

func Decrypt added in v1.4.0

func Decrypt(encodedData string, secret []byte) (string, error)

Decrypt decrypts encodedData string with a secret key and returns plain string.

func DirFromSearchPath

func DirFromSearchPath(searchpath string) (dir *os.File, err error)

DirFromSearchPath returns the first valid directory in searchpath

func Encrypt added in v1.4.0

func Encrypt(plainData, secret []byte) (string, error)

Encrypt encrypts plainData string with a secret key and returns encrypt string.

func FileFromSearchPath

func FileFromSearchPath(searchpath string) (file *os.File, err error)

FileFromSearchPath returns first valid file in searchpath

func GetDatetime

func GetDatetime(tstr string) (t time.Time, err error)

GetDatetime attempts to parse a partial time string against formats into time.Time

func GetDatetimeInLocation

func GetDatetimeInLocation(tstr string, location *time.Location) (t time.Time, err error)

GetDatetimeInLocation attempts to parse a partial time string against formats into time.Time in a given time.Location

func GetDecryptedSecret added in v1.4.0

func GetDecryptedSecret(name string, key []byte) (secret string, err error)

GetDecryptedSecret returns the decrypted value of an encrypted Docker secret

func GetLast

func GetLast(day time.Weekday) time.Time

GetLast returns time at midnight of the most recent given weekday

func GetRawSecret

func GetRawSecret(name string) (secret []byte, err error)

GetRawSecret returns the raw value of Docker secret

func GetSecret

func GetSecret(name string) (secret string, err error)

GetSecret returns the value of Docker secret

func GetWeekday

func GetWeekday(day string) (time.Weekday, error)

GetWeekday returns a time.Weekday parsed from a given day string

func IfGetBool

func IfGetBool(name string, deflt bool) (value bool)

IfGetBool returns the int value of environment variable name; if name is not found or value cannot be parsed as an int return deflt

func IfGetDuration

func IfGetDuration(name string, deflt time.Duration) (value time.Duration)

IfGetDuration returns the time.Duration value of environment variable name; if name is not found or value cannot be parsed as a time.Duration return deflt

func IfGetInt

func IfGetInt(name string, deflt int) (value int)

IfGetInt returns the int value of environment variable name; if name is not found or value cannot be parsed as an int return deflt

func IfGetRune added in v1.3.1

func IfGetRune(name string, deflt rune) (rvalue rune)

IfGetRune returns the rune value of environment variable name; if name is not found or value cannot be parsed as an rune return deflt

func IfGetenv

func IfGetenv(name, deflt string) (value string)

IfGetenv returns the value of environment variable name if found, else deflt

func LoadFromSearchPath

func LoadFromSearchPath(file, searchpath string) (data []byte, err error)

LoadFromSearchPath returns the data read from the first valid file in searchpath

func MustGetBool

func MustGetBool(name string) (value bool)

MustGetBool returns the int value of environment variable name; if name is not found or value cannot be parsed as an int exit with fatal error

func MustGetConfig

func MustGetConfig(name string) string

MustGetConfig returns the value of the Docker secret with name, if it exists; if the secret cannot be read, returns the value of environment variable name; if name is not found in either Docker secrets or as an environment variable, exit with fatal error

func MustGetDuration

func MustGetDuration(name string) (value time.Duration)

MustGetDuration returns the time.Duration value of environment variable name; if name is not found or value cannot be parsed as a time.Duration exit with fatal error

func MustGetInt

func MustGetInt(name string) (value int)

MustGetInt returns the int value of environment variable name; if name is not found or value cannot be parsed as an int exit with fatal error

func MustGetRune added in v1.3.0

func MustGetRune(name string, deflt rune) (rvalue rune)

MustGetRune returns the rune value of environment variable name; if name is not found or value cannot be parsed as an rune return deflt

func MustGetSecret

func MustGetSecret(name string) string

MustGetSecret returns the value of the Docker secret with name; if the secret cannot be read exit with fatal error

func MustGetenv

func MustGetenv(name string) (v string)

MustGetenv returns the value of environment variable name; if name is not found exit with fatal error

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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