Skip to content

Commit

Permalink
Rename CloudInterface.destination_url to a more generic url
Browse files Browse the repository at this point in the history
Signed-off-by: Gabriele Bartolini <gabriele.bartolini@2ndQuadrant.it>
  • Loading branch information
gbartolini committed Jan 2, 2020
1 parent 52eb43e commit 3fce054
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion barman/clients/cloud_backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def main(args=None):

with closing(postgres):
cloud_interface = CloudInterface(
destination_url=config.destination_url,
url=config.destination_url,
encryption=config.encryption,
jobs=config.jobs,
profile_name=config.profile)
Expand Down
2 changes: 1 addition & 1 deletion barman/clients/cloud_walarchive.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def main(args=None):

try:
cloud_interface = CloudInterface(
destination_url=config.destination_url,
url=config.destination_url,
encryption=config.encryption,
profile_name=config.profile)

Expand Down
10 changes: 5 additions & 5 deletions barman/cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,26 +412,26 @@ def set_part_start_time(self, part_number, start_time):


class CloudInterface(object):
def __init__(self, destination_url, encryption, jobs=2, profile_name=None):
def __init__(self, url, encryption, jobs=2, profile_name=None):
"""
Create a new S3 interface given the S3 destination url and the profile
name
:param str destination_url: Full URL of the cloud destination
:param str url: Full URL of the cloud destination/source
:param str|None encryption: Encryption type string
:param int jobs: How many sub-processes to use for asynchronous
uploading, defaults to 2.
:param str profile_name: Amazon auth profile identifier
"""
self.destination_url = destination_url
self.url = url
self.profile_name = profile_name
self.encryption = encryption

# Extract information from the destination URL
parsed_url = urlparse(destination_url)
parsed_url = urlparse(url)
# If netloc is not present, the s3 url is badly formatted.
if parsed_url.netloc == '' or parsed_url.scheme != 's3':
raise ValueError('Invalid s3 URL address: %s' % destination_url)
raise ValueError('Invalid s3 URL address: %s' % url)
self.bucket_name = parsed_url.netloc
self.bucket_exists = None
self.path = parsed_url.path
Expand Down
16 changes: 8 additions & 8 deletions tests/test_cloud.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_uploader_minimal(self, boto_mock):
Minimal build of the CloudInterface class
"""
cloud_interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None)
assert cloud_interface.bucket_name == 'bucket'
assert cloud_interface.path == '/path/to/dir'
Expand All @@ -60,7 +60,7 @@ def test_uploader_minimal(self, boto_mock):
def test_ensure_async(self, mp):
jobs_count = 30
interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None,
jobs=jobs_count)

Expand All @@ -85,7 +85,7 @@ def test_ensure_async(self, mp):

def test_retrieve_results(self):
interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None)
interface.queue = Queue()
interface.done_queue = Queue()
Expand Down Expand Up @@ -207,7 +207,7 @@ def test_worker_process_main(self, worker_process_execute_job_mock):
]

interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None)
interface.queue = mock.MagicMock()
interface.errors_queue = Queue()
Expand Down Expand Up @@ -255,7 +255,7 @@ def test_worker_process_execute_job(self,
# Unknown job type, no boto functions are being called and
# an exception is being raised
interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None)
interface.result_queue = Queue()
interface.done_queue = Queue()
Expand Down Expand Up @@ -312,7 +312,7 @@ def test_handle_async_errors(self):
# If we the upload process has already raised an error, we immediately
# exit without doing anything
interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None)
interface.error = "test"
interface.errors_queue = None # If get called raises AttributeError
Expand Down Expand Up @@ -342,7 +342,7 @@ def test_async_upload_part(self,
temp_stream.name = temp_name

interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None)
interface.queue = Queue()
interface.async_upload_part(
Expand All @@ -369,7 +369,7 @@ def test_async_complete_multipart_upload(self,
handle_async_errors_mock,
retrieve_results_mock):
interface = CloudInterface(
destination_url='s3://bucket/path/to/dir',
url='s3://bucket/path/to/dir',
encryption=None)
interface.queue = mock.MagicMock()
interface.parts_db = {
Expand Down

0 comments on commit 3fce054

Please sign in to comment.