forked from evergreen-ci/evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig_graphite.go
More file actions
36 lines (29 loc) · 1.07 KB
/
config_graphite.go
File metadata and controls
36 lines (29 loc) · 1.07 KB
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
package evergreen
import (
"context"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
)
// GraphiteConfig stores configuration for Graphite integration.
type GraphiteConfig struct {
CIOptimizationToken string `bson:"ci_optimization_token" json:"ci_optimization_token" yaml:"ci_optimization_token" secret:"true"`
ServerURL string `bson:"server_url" json:"server_url" yaml:"server_url"`
}
func (c *GraphiteConfig) SectionId() string { return "graphite" }
func (c *GraphiteConfig) Get(ctx context.Context) error {
return getConfigSection(ctx, c)
}
func (c *GraphiteConfig) Set(ctx context.Context) error {
return errors.Wrapf(setConfigSection(ctx, c.SectionId(), bson.M{
"$set": bson.M{
graphiteCIOptimizationTokenKey: c.CIOptimizationToken,
graphiteServerURLKey: c.ServerURL,
}}), "updating config section '%s'", c.SectionId(),
)
}
func (c *GraphiteConfig) ValidateAndDefault() error {
if c.CIOptimizationToken != "" && c.ServerURL == "" {
return errors.New("must specify a Graphite server URL if a token is specified")
}
return nil
}