Skip to content

Commit

Permalink
feat: Add network name override functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
samcm committed Oct 15, 2024
1 parent 89b138a commit 46df4ec
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cmd/cannon.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,15 @@ var CannonOverrides = []CannonOverride{
overrides.BeaconNodeAuthorizationHeader.Value = val
},
}),
createCannonOverride(CannonOverrideConfig{
FlagName: "cannon-network-name",
EnvName: "CANNON_NETWORK_NAME",
Description: "sets the network name",
OverrideFunc: func(val string, overrides *cannon.Override) {
overrides.NetworkName.Enabled = true
overrides.NetworkName.Value = val
},
}),
}

// cannonCmd represents the cannon command
Expand Down
6 changes: 6 additions & 0 deletions pkg/cannon/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,11 @@ func (c *Config) ApplyOverrides(o *Override, log logrus.FieldLogger) error {
c.Coordinator.Headers["Authorization"] = o.XatuCoordinatorAuth.Value
}

if o.NetworkName.Enabled {
log.Info("Overriding network name")

c.Name = o.NetworkName.Value
}

return nil
}
4 changes: 4 additions & 0 deletions pkg/cannon/overrides.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,8 @@ type Override struct {
Enabled bool
Value string
}
NetworkName struct {
Enabled bool
Value string
}
}

0 comments on commit 46df4ec

Please sign in to comment.