Skip to content

Commit

Permalink
Fix attribute access on potential None type
Browse files Browse the repository at this point in the history
Replaces the direct reference to `config.azure_credential` with one
which is guarded against `config` being `None`.

Because `resource_group` was set in a similar manner the code is
combined with the existing code which accessed `config.resource_group`.

Closes BAR-102.

Signed-off-by: Michael Wallace <[email protected]>
  • Loading branch information
mikewallace1979 committed Aug 31, 2023
1 parent 27dfb2a commit 73887a4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions barman/cloud_providers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,14 +295,17 @@ def get_snapshot_interface_from_backup_info(backup_info, config=None):
"backup_info has snapshot provider 'azure' but "
"subscription_id is not set"
)
if config is not None and hasattr(config, "azure_resource_group"):
resource_group = config.azure_resource_group
else:
resource_group = None
resource_group = None
azure_credential = None
if config is not None:
if hasattr(config, "azure_resource_group"):
resource_group = config.azure_resource_group
if hasattr(config, "azure_credential"):
azure_credential = config.azure_credential
return AzureCloudSnapshotInterface(
backup_info.snapshots_info.subscription_id,
resource_group=resource_group,
credential=_get_azure_credential(config.azure_credential),
credential=_get_azure_credential(azure_credential),
)
elif backup_info.snapshots_info.provider == "aws":
from barman.cloud_providers.aws_s3 import AwsCloudSnapshotInterface
Expand Down

0 comments on commit 73887a4

Please sign in to comment.