Skip to content

Commit

Permalink
Merge pull request #12 from ethpandaops/feat/support-no-config-file
Browse files Browse the repository at this point in the history
feat(config): Support running with no config file
samcm authored Jan 16, 2025
2 parents 2ec959a + 599bd54 commit 9dd7137
Showing 3 changed files with 44 additions and 17 deletions.
29 changes: 15 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -63,20 +63,6 @@ runMethod: RUN_METHOD_DOCKER
```
</details>
## 🔨 Development
<details>
<summary>Running Locally</summary>
To run Contributoor in development mode:
```bash
go run ./cmd/sentry/main.go --config /path/to/.contributoor/config.yaml --debug true
```

The `config.yaml` would have been generated for you by the installer.
</details>

<details>
<summary>Available CLI Flags</summary>
@@ -108,6 +94,21 @@ go run ./cmd/sentry/main.go \
```
</details>

## 🔨 Development

<details>
<summary>Running Locally</summary>

To run Contributoor in development mode:

```bash
go run ./cmd/sentry/main.go --config /path/to/.contributoor/config.yaml --debug true
```

The `config.yaml` would have been generated for you by the installer.
</details>


<details>
<summary>Code Generation</summary>

13 changes: 10 additions & 3 deletions cmd/sentry/main.go
Original file line number Diff line number Diff line change
@@ -204,9 +204,16 @@ func main() {
}

func newContributoor(c *cli.Context) (*contributoor, error) {
cfg, err := config.NewConfigFromPath(c.String("config"))
if err != nil {
return nil, err
cfg := config.NewDefaultConfig()

configLocation := c.String("config")
if configLocation != "" {
configFromFile, err := config.NewConfigFromPath(configLocation)
if err != nil {
return nil, err
}

cfg = configFromFile
}

if err := applyConfigOverridesFromFlags(cfg, c); err != nil {
19 changes: 19 additions & 0 deletions pkg/config/v1/config.go
Original file line number Diff line number Diff line change
@@ -75,6 +75,25 @@ func NewConfigFromPath(path string) (*Config, error) {
return cfg, nil
}

// NewDefaultConfig returns a new default config.
func NewDefaultConfig() *Config {
return &Config{
LogLevel: "info",
Version: "",
ContributoorDirectory: "~/.contributoor",
RunMethod: RunMethod_RUN_METHOD_DOCKER,
NetworkName: NetworkName_NETWORK_NAME_MAINNET,
BeaconNodeAddress: "http://localhost:5052",
MetricsAddress: "",
PprofAddress: "",
OutputServer: &OutputServer{
Address: "xatu.primary.production.platform.ethpandaops.io:443",
Credentials: "",
Tls: true,
},
}
}

// DisplayName returns the display name of the network.
func (n NetworkName) DisplayName() string {
switch n {

0 comments on commit 9dd7137

Please sign in to comment.