forked from evergreen-ci/evergreen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_runtime_environments.go
36 lines (28 loc) · 1.06 KB
/
config_runtime_environments.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
package evergreen
import (
"context"
"github.com/mongodb/anser/bsonutil"
"github.com/pkg/errors"
"go.mongodb.org/mongo-driver/bson"
)
type RuntimeEnvironmentsConfig struct {
BaseURL string `yaml:"base_url" bson:"base_url" json:"base_url"`
APIKey string `yaml:"api_key" bson:"api_key" json:"api_key"`
}
var (
runtimeEnvironmentsBaseURLKey = bsonutil.MustHaveTag(RuntimeEnvironmentsConfig{}, "BaseURL")
runtimeEnvironmentsAPIKey = bsonutil.MustHaveTag(RuntimeEnvironmentsConfig{}, "APIKey")
)
func (*RuntimeEnvironmentsConfig) SectionId() string { return "runtime_environments" }
func (c *RuntimeEnvironmentsConfig) Get(ctx context.Context) error {
return getConfigSection(ctx, c)
}
func (c *RuntimeEnvironmentsConfig) Set(ctx context.Context) error {
return errors.Wrapf(setConfigSection(ctx, c.SectionId(), bson.M{
"$set": bson.M{
runtimeEnvironmentsBaseURLKey: c.BaseURL,
runtimeEnvironmentsAPIKey: c.APIKey,
}}), "updating config section '%s'", c.SectionId(),
)
}
func (c *RuntimeEnvironmentsConfig) ValidateAndDefault() error { return nil }