Respect --skip-resource when deleting.

When running project cleanup and using the --skip-resource flag, this
flag is only used during the --dry-run stage. This change ensures it is
also used when deleting the resources which fixes the bug mentioned below.

Closes-Bug: #2074109
Change-Id: I8e50fd14dcde069b932cc8ec4bb4fc809f7d2eb7
This commit is contained in:
Tim Bishop 2024-07-22 16:55:34 +01:00
parent b223156906
commit 1d4aabab2e
No known key found for this signature in database
GPG Key ID: 6C226B37FDF38D55
2 changed files with 34 additions and 6 deletions

View File

@ -150,5 +150,8 @@ class ProjectCleanup(command.Command):
self.log.warning(_('Deleting resources'))
project_connect.project_cleanup(
dry_run=False, status_queue=status_queue, filters=filters
dry_run=False,
status_queue=status_queue,
filters=filters,
skip_resources=parsed_args.skip_resource,
)

View File

@ -83,7 +83,12 @@ class TestProjectCleanup(test_utils.TestCommand):
filters=filters,
skip_resources=None,
),
mock.call(dry_run=False, status_queue=mock.ANY, filters=filters),
mock.call(
dry_run=False,
status_queue=mock.ANY,
filters=filters,
skip_resources=None,
),
]
self.project_cleanup_mock.assert_has_calls(calls)
@ -114,7 +119,12 @@ class TestProjectCleanup(test_utils.TestCommand):
filters={},
skip_resources=None,
),
mock.call(dry_run=False, status_queue=mock.ANY, filters={}),
mock.call(
dry_run=False,
status_queue=mock.ANY,
filters={},
skip_resources=None,
),
]
self.project_cleanup_mock.assert_has_calls(calls)
@ -144,7 +154,12 @@ class TestProjectCleanup(test_utils.TestCommand):
filters={},
skip_resources=None,
),
mock.call(dry_run=False, status_queue=mock.ANY, filters={}),
mock.call(
dry_run=False,
status_queue=mock.ANY,
filters={},
skip_resources=None,
),
]
self.project_cleanup_mock.assert_has_calls(calls)
@ -230,7 +245,12 @@ class TestProjectCleanup(test_utils.TestCommand):
filters={},
skip_resources=None,
),
mock.call(dry_run=False, status_queue=mock.ANY, filters={}),
mock.call(
dry_run=False,
status_queue=mock.ANY,
filters={},
skip_resources=None,
),
]
self.project_cleanup_mock.assert_has_calls(calls)
@ -260,7 +280,12 @@ class TestProjectCleanup(test_utils.TestCommand):
filters={},
skip_resources=[skip_resource],
),
mock.call(dry_run=False, status_queue=mock.ANY, filters={}),
mock.call(
dry_run=False,
status_queue=mock.ANY,
filters={},
skip_resources=[skip_resource],
),
]
self.project_cleanup_mock.assert_has_calls(calls)