dba

package
v0.0.0-...-a71b546 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version is the current DBA version
	Version = "v0.1.0"
)

Variables

This section is empty.

Functions

func EvalTemplate

func EvalTemplate(v interface{}, Ctx EvalConfig) (interface{}, error)

EvalTemplate evaluates template if string, otherwise returns value as given

func MustRun

func MustRun(config io.ReadWriter)

MustRun triggers the anonimyzers on the database tables. If an error occurs, execution stops.

Types

type Anonymizer

type Anonymizer interface {

	// Anonymize should run the actual anonymization
	// It should return an error when it fails or nil otherwise.
	Anonymize(*Database, EvalConfig) error

	// GetChangesets returns the set of changes to apply
	GetChangeSets(EvalConfig)
}

Anonymizer is the interface implemented by tables for anonimyzing data

type Config

type Config struct {
	EvalConfig
	Databases []*Database
}

Config is the HCL config parsed into databases and tables

func ParseConfig

func ParseConfig(configFile io.ReadWriter) (*Config, error)

ParseConfig parses the DBA config

type ConfigParseError

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

ConfigParseError denotes failing to parse configuration file.

func (ConfigParseError) Error

func (pe ConfigParseError) Error() string

Error returns the formatted configuration error.

type Database

type Database struct {
	Tables []*Table
	*sql.DB
	// contains filtered or unexported fields
}

Database represents the 'db' node in the config file

func NewDB

func NewDB(dbName string) *Database

NewDB creates a new Database struct

func (*Database) Close

func (db *Database) Close()

Close ensures DB connection is closed

func (*Database) Connect

func (db *Database) Connect() error

Connect creates the DB connection

func (*Database) MustGetMeta

func (m *Database) MustGetMeta(key string) interface{}

GetMeta retrieves value of key. Panics if key is missing

func (*Database) Run

func (db *Database) Run(Ctx EvalConfig)

Run establishes DB connection and anonymizes the tables

func (*Database) SetMeta

func (m *Database) SetMeta(key string, val interface{})

type EvalConfig

type EvalConfig struct {
	*hil.EvalConfig
}

EvalConfig is the template rendering context

type Table

type Table struct {
	Updates map[string]interface{}
	// contains filtered or unexported fields
}

Table represents the table node in the config file

func NewTable

func NewTable(tblName string) *Table

NewTable creates a new Table struct

func (*Table) Anonymize

func (tbl *Table) Anonymize(db *Database, Ctx EvalConfig) error

Anonymize does the actual table anonymization

func (*Table) GetChangeSets

func (tbl *Table) GetChangeSets(Ctx EvalConfig) (string, []interface{})

GetChangeSets returns the set of changes to apply to the table

func (*Table) MustGetMeta

func (m *Table) MustGetMeta(key string) interface{}

GetMeta retrieves value of key. Panics if key is missing

func (*Table) SetMeta

func (m *Table) SetMeta(key string, val interface{})

type TableRow

type TableRow map[string]interface{}

TableRow represents a row in a table

type TemplateError

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

TemplateError denotes failing to table update template.

func (TemplateError) Error

func (te TemplateError) Error() string

Error returns the formatted template error.

Jump to

Keyboard shortcuts

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