Skip to content

Commit

Permalink
fix(nodebuilder): flag parsing for --node.type needs lowercase string…
Browse files Browse the repository at this point in the history
…, list network aliases for --p2p.network (#3827)
  • Loading branch information
renaynay authored Oct 8, 2024
1 parent 4309c83 commit 3997d72
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 8 additions & 4 deletions nodebuilder/node/type.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package node

import (
"strings"
)

// Type defines the Node type (e.g. `light`, `bridge`) for identity purposes.
// The zero value for Type is invalid.
type Type uint8
Expand Down Expand Up @@ -36,7 +40,7 @@ func (t Type) IsValid() bool {

// ParseType converts string in a type if possible.
func ParseType(str string) Type {
tp, ok := stringToType[str]
tp, ok := stringToType[strings.ToLower(str)]
if !ok {
return 0
}
Expand All @@ -53,9 +57,9 @@ var typeToString = map[Type]string{

// typeToString maps strings representations of all valid Types.
var stringToType = map[string]Type{
"Bridge": Bridge,
"Light": Light,
"Full": Full,
"bridge": Bridge,
"light": Light,
"full": Full,
}

// orderedTypes is a slice of all valid types in order of priority.
Expand Down
8 changes: 7 additions & 1 deletion nodebuilder/p2p/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,21 @@ func GetNetworks() []Network {
}

// listAvailableNetworks provides a string listing all known long-standing networks for things
// like CLI hints.
// like CLI hints. It also lists the network aliases as valid arguments.
func listAvailableNetworks() string {
var networks []string

for _, net := range orderedNetworks {
// "private" networks are configured via env vars, so skip
if net != Private {
networks = append(networks, net.String())
}
}
for net := range networkAliases {
if net != "private" {
networks = append(networks, net)
}
}

return strings.Join(networks, ", ")
}
Expand Down

0 comments on commit 3997d72

Please sign in to comment.