func (m *Muxy) LoadPlugins() { // Load Configuration var err error var confLoader *plugo.ConfigLoader c := &PluginConfig{} if m.config.ConfigFile != "" { confLoader = &plugo.ConfigLoader{} err = confLoader.LoadFromFile(m.config.ConfigFile, &c) if err != nil { log.Fatalf("Unable to read configuration file: %s", err.Error()) } } else { log.Fatal("No config file provided") } log.SetLevel(log.LogLevel(c.LogLevel)) // Load all plugins m.middlewares = make([]Middleware, len(c.Middleware)) plugins := plugo.LoadPluginsWithConfig(confLoader, c.Middleware) for i, p := range plugins { log.Info("Loading plugin \t" + log.Colorize(log.YELLOW, c.Middleware[i].Name)) m.middlewares[i] = p.(Middleware) } m.proxies = make([]Proxy, len(c.Proxy)) plugins = plugo.LoadPluginsWithConfig(confLoader, c.Proxy) for i, p := range plugins { log.Info("Loading proxy \t" + log.Colorize(log.YELLOW, c.Proxy[i].Name)) m.proxies[i] = p.(Proxy) m.proxies[i].Setup(m.middlewares) } }
func (g *Godspeed) LoadPlugins() { // Load Configuration var err error var confLoader *plugo.ConfigLoader c := &PluginConfig{} if g.config.ConfigFile != "" { confLoader = &plugo.ConfigLoader{} err = confLoader.LoadFromFile(g.config.ConfigFile, &c) if err != nil { log.Fatalf("Unable to read configuration file: %s", err.Error()) } } else { log.Fatal("No config file provided") } log.SetLevel(log.LogLevel(c.LogLevel)) // Load all plugins g.DeploymentStrategies = make([]DeploymentStrategy, len(c.Deployment)) plugins := plugo.LoadPluginsWithConfig(confLoader, c.Deployment) for i, p := range plugins { log.Debug("Loading plugin\t" + log.Colorize(log.YELLOW, c.Deployment[i].Name)) g.DeploymentStrategies[i] = p.(DeploymentStrategy) } }
// LoadPlugins loads all plugins referenced in the parity.yml file // from those registered at runtime func (p *Parity) LoadPlugins() { log.Debug("loading plugins") var err error var confLoader *plugo.ConfigLoader c := &config.RootConfig{} if p.config.ConfigFile != "" { confLoader = &plugo.ConfigLoader{} err = confLoader.LoadFromFile(p.config.ConfigFile, &c) if err != nil { log.Fatalf("Unable to read configuration file: %s", err.Error()) } } else { log.Fatalf("No configuration file provided. Please create a 'parity.yml' file.") } log.SetLevel(log.LogLevel(c.LogLevel)) // Load all plugins p.pluginConfig = &PluginConfig{Ui: p.config.Ui} // Set project name p.pluginConfig.ProjectName = c.Name p.pluginConfig.ProjectNameSafe = strings.Replace(strings.ToLower(c.Name), " ", "", -1) // Sync plugins p.SyncPlugins = make([]Sync, len(c.Sync)) syncPlugins := plugo.LoadPluginsWithConfig(confLoader, c.Sync) for i, pl := range syncPlugins { log.Debug("Loading Sync Plugin\t" + log.Colorize(log.YELLOW, c.Sync[i].Name)) p.SyncPlugins[i] = pl.(Sync) p.SyncPlugins[i].Configure(p.pluginConfig) p.plugins = append(p.plugins, p.SyncPlugins[i]) } // Run plugins p.RunPlugins = make([]Run, len(c.Run)) runPlugins := plugo.LoadPluginsWithConfig(confLoader, c.Run) for i, pl := range runPlugins { log.Debug("Loading Run Plugin\t" + log.Colorize(log.YELLOW, c.Run[i].Name)) p.RunPlugins[i] = pl.(Run) p.RunPlugins[i].Configure(p.pluginConfig) p.plugins = append(p.plugins, p.RunPlugins[i]) } // Build plugins p.BuildPlugins = make([]Builder, len(c.Build)) buildPlugins := plugo.LoadPluginsWithConfig(confLoader, c.Build) for i, pl := range buildPlugins { log.Debug("Loading Build Plugin\t" + log.Colorize(log.YELLOW, c.Build[i].Name)) p.BuildPlugins[i] = pl.(Builder) p.BuildPlugins[i].Configure(p.pluginConfig) p.plugins = append(p.plugins, p.BuildPlugins[i]) } // Shell plugins p.ShellPlugins = make([]Shell, len(c.Shell)) shellPlugins := plugo.LoadPluginsWithConfig(confLoader, c.Shell) for i, pl := range shellPlugins { log.Debug("Loading Shell Plugin\t" + log.Colorize(log.YELLOW, c.Shell[i].Name)) p.ShellPlugins[i] = pl.(Shell) p.ShellPlugins[i].Configure(p.pluginConfig) p.plugins = append(p.plugins, p.ShellPlugins[i]) } }