github.com/segakazzz/buffalo@v0.16.22-0.20210119082501-1f52048d3feb/genny/plugins/install/options.go (about) 1 package install 2 3 import ( 4 "os" 5 6 "github.com/gobuffalo/buffalo/plugins/plugdeps" 7 "github.com/gobuffalo/meta" 8 "github.com/segakazzz/buffalo/internal/takeon/github.com/markbates/errx" 9 ) 10 11 // Options container for passing needed info for 12 // installing plugins and adding them to the config file. 13 type Options struct { 14 App meta.App 15 Plugins []plugdeps.Plugin 16 Tags meta.BuildTags 17 Vendor bool 18 } 19 20 // Validate that options are usuable 21 func (opts *Options) Validate() error { 22 if opts.App.IsZero() { 23 pwd, err := os.Getwd() 24 if err != nil { 25 return err 26 } 27 opts.App = meta.New(pwd) 28 } 29 if len(opts.Plugins) == 0 { 30 plugs, err := plugdeps.List(opts.App) 31 if err != nil && (errx.Unwrap(err) != plugdeps.ErrMissingConfig) { 32 return err 33 } 34 opts.Plugins = plugs.List() 35 } 36 37 for i, p := range opts.Plugins { 38 p.Tags = opts.App.BuildTags("", append(opts.Tags, p.Tags...)...) 39 opts.Plugins[i] = p 40 } 41 42 return nil 43 }