Skip to content

Commit

Permalink
rename flag namings
Browse files Browse the repository at this point in the history
  • Loading branch information
vgonkivs committed Jan 22, 2025
1 parent 89cfa35 commit 9561cb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions nodebuilder/core/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

var (
coreFlag = "core.ip"
coreGRPCFlag = "core.port"
coreIPFlag = "core.ip"
corePortFlag = "core.port"
coreTLS = "core.tls"
coreXTokenPathFlag = "core.xtoken.path" //nolint:gosec
)
Expand All @@ -19,14 +19,14 @@ func Flags() *flag.FlagSet {
flags := &flag.FlagSet{}

flags.String(
coreFlag,
coreIPFlag,
"",
"Indicates node to connect to the given core node. "+
"Example: <ip>, 127.0.0.1. <dns>, subdomain.domain.tld "+
"Assumes gRPC port 9090 as default unless otherwise specified.",
)
flags.String(
coreGRPCFlag,
corePortFlag,
DefaultPort,
"Set a custom gRPC port for the core node connection. The --core.ip flag must also be provided.",
)
Expand All @@ -51,16 +51,16 @@ func ParseFlags(
cmd *cobra.Command,
cfg *Config,
) error {
coreIP := cmd.Flag(coreFlag).Value.String()
coreIP := cmd.Flag(coreIPFlag).Value.String()
if coreIP == "" {
if cmd.Flag(coreGRPCFlag).Changed {
if cmd.Flag(corePortFlag).Changed {
return fmt.Errorf("cannot specify gRPC port without specifying an IP address for --core.ip")
}
return nil
}

if cmd.Flag(coreGRPCFlag).Changed {
grpc := cmd.Flag(coreGRPCFlag).Value.String()
if cmd.Flag(corePortFlag).Changed {
grpc := cmd.Flag(corePortFlag).Value.String()
cfg.Port = grpc
}

Expand Down
2 changes: 1 addition & 1 deletion nodebuilder/core/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func TestParseFlags(t *testing.T) {
expectError: false,
},
{
name: "core.ip and core.grpc.port",
name: "core.ip and core.port",
args: []string{"--core.ip=127.0.0.1", "--core.port=54321"},
inputCfg: Config{
Port: DefaultPort,
Expand Down

0 comments on commit 9561cb5

Please sign in to comment.