config

package
v0.0.0-...-5f73fe0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PORT_GRPC  = "PORT_GRPC"
	PORT_REST  = "PORT_REST"
	PRODUCTION = "PRODUCTION"

	CONSUL_HOST        = "CONSUL_HOST"
	CONSUL_TOKEN       = "CONSUL_TOKEN"
	CONSUL_KEY_FOLDER  = "CONSUL_KEY_FOLDER"
	CONSUL_KEY_VERSION = "CONSUL_KEY_VERSION"
	CONSUL_KEY_FILE    = "CONSUL_KEY_FILE"

	TRACER_URL  = "TRACER_URL"
	TRACER_NAME = "TRACER_NAME"

	VAULT_MOUNT_PATH        = "VAULT_MOUNT_PATH"
	VAULT_PUBLIC_CERT_PATH  = "VAULT_PUBLIC_CERT_PATH"
	VAULT_PRIVATE_CERT_PATH = "VAULT_PRIVATE_CERT_PATH"
	VAULT_REDIS_CREDS_PATH  = "VAULT_REDIS_CREDS_PATH"
	VAULT_TOKEN             = "VAULT_TOKEN"
	VAULT_HOST              = "VAULT_HOST"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AppConfig

type AppConfig[T TokenTime] struct {
	Issuer   string   `yaml:"issuer"`
	Subject  string   `yaml:"subject"`
	Audience []string `yaml:"audience"`
	TTL      *TTL[T]  `yaml:"ttl"`
}

type Config

type Config struct {
	App *AppConfig[time.Duration]
	// contains filtered or unexported fields
}

func New

func New(log *logger.Logger) *Config

func (*Config) ReadConsul

func (c *Config) ReadConsul(ctx context.Context, consulKey string, cc *capi.Client) error

func (*Config) WatchConsul

func (c *Config) WatchConsul(ctx context.Context, consulKey string, newConfigs []WatchConsulBody) error

type ConsulEnv

type ConsulEnv struct {
	Host       string `mapstructure:"CONSUL_HOST"`
	Token      string `mapstructure:"CONSUL_TOKEN"`
	KeyFolder  string `mapstructure:"CONSUL_KEY_FOLDER"`
	KeyVersion string `mapstructure:"CONSUL_KEY_VERSION"`
	KeyFile    string `mapstructure:"CONSUL_KEY_FILE"`
}

func (*ConsulEnv) Key

func (c *ConsulEnv) Key() string

type Env

type Env struct {
	Vault      *VaultEnv
	Consul     *ConsulEnv
	Jaeger     *JaegerEnv
	PortGRPC   string
	PortREST   string
	Production bool
}

func ReadEnv

func ReadEnv() (*Env, error)

type JaegerEnv

type JaegerEnv struct {
	URL  string `mapstructure:"TRACER_URL"`
	Name string `mapstructure:"TRACER_NAME"`
}

type TTL

type TTL[T TokenTime] struct {
	Access  T `yaml:"access"`
	Refresh T `yaml:"refresh"`
}

type TokenTime

type TokenTime interface {
	time.Duration | string
}

type VaultEnv

type VaultEnv struct {
	MountPath       string `mapstructure:"VAULT_MOUNT_PATH"`
	PublicCertPath  string `mapstructure:"VAULT_PUBLIC_CERT_PATH"`
	PrivateCertPath string `mapstructure:"VAULT_PRIVATE_CERT_PATH"`
	RedisCredsPath  string `mapstructure:"VAULT_REDIS_CREDS_PATH"`
	Token           string `mapstructure:"VAULT_TOKEN"`
	Host            string `mapstructure:"VAULT_HOST"`
}

type WatchConsulBody

type WatchConsulBody struct {
	Key         string
	CreateIndex int
	Flags       int
	Value       string
}

Jump to

Keyboard shortcuts

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