-
Notifications
You must be signed in to change notification settings - Fork 37
/
pyroscope.go
37 lines (32 loc) · 983 Bytes
/
pyroscope.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
package config
import (
"errors"
"fmt"
"github.com/smartcontractkit/chainlink-testing-framework/libs/utils/net"
)
type PyroscopeConfig struct {
Enabled *bool `toml:"enabled"`
ServerUrl *string `toml:"server_url"`
Key *string `toml:"key_secret"`
Environment *string `toml:"environment"`
}
// Validate checks that the pyroscope config is valid, which means that
// server url, environment and key are set and non-empty, but only if
// pyroscope is enabled
func (c *PyroscopeConfig) Validate() error {
if c.Enabled != nil && *c.Enabled {
if c.ServerUrl == nil {
return errors.New("pyroscope server url must be set")
}
if !net.IsValidURL(*c.ServerUrl) {
return fmt.Errorf("invalid pyroscope server url %s", *c.ServerUrl)
}
if c.Environment == nil || *c.Environment == "" {
return errors.New("pyroscope environment must be set")
}
if c.Key == nil || *c.Key == "" {
return errors.New("pyroscope key must be set")
}
}
return nil
}