Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misc!(flags): rename core.grpc.port to core.port #4059

Merged
merged 3 commits into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 18 additions & 7 deletions nodebuilder/core/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
)

var (
coreFlag = "core.ip"
coreIPFlag = "core.ip"
corePortFlag = "core.port"
coreGRPCFlag = "core.grpc.port"
coreTLS = "core.tls"
coreXTokenPathFlag = "core.xtoken.path" //nolint:gosec
Expand All @@ -19,17 +20,23 @@ 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.",
)
flags.String(
coreGRPCFlag,
"",
"Set a custom gRPC port for the core node connection.WARNING: --core.grpc.port is deprecated. "+
"Please use --core.port instead",
)
flags.Bool(
coreTLS,
false,
Expand All @@ -51,16 +58,20 @@ func ParseFlags(
cmd *cobra.Command,
cfg *Config,
) error {
coreIP := cmd.Flag(coreFlag).Value.String()
if cmd.Flag(coreGRPCFlag).Changed {
return fmt.Errorf("the flag is deprecated. Please use --core.port instead")
}

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
8 changes: 4 additions & 4 deletions nodebuilder/core/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ func TestParseFlags(t *testing.T) {
expectError: false,
},
{
name: "core.ip and core.grpc.port",
args: []string{"--core.ip=127.0.0.1", "--core.grpc.port=54321"},
name: "core.ip and core.port",
args: []string{"--core.ip=127.0.0.1", "--core.port=54321"},
inputCfg: Config{
Port: DefaultPort,
},
Expand All @@ -85,8 +85,8 @@ func TestParseFlags(t *testing.T) {
expectError: false,
},
{
name: "core.grpc.port without core.ip",
args: []string{"--core.grpc.port=54321"},
name: "core.port without core.ip",
args: []string{"--core.port=54321"},
expectedCfg: Config{},
expectError: true,
},
Expand Down
Loading