From 9dca2bd3c4fbc176d38ed14c8fdb79e3db218a6d Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 26 Nov 2019 06:59:13 +0530 Subject: [PATCH] collection: Provide additional info about collection name restriction (#65250) Fixes: #65151 Signed-off-by: Abhijeet Kasurde --- changelogs/fragments/collection_error_fix.yml | 2 ++ lib/ansible/galaxy/collection.py | 5 ++++- lib/ansible/utils/collection_loader.py | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/collection_error_fix.yml diff --git a/changelogs/fragments/collection_error_fix.yml b/changelogs/fragments/collection_error_fix.yml new file mode 100644 index 00000000000..00f6c0876cb --- /dev/null +++ b/changelogs/fragments/collection_error_fix.yml @@ -0,0 +1,2 @@ +minor_changes: +- Provides additional information about collection namespace name restrictions (https://github.com/ansible/ansible/issues/65151). diff --git a/lib/ansible/galaxy/collection.py b/lib/ansible/galaxy/collection.py index b3e150fb0af..0569605a3de 100644 --- a/lib/ansible/galaxy/collection.py +++ b/lib/ansible/galaxy/collection.py @@ -454,7 +454,10 @@ def validate_collection_name(name): if AnsibleCollectionRef.is_valid_collection_name(collection): return name - raise AnsibleError("Invalid collection name '%s', name must be in the format .." % name) + raise AnsibleError("Invalid collection name '%s', " + "name must be in the format .. " + "Please make sure namespace and collection name contains " + "characters from [a-zA-Z0-9_] only." % name) @contextmanager diff --git a/lib/ansible/utils/collection_loader.py b/lib/ansible/utils/collection_loader.py index 81e3f4fac02..ec496524b5b 100644 --- a/lib/ansible/utils/collection_loader.py +++ b/lib/ansible/utils/collection_loader.py @@ -474,7 +474,7 @@ class AnsibleCollectionRef: @staticmethod def is_valid_collection_name(collection_name): """ - Validates if is string is a well-formed collection name (does not look up the collection itself) + Validates if the given string is a well-formed collection name (does not look up the collection itself) :param collection_name: candidate collection name to validate (a valid name is of the form 'ns.collname') :return: True if the collection name passed is well-formed, False otherwise """