You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
949 B
41 lines
949 B
8 years ago
|
// Copyright 2012-present Oliver Eilhard. All rights reserved.
|
||
9 years ago
|
// Use of this source code is governed by a MIT-license.
|
||
|
// See http://olivere.mit-license.org/license.txt for details.
|
||
|
|
||
|
package elastic
|
||
|
|
||
8 years ago
|
import "golang.org/x/net/context"
|
||
|
|
||
9 years ago
|
// HasPlugin indicates whether the cluster has the named plugin.
|
||
|
func (c *Client) HasPlugin(name string) (bool, error) {
|
||
|
plugins, err := c.Plugins()
|
||
|
if err != nil {
|
||
|
return false, nil
|
||
|
}
|
||
|
for _, plugin := range plugins {
|
||
|
if plugin == name {
|
||
|
return true, nil
|
||
|
}
|
||
|
}
|
||
|
return false, nil
|
||
|
}
|
||
|
|
||
|
// Plugins returns the list of all registered plugins.
|
||
|
func (c *Client) Plugins() ([]string, error) {
|
||
8 years ago
|
stats, err := c.ClusterStats().Do(context.Background())
|
||
9 years ago
|
if err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if stats == nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
if stats.Nodes == nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var plugins []string
|
||
|
for _, plugin := range stats.Nodes.Plugins {
|
||
|
plugins = append(plugins, plugin.Name)
|
||
|
}
|
||
|
return plugins, nil
|
||
|
}
|