diff --git a/etcd3gw/client.py b/etcd3gw/client.py index 0f43ea4..43690ce 100644 --- a/etcd3gw/client.py +++ b/etcd3gw/client.py @@ -11,6 +11,7 @@ # under the License. import json +import os import queue import threading import uuid @@ -37,7 +38,7 @@ _EXCEPTIONS_BY_CODE = { requests.codes['precondition_failed']: exceptions.PreconditionFailedError, } -DEFAULT_API_PATH = '/v3alpha/' +DEFAULT_API_PATH = os.getenv('ETCD3GW_API_PATH', '/v3alpha/') class Etcd3Client(object): diff --git a/etcd3gw/tests/test_client.py b/etcd3gw/tests/test_client.py index 39a6df3..7c36c94 100644 --- a/etcd3gw/tests/test_client.py +++ b/etcd3gw/tests/test_client.py @@ -22,17 +22,20 @@ class TestEtcd3Gateway(base.TestCase): def test_client_default(self): client = Etcd3Client() - self.assertEqual("http://localhost:2379/v3alpha/lease/grant", + self.assertEqual("http://localhost:2379%slease/grant" % + client.api_path, client.get_url("/lease/grant")) def test_client_ipv4(self): client = Etcd3Client(host="127.0.0.1") - self.assertEqual("http://127.0.0.1:2379/v3alpha/lease/grant", + self.assertEqual("http://127.0.0.1:2379%slease/grant" % + client.api_path, client.get_url("/lease/grant")) def test_client_ipv6(self): client = Etcd3Client(host="::1") - self.assertEqual("http://[::1]:2379/v3alpha/lease/grant", + self.assertEqual("http://[::1]:2379%slease/grant" % + client.api_path, client.get_url("/lease/grant")) def test_client_bad_request(self):