config

package
v0.0.0-...-6eb2448 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2020 License: MIT Imports: 6 Imported by: 5

Documentation

Overview

Package config has the definitions and utility function required for managing configurations for the applications

Index

Constants

View Source
const (
	//VAULT_ADDRESS is the environement variable for address of vault server
	VAULT_ADDRESS = "CUTTLE_AI_CONFIG_VAULT_ADDRESS"
	//DEFAULT_VAULT_ADDRESS is the environment variable for address of vault server
	DEFAULT_VAULT_ADDRESS = "VAULT_ADDR"
	//VAULT_TOKEN is the environment variable for vault access token
	VAULT_TOKEN = "CUTTLE_AI_CONFIG_VAULT_TOKEN"
	//VAULT_PATH is the environement variable for vault path
	VAULT_PATH = "CUTTLE_AI_CONFIG_VAULT_DEFAULT_PATH"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config map[string]string

Config is the configuration required for an application

type Service

type Service interface {
	//Init will init the configuration for the service
	Init(Config) error
}

Service is the interface to be implemented for representing a service that requires configuration

type Store

type Store interface {
	//GetConfig returns the configuration from the store
	//config should be the name of the config
	GetConfig(config string) (Config, error)
}

Store stores the configuration required for an application in a remote/local server

type Vault

type Vault struct {
	//Config has the configuration required for connecting with the Vault server
	Config *api.Config
	//Token to commuincate with the vault server
	Token string
	//Path is the path from which the secrets has to be fetched
	Path string
}

Vault is config store that stores the configuration in hashcopr vault It fetches the configuration from vault on demand

func NewVault

func NewVault() (*Vault, error)

NewVault will create a new vault and inits the configuration If any error found while initing the config, it will return it with nil vault Else nil error is returned.

func (*Vault) GetConfig

func (v *Vault) GetConfig(config string) (Config, error)

GetConfig returns the config along with the error if any while getting the configuration from remote/local vault server. If no error happens it will return non-nil Config and nil as error. If error happens it will return the error and nil as config

func (*Vault) InitConfig

func (v *Vault) InitConfig() error

InitConfig will init the configuration from environment variables The only supported method of providing configuration is environment variables.

Jump to

Keyboard shortcuts

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