Esempio n. 1
0
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)
	}
}
Esempio n. 2
0
func (s ShellDeploymentStrategy) runCommand(c string) error {

	// Create command string
	cmd := s.createCommand(c)
	log.Info(" --> Running command: %s", c)

	// Create command string
	out, err := cmd.Output()
	if err != nil {
		log.Fatal(fmt.Sprintf("Script '%s' with args '%v' not found or is not executable: %v", cmd.Path, cmd.Args, err))
		return err
	}
	log.Info(log.Colorize(log.CYAN, fmt.Sprintf("%s", out)))
	return nil
}