-
Notifications
You must be signed in to change notification settings - Fork 125
/
options.go
52 lines (45 loc) · 1.45 KB
/
options.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package summary
import (
"github.com/fairwindsops/goldilocks/pkg/kube"
"github.com/fairwindsops/goldilocks/pkg/utils"
"k8s.io/apimachinery/pkg/util/sets"
)
type Option func(*options)
// options for getting and caching the Summarizer's VPAs
type options struct {
kubeClient *kube.ClientInstance
vpaClient *kube.VPAClientInstance
dynamicClient *kube.DynamicClientInstance
namespace string
vpaLabels map[string]string
excludedContainers sets.String
}
// defaultOptions for a Summarizer
func defaultOptions() *options {
return &options{
kubeClient: kube.GetInstance(),
vpaClient: kube.GetVPAInstance(),
dynamicClient: kube.GetDynamicInstance(),
namespace: namespaceAllNamespaces,
vpaLabels: utils.VPALabels,
excludedContainers: sets.NewString(),
}
}
// ForNamespace is an Option for limiting the summary to a single namespace
func ForNamespace(namespace string) Option {
return func(opts *options) {
opts.namespace = namespace
}
}
// ExcludeContainers is an Option for excluding containers in the summary
func ExcludeContainers(excludedContainers sets.String) Option {
return func(opts *options) {
opts.excludedContainers = excludedContainers
}
}
// ForVPAsWithLabels is an Option for limiting the summary to certain VPAs matching the labels
func ForVPAsWithLabels(vpaLabels map[string]string) Option {
return func(opts *options) {
opts.vpaLabels = vpaLabels
}
}