// NewPluginInfo creates a new PluginInfo for the plugin using the provided configuration. Returns an error if the
// provided configuration is not valid (can occur if multiple tasks have the same name or if a task is not valid).
965250
func NewPluginInfo(group, product, version string, params ...PluginInfoParam) (PluginInfo, error) {
	if err := validateComponent("group", group); err != nil {
		return nil, err
	}
	if err := validateComponent("product", product); err != nil {
		return nil, err
	}
	if !strings.HasSuffix(product, "-plugin") {
		return nil, errors.Errorf(`product must end with "-plugin", was %q`, product)
	}
	if err := validateComponent("version", version); err != nil {
		return nil, err
	}

	id := fmt.Sprintf("%s:%s:%s", group, product, version)

	builder := pluginInfoBuilder{}
	for _, param := range params {
		if err := param.apply(&builder); err != nil {
			return nil, err
		}
	}

	// set global flag options based on builder
	for i := range builder.tasks {
		builder.tasks[i].GlobalFlagOptionsVar = builder.globalFlagOpts
	}
	if builder.upgradeConfigTask != nil {
		builder.upgradeConfigTask.GroupID = group
		builder.upgradeConfigTask.ProductID = product
		builder.upgradeConfigTask.GlobalFlagOptionsVar = builder.globalFlagOpts
	}

	taskNameMap := make(map[string]struct{})
	for _, task := range builder.tasks {
		if _, ok := taskNameMap[task.Name()]; ok {
			return nil, errors.Errorf(`plugin %s specifies multiple tasks with name "%s"`, id, task.Name())
		}
		taskNameMap[task.Name()] = struct{}{}
	}

	if builder.upgradeConfigTask != nil && !builder.usesConfigFile {
		return nil, errors.Errorf(`plugin %s provides a configuration upgrade task but does not specify that it uses configuration`, id)
	}

	return pluginInfoImpl{
		PluginSchemaVersionVar: CurrentSchemaVersion,
		GroupVar:               group,
		ProductVar:             product,
		VersionVar:             version,
		UsesConfigVar:          builder.usesConfigFile,
		TasksVar:               builder.tasks,
		UpgradeConfigTaskVar:   builder.upgradeConfigTask,
	}, nil
}
382946
func NewPlugin(teamName, token string) plugins.BotMessagePlugin {
	return &plugin{
		teamName:  teamName,
		esaClient: esa.NewClient(token),
	}
}
1232269
func NewPlugin(opts ...Option) *Plugin {
	p := &Plugin{}

	p.PluginName = "msgsync"

	for _, o := range opts {
		o(p)
	}

	p.PluginDeps.Setup()

	return p
}
74886
func New(ic *plugin.InitContext) (interface{}, error) {
	var ns *metrics.Namespace
	config := ic.Config.(*Config)
	if !config.NoPrometheus {
		ns = metrics.NewNamespace("container", "", nil)
	}
	collector := newCollector(ns)
	oom, err := newOOMCollector(ns)
	if err != nil {
		return nil, err
	}
	if ns != nil {
		metrics.Register(ns)
	}
	ic.Meta.Platforms = append(ic.Meta.Platforms, platforms.DefaultSpec())
	return &cgroupsMonitor{
		collector: collector,
		oom:       oom,
		context:   ic.Context,
		publisher: ic.Events,
	}, nil
}
690490
func ForPlugin(name string) PluginLogger {
	if logger, found := DefaultRegistry.Lookup(name); found {
		DefaultLogger.Debugf("using plugin logger for %q that was already initialized", name)
		return &ParentLogger{
			Logger:  logger,
			Prefix:  name,
			Factory: DefaultRegistry,
		}
	}
	return NewParentLogger(name, DefaultRegistry)
}
1004873
func NewPlugin(name, prefix string, newFunc func(typesMap TypesMap, p Printer, deps map[string]Dependency) Generator) Plugin {
	return &plugin{
		name:    name,
		prefix:  prefix,
		newFunc: newFunc,
	}
}
82295
func NewPluginStatusMap(owner infra.PluginName) PluginStatusIdxMapRW {
	return &pluginStatusMap{
		mapping: mem.NewNamedMapping(logrus.DefaultLogger(), "plugin_status", IndexPluginStatus),
	}
}
127182
func (l *PluginLoader) validatePluginConfigs() error {
	var mErr multierror.Error
	for id, info := range l.plugins {
		if err := l.validatePluginConfig(id, info); err != nil {
			wrapped := multierror.Prefix(err, fmt.Sprintf("plugin %s:", id))
			multierror.Append(&mErr, wrapped)
		}
	}

	return mErr.ErrorOrNil()
}
563447
func newInfo(infoType string, context []byte) []byte {
	info := append([]byte("Content-Encoding: "), []byte(infoType)...)
	info = append(info, 0)
	// For aes128gcm ctx is not needed.
	if len(context) > 0 {
		info = append(info, []byte("P-256")...)
		info = append(info, context...)
	}
	return info
}
989668
func NewPlugin(name string, getQueries GetQueriesFunc, writeResults WriteResultsFunc) *Plugin {
	return &Plugin{name: name, getQueries: getQueries, writeResults: writeResults}
}
1007022
func InitPlugin(netPlugin *plugin.NetPlugin) {

	cniLog = log.WithField("plugin", "mesos")
	cniLog.Infof("starting Mesos CNI server")
	router := mux.NewRouter()

	// register handlers for cni plugin
	subRtr := router.Headers("Content-Type", "application/json").Subrouter()
	subRtr.HandleFunc(cniapi.MesosNwIntfAdd, httpWrapper(mesosNwIntfAdd)).Methods("POST")
	subRtr.HandleFunc(cniapi.MesosNwIntfDel, httpWrapper(mesosNwIntfDel)).Methods("POST")
	router.HandleFunc("/{*}", unknownReq)

	sockFile := cniapi.ContivMesosSocket
	os.Remove(sockFile)
	os.MkdirAll(cniapi.PluginPath, 0700)

	cniDriverInit(netPlugin)

	go func() {
		lsock, err := net.ListenUnix("unix", &net.UnixAddr{Name: sockFile, Net: "unix"})
		if err != nil {
			cniLog.Errorf("Mesos CNI server failed:  %s", err)
			return
		}

		cniLog.Infof("Mesos CNI server is listening on %s", sockFile)
		http.Serve(lsock, router)
		lsock.Close()
		cniLog.Infof("Mesos CNI server socket %s closed ", sockFile)
	}()
}
395886
func (cli *Client) PluginInstall(ctx context.Context, name string, options types.PluginInstallOptions) error {
	// FIXME(vdemeester) name is a ref, we might want to parse/validate it here.
	query := url.Values{}
	query.Set("name", name)
	resp, err := cli.tryPluginPull(ctx, query, options.RegistryAuth)
	if resp.statusCode == http.StatusUnauthorized && options.PrivilegeFunc != nil {
		newAuthHeader, privilegeErr := options.PrivilegeFunc()
		if privilegeErr != nil {
			ensureReaderClosed(resp)
			return privilegeErr
		}
		resp, err = cli.tryPluginPull(ctx, query, newAuthHeader)
	}
	if err != nil {
		ensureReaderClosed(resp)
		return err
	}
	var privileges types.PluginPrivileges
	if err := json.NewDecoder(resp.body).Decode(&privileges); err != nil {
		ensureReaderClosed(resp)
		return err
	}
	ensureReaderClosed(resp)

	if !options.AcceptAllPermissions && options.AcceptPermissionsFunc != nil && len(privileges) > 0 {
		accept, err := options.AcceptPermissionsFunc(privileges)
		if err != nil {
			return err
		}
		if !accept {
			resp, _ := cli.delete(ctx, "/plugins/"+name, nil, nil)
			ensureReaderClosed(resp)
			return pluginPermissionDenied{name}
		}
	}
	if options.Disabled {
		return nil
	}
	return cli.PluginEnable(ctx, name)
}
900138
func (a *addr2LinerNM) addrInfo(addr uint64) ([]plugin.Frame, error) {
	if len(a.m) == 0 || addr < a.m[0].address || addr > a.m[len(a.m)-1].address {
		return nil, nil
	}

	// Binary search. Search until low, high are separated by 1.
	low, high := 0, len(a.m)
	for low+1 < high {
		mid := (low + high) / 2
		v := a.m[mid].address
		if addr == v {
			low = mid
			break
		} else if addr > v {
			low = mid
		} else {
			high = mid
		}
	}

	// Address is between a.m[low] and a.m[high].
	// Pick low, as it represents [low, high).
	f := []plugin.Frame{
		{
			Func: a.m[low].name,
		},
	}
	return f, nil
}
1036776
func NewPlugin() *podPresetPlugin {
	return &podPresetPlugin{
		Handler: admission.NewHandler(admission.Create, admission.Update),
	}
}
946977
func NewPlugin(opts *Options) *Plugin {
	if opts == nil {
		opts = &Options{}
	}

	so := opts.Object

	if so == nil {
		so = &Object{}
	}
	if so.Paths == nil {
		so.Paths = make(Paths, 0)
	}
	if so.Definitions == nil {
		so.Definitions = make(Definitions, 0)
	}

	p := &Plugin{options: opts}
	soConstructor := &swaggerObjectConstructor{
		plugin:           p,
		object:           so,
		typeSchemaMapper: make(map[reflect.Type]*TypeSchema),
	}
	for k, v := range DefaultTypeSchemaMapper {
		soConstructor.typeSchemaMapper[k] = v
	}
	p.constructor = soConstructor

	return p
}
83415
func NewInfo(environment string) Info {
	if environment == "" {
		environment = EnvironmentProduction
	}
	return Info{
		CommitHash:  commitHash,
		BuildDate:   buildDate,
		Environment: environment,
	}
}
334571
func New(url string) (*dt.Plugin, error) {
	if err := core.LoadEnvVars(); err != nil {
		log.Fatal(err)
	}
	db, err := core.ConnectDB("")
	if err != nil {
		return nil, err
	}

	// Read plugin.json data from within plugins.go, unmarshal into struct
	c := dt.PluginConfig{}
	if len(os.Getenv("ABOT_PATH")) > 0 {
		p := filepath.Join(os.Getenv("ABOT_PATH"), "plugins.go")
		var scn *bufio.Scanner
		fi, err := os.OpenFile(p, os.O_RDONLY, 0666)
		if os.IsNotExist(err) {
			goto makePlugin
		}
		if err != nil {
			return nil, err
		}
		defer func() {
			if err = fi.Close(); err != nil {
				log.Info("failed to close file", fi.Name())
				return
			}
		}()
		var found bool
		var data string
		scn = bufio.NewScanner(fi)
		for scn.Scan() {
			t := scn.Text()
			if !found && t != url {
				continue
			} else if t == url {
				found = true
				continue
			} else if len(t) >= 1 && t[0] == '}' {
				data += t
				break
			}
			data += t
		}
		if err = scn.Err(); err != nil {
			return nil, err
		}
		if len(data) > 0 {
			if err = json.Unmarshal([]byte(data), &c); err != nil {
				return nil, err
			}
			if len(c.Name) == 0 {
				return nil, ErrMissingPluginName
			}
		}
	}
makePlugin:
	l := log.New(c.Name)
	l.SetDebug(os.Getenv("ABOT_DEBUG") == "true")
	plg := &dt.Plugin{
		Trigger:     &dt.StructuredInput{},
		SetBranches: func(in *dt.Msg) [][]dt.State { return nil },
		Events: &dt.PluginEvents{
			PostReceive:    func(cmd *string) {},
			PreProcessing:  func(cmd *string, u *dt.User) {},
			PostProcessing: func(in *dt.Msg) {},
			PreResponse:    func(in *dt.Msg, resp *string) {},
		},
		Config: c,
		DB:     db,
		Log:    l,
	}
	plg.SM = dt.NewStateMachine(plg)
	return plg, nil
}