// registerPlugins makes plugins available for use by the agent. func registerPlugins(registry plugin.Registry, plugins []plugin.Plugin, logger *StreamLogger) error { for _, pl := range plugins { if err := registry.Register(pl); err != nil { return fmt.Errorf("Failed to register plugin %v: %v", pl.Name(), err) } logger.LogExecution(slogger.INFO, "Registered plugin %v", pl.Name()) } return nil }
// Helper for validating a set of plugin commands given a project/registry func validateCommands(section string, project *model.Project, registry plugin.Registry, commands []model.PluginCommandConf) []ValidationError { errs := []ValidationError{} for _, cmd := range commands { command := fmt.Sprintf("'%v' command", cmd.Command) _, err := registry.GetCommands(cmd, project.Functions) if err != nil { if cmd.Function != "" { command = fmt.Sprintf("'%v' function", cmd.Function) } errs = append(errs, ValidationError{Message: fmt.Sprintf("%v section in %v: %v", section, command, err)}) } if cmd.Type != "" { if cmd.Type != model.SetupCommandType && cmd.Type != model.TestCommandType { msg := fmt.Sprintf("%v section in '%v': invalid command type: '%v'", section, command, cmd.Type) errs = append(errs, ValidationError{Message: msg}) } } } return errs }