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

Remove not needed GetAddressFromCLIOptions #5742

Merged
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
2 changes: 1 addition & 1 deletion cmd/query/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,7 @@ func TestServerInUseHostPort(t *testing.T) {
func TestServerSinglePort(t *testing.T) {
flagsSvc := flags.NewService(ports.QueryAdminHTTP)
flagsSvc.Logger = zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller()))
hostPort := ports.GetAddressFromCLIOptions(ports.QueryHTTP, "")
hostPort := ports.PortToHostPort(ports.QueryHTTP)
querySvc := makeQuerySvc()
telset := initTelSet(flagsSvc.Logger, jtracer.NoOp(), flagsSvc.HC())
server, err := NewServer(querySvc.qs, nil,
Expand Down
9 changes: 0 additions & 9 deletions ports/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,6 @@ func PortToHostPort(port int) string {
return ":" + strconv.Itoa(port)
}

// GetAddressFromCLIOptions gets listening address based on port (deprecated flags) or host:port (new flags)
func GetAddressFromCLIOptions(port int, hostPort string) string {
if port != 0 {
return PortToHostPort(port)
}

return FormatHostPort(hostPort)
}

// FormatHostPort returns hostPort in a usable format (host:port) if it wasn't already
func FormatHostPort(hostPort string) string {
if hostPort == "" {
Expand Down
21 changes: 0 additions & 21 deletions ports/ports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package ports

import (
"fmt"
"testing"

"github.com/stretchr/testify/assert"
Expand All @@ -27,26 +26,6 @@ func TestPortToHostPort(t *testing.T) {
assert.Equal(t, ":42", PortToHostPort(42))
}

func TestGetAddressFromCLIOptionsLegacy(t *testing.T) {
tests := []struct {
port int
hostPort string
out string
}{
{port: 123, hostPort: "", out: ":123"},
{port: 0, hostPort: "127.0.0.1:123", out: "127.0.0.1:123"},
{port: 0, hostPort: ":123", out: ":123"},
{port: 123, hostPort: "567", out: ":123"},
{port: 0, hostPort: "123", out: ":123"},
{port: 0, hostPort: "", out: ""},
}
for _, test := range tests {
t.Run(fmt.Sprintf("%+v", test), func(t *testing.T) {
assert.Equal(t, test.out, GetAddressFromCLIOptions(test.port, test.hostPort))
})
}
}

func TestFormatHostPort(t *testing.T) {
assert.Equal(t, ":42", FormatHostPort("42"))
assert.Equal(t, ":831", FormatHostPort(":831"))
Expand Down
Loading