configuration

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ConfigFileName name of the configuration file
	ConfigFileName = ".passwdvaultconfig"

	// ConfigFileType configuration file type
	ConfigFileType = "yaml"
)

Variables

View Source
var (
	ConfigFilePath = path.Join(os.Getenv("HOME"), ConfigFileName+"."+ConfigFileType)

	DefaultConfig = Configuration{
		User: UserConfiguration{
			Name:  "someuser",
			Email: "[email protected]",
		},
		Database: DatabaseConfiguration{
			Name:      "badger",
			Path:      "/tmp/",
			Encrypted: true,
			MasterKey: MasterKey{
				FromFilePath: "/etc/passwdvault/mk",
				Length:       32,
			},
		},
	}
)

DefaultConfig default configuration

Functions

func CheckForConfigFileAndParse

func CheckForConfigFileAndParse() error

CheckForConfigFileAndParse utility function that checks if config file exists and parse it

func CloseDb

func CloseDb()

CloseDb closes BadgerDB

func CreateConfigurationFile

func CreateConfigurationFile(user *UserConfiguration, database *DatabaseConfiguration) error

CreateConfigurationFile creates a configuration file in $HOME/.passwdvaultconfig.yaml with values specified in user and database

func CreateDb

func CreateDb(databasePath string, masterkey []byte) error

CreateDb creates a database for the first time

func CreateDefaultFile

func CreateDefaultFile(completeFilePath string) error

CreateDefaultFile creates a default configuration file in $HOME/.passwdvaultconfig.yaml

func DbInit

func DbInit() error

DbInit executes a function that initiates and opens BadgerDB

func InitCriticalData

func InitCriticalData() error

InitCriticalData utility function that initiates every critical data needed to the program

func ParseConfigurationFile

func ParseConfigurationFile() error

ParseConfigurationFile parses the configuration file

func ReadMasterKeyFromFile

func ReadMasterKeyFromFile(filepath string) ([]byte, error)

ReadMasterKeyFromFile reads masterkey value from file

func SaveConfigurationFile

func SaveConfigurationFile() error

SaveConfigurationFile saves configuration file

Types

type Configuration

type Configuration struct {
	User     UserConfiguration
	Database DatabaseConfiguration
}

Configuration holds default configuration file with useful data about the database path and config

type DatabaseConfiguration

type DatabaseConfiguration struct {
	Name      string `mapstructure:"filename"`
	Path      string `mapstructure:"path"`
	Encrypted bool   `mapstructure:"encrypted"`
	MasterKey MasterKey
}

DatabaseConfiguration struct of the database configuration

type MasterKey

type MasterKey struct {
	FromFilePath string `mapstructure:"filepath"`
	Length       int8   `mapstructure:"len"`
}

MasterKey struct of the masterkey needed to unlock the database

type UserConfiguration

type UserConfiguration struct {
	Name  string `mapstructure:"name"`
	Email string `mapstructure:"email"`
}

UserConfiguration struct of user configuration

Jump to

Keyboard shortcuts

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