Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Commit

Permalink
grant role to user: handle admin roles with space
Browse files Browse the repository at this point in the history
Fix 'Unable to add user' when granted role contains a space:

    $ awx-cli send <<EOF
    [
      {
        "asset_type": "organization",
        "name": "MyOrg",
        "asset_relation": {
          "roles": [
            {
              "name": "Inventory Admin",
              "user": ["misc"],
              "team": []
            }
          ]
        }
      }
    ]
    EOF

    ORGANIZATION [MyOrg] ***
    Asset up to date
    Unable to add user misc to Inventory Admin role: The requested object could not be found.
  • Loading branch information
pilou- committed Jun 11, 2019
1 parent 1a0f473 commit 059c195
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tower_cli/resources/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def data_endpoint(cls, in_data, ignore=[]):
else:
endpoint = '/roles/'
if in_data.get('type', False):
data['role_field'] = '%s_role' % in_data['type'].lower()
data['role_field'] = '%s_role' % in_data['type'].replace(' ', '_').lower()
# Add back fields unrelated to role lookup, such as all_pages
for key, value in in_data.items():
if key not in RESOURCE_FIELDS and key not in ['type', 'user', 'team']:
Expand Down

0 comments on commit 059c195

Please sign in to comment.