github.com/mahkhaled/pop@v4.13.1+incompatible/genny/config/options.go (about) 1 package config 2 3 import ( 4 "os" 5 6 "errors" 7 ) 8 9 // Options needed for the config generator 10 type Options struct { 11 Root string // Defaults to PWD 12 FileName string // Defaults to database.yml 13 Dialect string // required 14 Prefix string // required - <prefix>_development 15 } 16 17 func (opts *Options) Validate() error { 18 if opts.Root == "" { 19 pwd, _ := os.Getwd() 20 opts.Root = pwd 21 } 22 if opts.Prefix == "" { 23 return errors.New("you must provide a database name prefix") 24 } 25 if opts.FileName == "" { 26 opts.FileName = "database.yml" 27 } 28 if opts.Dialect == "" { 29 return errors.New("you must provide a database dialect") 30 } 31 return nil 32 }