diff --git a/pubtools/_pulp/services/cdn.py b/pubtools/_pulp/services/cdn.py index f5fc947d..64c30c3e 100644 --- a/pubtools/_pulp/services/cdn.py +++ b/pubtools/_pulp/services/cdn.py @@ -45,6 +45,13 @@ def add_service_args(self, parser): "--cdn-arl-template", help="ARL template used for flushing cache by ARL", nargs="*", + # FIXME: combination of nargs='*' and action='append' will + # generate a list of lists, but we just want one flat list. + # We flatten this elsewhere. + # + # When minimum python is >= 3.8, replace this with action="extend" + action="append", + default=[], ) @property @@ -61,6 +68,11 @@ def cdn_client(self): def __get_instance(self): args = self._service_args + + # FIXME: see above comment about action="extend" for python >= 3.8 + # This flattens the list-of-list. + args.cdn_arl_template = [x for y in args.cdn_arl_template for x in y] + if not args.cdn_url: # disable requests made to CDN return None diff --git a/tests/logs/publish/test_publish/test_repo_publish_cache_cleanup_with_arl.txt b/tests/logs/publish/test_publish/test_repo_publish_cache_cleanup_with_arl.txt index 6f49566a..f4949a85 100644 --- a/tests/logs/publish/test_publish/test_repo_publish_cache_cleanup_with_arl.txt +++ b/tests/logs/publish/test_publish/test_repo_publish_cache_cleanup_with_arl.txt @@ -5,6 +5,10 @@ [ INFO] Publish: finished [ INFO] Flush CDN cache: started [ INFO] Flushing cache for repo1: +[ INFO] /bar/fake-ttl/content/unit/1/client/mutable1 +[ INFO] /bar/fake-ttl/content/unit/1/client/mutable2 +[ INFO] /baz/fake-ttl/content/unit/1/client/mutable1 +[ INFO] /baz/fake-ttl/content/unit/1/client/mutable2 [ INFO] /foo/fake-ttl/content/unit/1/client/mutable1 [ INFO] /foo/fake-ttl/content/unit/1/client/mutable2 [ INFO] https://cdn.example.com/content/unit/1/client/mutable1 diff --git a/tests/publish/test_publish.py b/tests/publish/test_publish.py index dc3fc26a..509d5456 100644 --- a/tests/publish/test_publish.py +++ b/tests/publish/test_publish.py @@ -268,6 +268,9 @@ def test_repo_publish_cache_cleanup_with_arl(command_tester): "https://cdn.example.com/", "--cdn-arl-template", "/foo/{ttl}/{path}", + "--cdn-arl-template", + "/bar/{ttl}/{path}", + "/baz/{ttl}/{path}", "--cdn-cert", "/some/path/to/cert", "--cdn-key", @@ -279,6 +282,10 @@ def test_repo_publish_cache_cleanup_with_arl(command_tester): assert [hist.repository.id for hist in fake_pulp.publish_history] == ["repo1"] # flushed the urls and the arls assert sorted(fake_publish.fastpurge_client.purged_urls) == [ + "/bar/fake-ttl/content/unit/1/client/mutable1", + "/bar/fake-ttl/content/unit/1/client/mutable2", + "/baz/fake-ttl/content/unit/1/client/mutable1", + "/baz/fake-ttl/content/unit/1/client/mutable2", "/foo/fake-ttl/content/unit/1/client/mutable1", "/foo/fake-ttl/content/unit/1/client/mutable2", "https://cdn.example.com/content/unit/1/client/mutable1",