config

package
v0.2.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MainDir                         = ".halfpipe"
	MainFileNamePrefix              = "config"
	MainFileNameExt                 = "yaml"
	MainFileFullName                = MainFileNamePrefix + "." + MainFileNameExt
	ConnectionsConfigFileNamePrefix = "connections"
	ConnectionsConfigFileNameExt    = "yaml"
	ConnectionsConfigFileFullName   = ConnectionsConfigFileNamePrefix + "." + ConnectionsConfigFileNameExt
)

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(text []byte, key []byte) ([]byte, error)

Types

type EncryptedFile

type EncryptedFile struct {
	Dirname    string
	FileName   string
	FilePrefix string
	FileExt    string
	FullPath   string
	// contains filtered or unexported fields
}

EncryptedFile is a simple struct able to split file paths into the components to improve readability of code.

func NewEncryptedFileInConfigHomeDir

func NewEncryptedFileInConfigHomeDir(filename string) *EncryptedFile

func (*EncryptedFile) Get

func (f *EncryptedFile) Get() (text []byte, err error)

func (*EncryptedFile) Set

func (f *EncryptedFile) Set(text []byte) (err error)

type File

type File struct {
	Dirname    string
	FileName   string
	FilePrefix string
	FileExt    string
	FullPath   string
	// contains filtered or unexported fields
}

File is a simple struct able to split file paths into the components to improve readability of code.

var Connections *File
var Main *File

func NewConfigFile2WithDir

func NewConfigFile2WithDir(dirName string, filename string) *File

func (*File) Delete

func (c *File) Delete(key string) error

func (*File) Get

func (c *File) Get(key string, out interface{}) error

Get will fetch the key from the config File into variable, out. Supported out types are: string, ConnectionDetails. Return an error if we can't find the key.

func (*File) GetAllKeys

func (c *File) GetAllKeys() ([]string, error)

func (*File) GetConnectionDetails

func (c *File) GetConnectionDetails(connectionName string) (*shared.ConnectionDetails, error)

GetConnectionDetails fetches generic connection details from the File c using the connectionName to do the lookup. If the connection is not found the an error is produced.

func (*File) GetConnectionType

func (c *File) GetConnectionType(connectionName string) (connectionType string, err error)

GetConnectionType returns the connection type by un-marshalling the connection into an rdbms.DBConnectionDetails struct - so connections need to match that structure for now. Return an error if the key doesn't exist.

func (*File) LoadConnection

func (c *File) LoadConnection(connectionName string) (shared.ConnectionDetails, error)

func (*File) Set

func (c *File) Set(key string, val interface{}) error

type FileNotFoundError

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

FileNotFoundError denotes failing to find configuration file.

func (FileNotFoundError) Error

func (f FileNotFoundError) Error() string

Error returns the formatted configuration error.

type KeyNotFoundError

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

func (KeyNotFoundError) Error

func (k KeyNotFoundError) Error() string

Jump to

Keyboard shortcuts

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