forked from open-telemetry/opentelemetry-collector-contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
32 lines (24 loc) · 898 Bytes
/
config.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
// Copyright The OpenTelemetry Authors
// SPDX-License-Identifier: Apache-2.0
package k8seventsreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/k8seventsreceiver"
import (
k8s "k8s.io/client-go/kubernetes"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sconfig"
)
// Config defines configuration for kubernetes events receiver.
type Config struct {
k8sconfig.APIConfig `mapstructure:",squash"`
// List of ‘namespaces’ to collect events from.
Namespaces []string `mapstructure:"namespaces"`
// For mocking
makeClient func(apiConf k8sconfig.APIConfig) (k8s.Interface, error)
}
func (cfg *Config) Validate() error {
return cfg.APIConfig.Validate()
}
func (cfg *Config) getK8sClient() (k8s.Interface, error) {
if cfg.makeClient == nil {
cfg.makeClient = k8sconfig.MakeClient
}
return cfg.makeClient(cfg.APIConfig)
}