Skip to content

Commit

Permalink
[2.9] collection: Provide additional info about collection name restr…
Browse files Browse the repository at this point in the history
…iction

Fixes: ansible#65151

Signed-off-by: Abhijeet Kasurde <[email protected]>
(cherry picked from commit 9dca2bd)
  • Loading branch information
Akasurde committed Nov 26, 2019
1 parent 04d32c5 commit 0c6ef80
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/collection_error_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Provides additional information about collection namespace name restrictions (https://github.com/ansible/ansible/issues/65151).
5 changes: 4 additions & 1 deletion lib/ansible/galaxy/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,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 <namespace>.<collection>." % name)
raise AnsibleError("Invalid collection name '%s', "
"name must be in the format <namespace>.<collection>. "
"Please make sure namespace and collection name contains "
"characters from [a-zA-Z0-9_] only." % name)


@contextmanager
Expand Down
2 changes: 1 addition & 1 deletion lib/ansible/utils/collection_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def is_valid_fqcr(ref, ref_type=None):
@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
"""
Expand Down

0 comments on commit 0c6ef80

Please sign in to comment.