forked from ethpandaops/assertoor
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.go
More file actions
84 lines (66 loc) · 2.25 KB
/
config.go
File metadata and controls
84 lines (66 loc) · 2.25 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package coordinator
import (
"os"
"github.com/erigontech/assertoor/pkg/coordinator/clients"
"github.com/erigontech/assertoor/pkg/coordinator/db"
"github.com/erigontech/assertoor/pkg/coordinator/helper"
"github.com/erigontech/assertoor/pkg/coordinator/names"
"github.com/erigontech/assertoor/pkg/coordinator/types"
web_types "github.com/erigontech/assertoor/pkg/coordinator/web/types"
"gopkg.in/yaml.v3"
)
type Config struct {
// Database config
Database *db.DatabaseConfig `yaml:"database" json:"database"`
// List of execution & consensus clients to use.
Endpoints []clients.ClientConfig `yaml:"endpoints" json:"endpoints"`
// WebServer config
Web *web_types.WebConfig `yaml:"web" json:"web"`
// Validator names config
ValidatorNames *names.Config `yaml:"validatorNames" json:"validatorNames"`
// Global variables
GlobalVars map[string]interface{} `yaml:"globalVars" json:"globalVars"`
// Coordinator config
Coordinator *CoordinatorConfig `yaml:"coordinator" json:"coordinator"`
// List of Test configurations.
Tests []*types.TestConfig `yaml:"tests" json:"tests"`
// List of yaml files with test configurations
ExternalTests []*types.ExternalTestConfig `yaml:"externalTests" json:"externalTests"`
}
//nolint:revive // ignore
type CoordinatorConfig struct {
// Maximum number of tests executed concurrently
MaxConcurrentTests uint64 `yaml:"maxConcurrentTests" json:"maxConcurrentTests"`
// Test history cleanup delay
TestRetentionTime helper.Duration `yaml:"testRetentionTime" json:"testRetentionTime"`
}
// DefaultConfig represents a sane-default configuration.
func DefaultConfig() *Config {
return &Config{
Endpoints: []clients.ClientConfig{
{
Name: "local",
ExecutionURL: "http://localhost:8545",
ConsensusURL: "http://localhost:5052",
},
},
GlobalVars: make(map[string]interface{}),
Coordinator: &CoordinatorConfig{},
Tests: []*types.TestConfig{},
ExternalTests: []*types.ExternalTestConfig{},
}
}
func NewConfig(path string) (*Config, error) {
if path == "" {
return DefaultConfig(), nil
}
config := DefaultConfig()
yamlFile, err := os.ReadFile(path)
if err != nil {
return nil, err
}
if err := yaml.Unmarshal(yamlFile, &config); err != nil {
return nil, err
}
return config, nil
}