diff --git a/api/client.go b/api/client.go index 4688d4d1..6260ebbd 100644 --- a/api/client.go +++ b/api/client.go @@ -378,3 +378,10 @@ func (c *Client) Version(ctx context.Context) (string, error) { return version.Version, nil } + +// BaseURL returns the base URL of the client. +func (c *Client) BaseURL() *url.URL { + // make a copy of the base URL to prevent mutation + base := *c.base + return &base +} diff --git a/api/client_test.go b/api/client_test.go index 23fe9334..9ad7ec59 100644 --- a/api/client_test.go +++ b/api/client_test.go @@ -40,6 +40,9 @@ func TestClientFromEnvironment(t *testing.T) { if client.base.String() != v.expect { t.Fatalf("expected %s, got %s", v.expect, client.base.String()) } + if client.BaseURL().String() != v.expect { + t.Fatalf("expected %s, got %s", v.expect, client.BaseURL().String()) + } }) } }