Skip to content

Commit

Permalink
refactor: Enforce one of --ethereum-cl or --ethereum-el
Browse files Browse the repository at this point in the history
  • Loading branch information
mattevans committed Feb 6, 2025
1 parent d3d8458 commit 03b9991
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
17 changes: 2 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,9 @@ The checks are run against a Grafana instance, which is configured with a Promet

## Usage

### Pulse Check All Clients
### Pulse Check

```bash
docker run -e GRAFANA_SERVICE_TOKEN=your_token \
-e DISCORD_BOT_TOKEN=your_token \
-e OPENROUTER_API_KEY=optional_key \
ethpandaops/panda-pulse:0.0.2 \
--discord-channel CHANNEL_ID \
--network NETWORK_NAME
```

### Pulse Check Specific Client

You can also pass in a target client to scope the checks + notification.

This can be done with `--ethereum-cl` or `--ethereum-el`:
Run by passing in a network name, a discord channel ID and one of `--ethereum-cl` or `--ethereum-el`.

```bash
docker run -e GRAFANA_SERVICE_TOKEN=your_token \
Expand Down
16 changes: 11 additions & 5 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,25 @@ func main() {
return fmt.Errorf("DISCORD_BOT_TOKEN environment variable is required")
}

// Check for mutually exclusive flags.
if cmd.Flags().Changed("ethereum-cl") && cmd.Flags().Changed("ethereum-el") {
// We enforce that one of --ethereum-cl or --ethereum-el is specified.
clSpecified := cmd.Flags().Changed("ethereum-cl")
elSpecified := cmd.Flags().Changed("ethereum-el")

if !clSpecified && !elSpecified {
return fmt.Errorf("must specify either --ethereum-cl or --ethereum-el")
}

if clSpecified && elSpecified {
return fmt.Errorf("cannot specify both --ethereum-cl and --ethereum-el flags")
}

// Validate client flags.
if cmd.Flags().Changed("ethereum-cl") {
if clSpecified {
if err := validateClient(cfg.ConsensusNode, true); err != nil {
return err
}
}

if cmd.Flags().Changed("ethereum-el") {
if elSpecified {
if err := validateClient(cfg.ExecutionNode, false); err != nil {
return err
}
Expand Down

0 comments on commit 03b9991

Please sign in to comment.