aboutsummaryrefslogtreecommitdiffstats
path: root/client/go
diff options
context:
space:
mode:
authorMartin Polden <mpolden@mpolden.no>2023-05-19 15:10:49 +0200
committerMartin Polden <mpolden@mpolden.no>2023-05-20 12:19:52 +0200
commit531e4093e0a06c2868ec702c7a0a9235ad54a2c6 (patch)
treeddb0fa7711bf8a4f87c259288ade683b8cf8a3f0 /client/go
parent8a6a790e38145f5295ad55db3681c442bf1410dd (diff)
Only set port for local target
Diffstat (limited to 'client/go')
-rw-r--r--client/go/internal/cli/cmd/status_test.go4
-rw-r--r--client/go/internal/vespa/target_custom.go13
-rw-r--r--client/go/internal/vespa/target_test.go6
3 files changed, 12 insertions, 11 deletions
diff --git a/client/go/internal/cli/cmd/status_test.go b/client/go/internal/cli/cmd/status_test.go
index a3cae7c3fe4..76efea55503 100644
--- a/client/go/internal/cli/cmd/status_test.go
+++ b/client/go/internal/cli/cmd/status_test.go
@@ -16,7 +16,7 @@ func TestStatusDeployCommand(t *testing.T) {
}
func TestStatusDeployCommandWithURLTarget(t *testing.T) {
- assertDeployStatus("http://mydeploytarget:19071", []string{"-t", "http://mydeploytarget"}, t)
+ assertDeployStatus("http://mydeploytarget:19071", []string{"-t", "http://mydeploytarget:19071"}, t)
}
func TestStatusDeployCommandWithLocalTarget(t *testing.T) {
@@ -28,7 +28,7 @@ func TestStatusQueryCommand(t *testing.T) {
}
func TestStatusQueryCommandWithUrlTarget(t *testing.T) {
- assertQueryStatus("http://mycontainertarget:8080", []string{"-t", "http://mycontainertarget"}, t)
+ assertQueryStatus("http://mycontainertarget:8080", []string{"-t", "http://mycontainertarget:8080"}, t)
}
func TestStatusQueryCommandWithLocalTarget(t *testing.T) {
diff --git a/client/go/internal/vespa/target_custom.go b/client/go/internal/vespa/target_custom.go
index 0a3a9d48fed..0129b1e1153 100644
--- a/client/go/internal/vespa/target_custom.go
+++ b/client/go/internal/vespa/target_custom.go
@@ -41,7 +41,7 @@ func (t *customTarget) Deployment() Deployment { return Deployment{} }
func (t *customTarget) createService(name string) (*Service, error) {
switch name {
case DeployService, QueryService, DocumentService:
- url, err := t.urlWithPort(name)
+ url, err := t.serviceURL(name, t.targetType)
if err != nil {
return nil, err
}
@@ -79,20 +79,21 @@ func (t *customTarget) PrintLog(options LogOptions) error {
func (t *customTarget) CheckVersion(version version.Version) error { return nil }
-func (t *customTarget) urlWithPort(serviceName string) (string, error) {
+func (t *customTarget) serviceURL(name string, targetType string) (string, error) {
u, err := url.Parse(t.baseURL)
if err != nil {
return "", err
}
- port := u.Port()
- if port == "" {
- switch serviceName {
+ if targetType == TargetLocal {
+ // Use same ports as the vespaengine/vespa container image
+ port := ""
+ switch name {
case DeployService:
port = "19071"
case QueryService, DocumentService:
port = "8080"
default:
- return "", fmt.Errorf("unknown service: %s", serviceName)
+ return "", fmt.Errorf("unknown service: %s", name)
}
u.Host = u.Host + ":" + port
}
diff --git a/client/go/internal/vespa/target_test.go b/client/go/internal/vespa/target_test.go
index bf266e8f9ec..6dc97f496f5 100644
--- a/client/go/internal/vespa/target_test.go
+++ b/client/go/internal/vespa/target_test.go
@@ -76,9 +76,9 @@ func TestCustomTarget(t *testing.T) {
assertServiceURL(t, "http://127.0.0.1:8080", lt, "document")
ct := CustomTarget(&mock.HTTPClient{}, "http://192.0.2.42", TLSOptions{})
- assertServiceURL(t, "http://192.0.2.42:19071", ct, "deploy")
- assertServiceURL(t, "http://192.0.2.42:8080", ct, "query")
- assertServiceURL(t, "http://192.0.2.42:8080", ct, "document")
+ assertServiceURL(t, "http://192.0.2.42", ct, "deploy")
+ assertServiceURL(t, "http://192.0.2.42", ct, "query")
+ assertServiceURL(t, "http://192.0.2.42", ct, "document")
ct2 := CustomTarget(&mock.HTTPClient{}, "http://192.0.2.42:60000", TLSOptions{})
assertServiceURL(t, "http://192.0.2.42:60000", ct2, "deploy")