-
Notifications
You must be signed in to change notification settings - Fork 52
/
node_driver.go
35 lines (28 loc) · 982 Bytes
/
node_driver.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package drivers
import (
"context"
"fmt"
"github.com/rancher/opni/pkg/config/v1beta1"
"github.com/rancher/opni/pkg/plugins/driverutil"
"github.com/rancher/opni/pkg/rules"
"github.com/rancher/opni/pkg/util/notifier"
"github.com/rancher/opni/plugins/metrics/apis/node"
"github.com/rancher/opni/plugins/metrics/apis/remoteread"
)
type MetricsNodeConfigurator interface {
ConfigureNode(nodeId string, conf *node.MetricsCapabilityConfig) error
}
type MetricsNodeDriver interface {
MetricsNodeConfigurator
DiscoverPrometheuses(context.Context, string) ([]*remoteread.DiscoveryEntry, error)
ConfigureRuleGroupFinder(config *v1beta1.RulesSpec) notifier.Finder[rules.RuleGroup]
}
var NodeDrivers = driverutil.NewDriverCache[MetricsNodeDriver]()
type ConfigurationError struct {
NodeId string
Cfg *node.MetricsCapabilityConfig
Err error
}
func (e *ConfigurationError) Error() string {
return fmt.Errorf("error configuring node %s: %w", e.NodeId, e.Err).Error()
}