Skip to content

Commit 2b5f94e

Browse files
committed
set default values to simplify config
1 parent dbfa846 commit 2b5f94e

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

framework/components/blockchain/blockchain.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ type Input struct {
99
Type string `toml:"type" validate:"required,oneof=anvil geth" envconfig:"net_type"`
1010
Image string `toml:"image" validate:"required"`
1111
Tag string `toml:"tag" validate:"required"`
12-
PullImage bool `toml:"pull_image"`
13-
Port string `toml:"port" validate:"required"`
14-
ChainID string `toml:"chain_id" validate:"required"`
12+
PullImage bool `toml:"pull_image" default:"true"`
13+
Port string `toml:"port" validate:"required" default:"8545"`
14+
ChainID string `toml:"chain_id" validate:"required" default:"31337"`
1515
DockerCmdParamsOverrides []string `toml:"docker_cmd_params"`
1616
Out *Output `toml:"out"`
1717
}

framework/components/clnode/default.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ const defaultConfigTmpl = `
1919
[Log]
2020
Level = 'debug'
2121
22+
[Pyroscope]
23+
ServerAddress = 'http://host.docker.internal:4040'
24+
Environment = 'local'
25+
2226
[WebServer]
2327
HTTPWriteTimeout = '30s'
2428
SecureCookies = false

framework/components/simple_don/simple_don.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
)
77

88
type Input struct {
9-
Nodes int `toml:"nodes" validate:"required"`
10-
*clnode.Input
11-
Out *Output `toml:"out"`
9+
Nodes int `toml:"nodes" validate:"required"`
10+
NodeSpec *clnode.Input `toml:"node_spec" validate:"required"`
11+
Out *Output `toml:"out"`
1212
}
1313

1414
type Output struct {
1515
UseCache bool `toml:"use_cache"`
16-
Nodes []*clnode.Output `toml:"node"`
16+
CLNodes []*clnode.Output `toml:"cl_nodes"`
1717
}
1818

1919
func NewSimpleDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output, error) {
@@ -26,18 +26,19 @@ func NewSimpleDON(in *Input, bcOut *blockchain.Output, fakeUrl string) (*Output,
2626
if err != nil {
2727
return nil, err
2828
}
29-
in.Input.Node.TestConfigOverrides = net
30-
in.Input.DataProviderURL = fakeUrl
31-
in.Input.Out = nil
32-
o, err := clnode.NewNode(in.Input)
29+
newIn := in.NodeSpec
30+
newIn.Node.TestConfigOverrides = net
31+
newIn.DataProviderURL = fakeUrl
32+
newIn.Out = nil
33+
o, err := clnode.NewNode(newIn)
3334
if err != nil {
3435
return nil, err
3536
}
3637
nodeOuts = append(nodeOuts, o)
3738
}
3839
out := &Output{
3940
UseCache: true,
40-
Nodes: nodeOuts,
41+
CLNodes: nodeOuts,
4142
}
4243
in.Out = out
4344
return out, nil

framework/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func mergeInputs[T any]() (*T, error) {
6868
L.Info().Str("Path", path).Msg("Loading configuration input")
6969
data, err := os.ReadFile(filepath.Join(DefaultConfigDir, path))
7070
if err != nil {
71-
return nil, fmt.Errorf("error reading promtailConfig file %s: %w", path, err)
71+
return nil, fmt.Errorf("error reading promtail config file %s: %w", path, err)
7272
}
7373
if L.GetLevel() == zerolog.DebugLevel {
7474
fmt.Println(string(data))
@@ -304,7 +304,7 @@ func applyEnvConfig(prefix string, input interface{}) error {
304304
func getBaseConfigPath() (string, error) {
305305
configs := os.Getenv("CTF_CONFIGS")
306306
if configs == "" {
307-
return "", fmt.Errorf("no %s env var is provided, you should provide at least one test promtailConfig in TOML", EnvVarTestConfigs)
307+
return "", fmt.Errorf("no %s env var is provided, you should provide at least one test config in TOML", EnvVarTestConfigs)
308308
}
309309
return strings.Split(configs, ",")[0], nil
310310
}

framework/promtail.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ scrape_configs:
8383

8484
filePath := PathRoot + "/promtail-config.yml"
8585

86-
// Create the file where the promtailConfig will be written
86+
// Create the file where the promtail config will be written
8787
configFile, err := os.CreateTemp("", "promtail-config.yml")
8888
if err != nil {
8989
return "", fmt.Errorf("could not create promtail-config.yml file: %w", err)
@@ -92,15 +92,15 @@ scrape_configs:
9292

9393
tmpl, err := template.New("promtail").Parse(configTemplate)
9494
if err != nil {
95-
return "", fmt.Errorf("could not parse promtailConfig template: %w", err)
95+
return "", fmt.Errorf("could not parse promtail config template: %w", err)
9696
}
9797

9898
err = tmpl.Execute(configFile, secrets)
9999
if err != nil {
100-
return "", fmt.Errorf("could not execute promtailConfig template: %w", err)
100+
return "", fmt.Errorf("could not execute promtail config template: %w", err)
101101
}
102102

103-
fmt.Printf("Promtail promtailConfig written to %s\n", filePath)
103+
fmt.Printf("Promtail config written to %s\n", filePath)
104104
return configFile.Name(), nil
105105
}
106106

framework/secretsmanager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewAWSSecretsManager(requestTimeout time.Duration) (*AWSSecretsManager, err
7272
}
7373
cfg.Region = region
7474
if err != nil {
75-
return nil, fmt.Errorf("unable to load AWS SDK promtailConfig, %v", err)
75+
return nil, fmt.Errorf("unable to load AWS SDK config, %v", err)
7676
}
7777
l := log.Logger.With().Str("Component", "AWSSecretsManager").Logger()
7878
l.Info().Msg("Connecting to AWS Secrets Manager")

0 commit comments

Comments
 (0)