forked from deblan/database-anonymizer
[wip] configuration
This commit is contained in:
parent
699614defb
commit
ddfd8bdcef
4 changed files with 103 additions and 0 deletions
40
config/config.go
Normal file
40
config/config.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
type DatabaseConfig struct {
|
||||
Type string
|
||||
Dsn string
|
||||
}
|
||||
|
||||
type AnonymizationConfig struct {
|
||||
}
|
||||
|
||||
func LoadDatabaseConfig(c *cli.Context) (error, DatabaseConfig) {
|
||||
config := DatabaseConfig{
|
||||
Type: c.String("type"),
|
||||
Dsn: c.String("dsn"),
|
||||
}
|
||||
|
||||
if config.Type == "" {
|
||||
return errors.New("You must specify a database type"), config
|
||||
}
|
||||
|
||||
if config.Dsn == "" {
|
||||
return errors.New("You must specify a database DSN"), config
|
||||
}
|
||||
|
||||
return nil, config
|
||||
}
|
||||
|
||||
func LoadAnonymizationConfig(c *cli.Context) (error, AnonymizationConfig) {
|
||||
config := AnonymizationConfig{
|
||||
Type: c.String("type"),
|
||||
Dsn: c.String("dsn"),
|
||||
}
|
||||
|
||||
return nil, config
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue