Skip to content
This repository was archived by the owner on Jun 13, 2020. It is now read-only.
This repository was archived by the owner on Jun 13, 2020. It is now read-only.

"absent" AppRole fails without "policies" field #134

Description

@skovorodkin

aomi requires AppRole's policiesto be defined even if its state is absent:

approles:
  - name: app
    # policies: [app]
    state: absent

Error:

$ docker run -e VAULT_ADDR=$VAULT_ADDR -v $(pwd)/aomi:/aomi -v $(pwd)/.vault-token:/.vault-token autodesk/aomi:1.6.1 diff --secretfile /aomi/Secretfile --policies /aomi/policies --verbose
Connecting to http://10.0.0.1:8200
Token derived from /.vault-token
Unexpected error: exceptions.KeyError
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/aomi-1.6.1-py2.7.egg/aomi/cli.py", line 439, in main
    action_runner(parser, args)
  File "/usr/local/lib/python2.7/site-packages/aomi-1.6.1-py2.7.egg/aomi/cli.py", line 414, in action_runner
    aomi.seed_action.diff(client.connect(args), args)
  File "/usr/local/lib/python2.7/site-packages/aomi-1.6.1-py2.7.egg/aomi/seed_action.py", line 117, in diff
    ctx = Context.load(get_secretfile(opt), opt) \
  File "/usr/local/lib/python2.7/site-packages/aomi-1.6.1-py2.7.egg/aomi/model/context.py", line 124, in load
    ctx.add(mod(resource, opt))
  File "/usr/local/lib/python2.7/site-packages/aomi-1.6.1-py2.7.egg/aomi/model/auth.py", line 185, in __init__
    'policies': ','.join(obj['policies'])
KeyError: 'policies'

The error happens in AppRole.__init__. I'm not sure what's the correct way to fix it (if it has to be fixed at all), but seems like Policy.__init__ had the same issue and now it inits other fields only if self.present. Perhaps the same could be done in AppRole.__init__ right before role_obj is created.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions