config

package
v0.0.0-...-90cfb48 Latest Latest
Warning

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

Go to latest
Published: May 1, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENV_PORT                   = "PORT"
	ENV_CONSUL_HOST            = "CONSUL_HOST"
	ENV_CONSUL_KEY_FOLDER      = "CONSUL_KEY_FOLDER"
	ENV_CONSUL_KEY_VERSION     = "CONSUL_KEY_VERSION"
	ENV_CONSUL_KEY_FILE        = "CONSUL_KEY_FILE"
	ENV_VAULT_SCHEME           = "VAULT_SCHEME"
	ENV_VAULT_HOST             = "VAULT_HOST"
	ENV_VAULT_TOKEN            = "VAULT_TOKEN"
	ENV_VAULT_MOUNT_PATH       = "VAULT_MOUNT_PATH"
	ENV_VAULT_KEY_PUBLIC_PATH  = "VAULT_KEY_PUBLIC_PATH"
	ENV_VAULT_KEY_PRIVATE_PATH = "VAULT_KEY_PRIVATE_PATH"
	ENV_VAULT_KEY_VERSION      = "VAULT_KEY_VERSION"
	ENV_GENERATE_RSA_KEYS      = "GENERATE_RSA_KEYS"
)

Variables

This section is empty.

Functions

func NewVaultClient

func NewVaultClient(env *EnvVault) (*vault.Client, error)

Types

type Config

type Config struct {
	// contains filtered or unexported fields
}

func (*Config) JWT

func (c *Config) JWT() *JWTConfig

func (*Config) ReadConfig

func (c *Config) ReadConfig(env *EnvConsul) error

func (*Config) ReadVaultKeys

func (c *Config) ReadVaultKeys(vaultClient *vault.Client, env *EnvVault) (*KeysConfig, error)

func (*Config) Redis

func (c *Config) Redis() *RedisConfig

func (*Config) WatchConsul

func (c *Config) WatchConsul(env *EnvConsul, newConfigs []WatchConsulBody) error

type Configurator

type Configurator interface {
	ConsulWatcher
	ReadConfig(env *EnvConsul) error
	Redis() *RedisConfig
	JWT() *JWTConfig
	ReadVaultKeys(vaultClient *vault.Client, env *EnvVault) (*KeysConfig, error)
}

func NewConfig

func NewConfig() Configurator

TODO: replace with ReadConfig instead NewConfig and config.ReadConfig

type ConsulWatcher

type ConsulWatcher interface {
	WatchConsul(env *EnvConsul, newConfigs []WatchConsulBody) error
}

type EnvConsul

type EnvConsul struct {
	Host string       `yaml:"host"`
	Key  EnvConsulKey `yaml:"key"`
}

type EnvConsulKey

type EnvConsulKey struct {
	Folder  string `yaml:"folder"`
	Version string `yaml:"version"`
	File    string `yaml:"file"`
}

func (*EnvConsulKey) String

func (e *EnvConsulKey) String() string

type EnvLocal

type EnvLocal struct {
	Port            string    `yaml:"port"`
	Consul          EnvConsul `yaml:"consul"`
	Vault           EnvVault  `yaml:"vault"`
	GenerateRSAKeys bool      `yaml:"generate_rsa_keys"`
}

func ReadEnv

func ReadEnv() (*EnvLocal, error)

type EnvVault

type EnvVault struct {
	Scheme    string      `yaml:"scheme"`
	Host      string      `yaml:"host"`
	Token     string      `yaml:"token"`
	MountPath string      `yaml:"mount_path"`
	Key       EnvVaultKey `yaml:"key"`
}

type EnvVaultKey

type EnvVaultKey struct {
	PublicPath  string `yaml:"public_path"`
	PrivatePath string `yaml:"private_path"`
	Version     int    `yaml:"version"`
}

type JWTConfig

type JWTConfig struct {
	Issuer   string   `yaml:"issuer"`
	Subject  string   `yaml:"subject"`
	Audience []string `yaml:"audience"`
	TTL      TTL      `yaml:"ttl"`
}

type KeysConfig

type KeysConfig struct {
	Public  []byte `yaml:"public"`
	Private []byte `yaml:"private"`
}

type MainConfig

type MainConfig struct {
	Redis RedisConfig `yaml:"redis"`
	JWT   JWTConfig   `yaml:"jwt"`
}

type RedisConfig

type RedisConfig struct {
	Host     string `yaml:"host"`
	Port     int    `yaml:"port"`
	Db       int    `yaml:"db"`
	Password string `yaml:"password"`
}

type TTL

type TTL struct {
	Access  string `yaml:"access"`
	Refresh string `yaml:"refresh"`
}

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