Repository navigation
Add consul acl state - #49261
Add consul acl state#49261
Conversation
cachedout
left a comment
There was a problem hiding this comment.
Could you please fix these lint errors? https://jenkinsci.saltstack.com/job/pr-lint/job/PR-49261/1/warnings52Result/new/
|
hello @cachedout done ;) |
|
#49232 has been merged :) |
rallytime
left a comment
There was a problem hiding this comment.
I have some small change requests here.
| # -*- coding: utf-8 -*- | ||
| ''' | ||
| Consul Managemnt | ||
| =========================== |
There was a problem hiding this comment.
This header (====) needs to match the number of characters in the Consul Management title, otherwise the doc build will output a warning.
There's also a typo in the heading. Management.
| ''' | ||
| return True if the acl need to be update, False if it doesn't need to be update | ||
| ''' | ||
| r = __salt__['consul.acl_info'](id=id, token=token, consul_url=consul_url) |
There was a problem hiding this comment.
I know this is picky, but can you change these variable references to be at least 3 letters? It's a stylistic standard we like to have at Salt. ret is fine.
This needs to be changed in some of the other functions below as well.
|
|
||
| def _acl_exists(name=None, id=None, token=None, consul_url=None): | ||
| ''' | ||
| return True if acl exist, if False it not |
There was a problem hiding this comment.
If acl exists, return True. Otherwise, return False. might be a little more clear here.
| elif name: | ||
| r = __salt__['consul.acl_list'](token=token, consul_url=consul_url) | ||
|
|
||
| if len(r['data']): |
There was a problem hiding this comment.
Can if r.get('data') work here instead of len? That might be a little more clear here.
| if not exists['result']: | ||
| if __opts__['test']: | ||
| ret['result'] = None | ||
| ret['comment'] = "the acl doesn't exist, it will be create" |
| if changes: | ||
| if __opts__['test']: | ||
| ret['result'] = None | ||
| ret['comment'] = "the acl exist, but it need to be update" |
There was a problem hiding this comment.
the acl exists and will be updated
| if exists['result']: | ||
| if __opts__['test']: | ||
| ret['result'] = None | ||
| ret['comment'] = "the acl exists, it will be delete" |
|
@rallytime thx for the review, i will take a look at it as soon as i can |
|
|
||
| def _acl_exists(name=None, id=None, token=None, consul_url=None): | ||
| ''' | ||
| If acl exists, return True. Otherwise, return False. |
There was a problem hiding this comment.
I think this is a little misleading. This function seems to return a dictionary and this makes it seem like the return itself is actually a boolean.
There was a problem hiding this comment.
tell me if the description is more clear now
|
|
||
| def _acl_exists(name=None, id=None, token=None, consul_url=None): | ||
| ''' | ||
| If acl exists, return True. Otherwise, return False. |
There was a problem hiding this comment.
This seems misleading. This makes it seem like the function returns a boolean when it actually returns a dictionary.
|
@cachedout @rallytime thx, is this possible to backport this PR in 2017.7 ? |
|
Hi @remijouannet - We only accept/back-port bug fixes in the dot branches so this won't be backported. You can use dynamic module distribution to use this earlier on your own, however. |
|
ho, ok no problem |
|
@remijouannet It will be in the release codenamed |
|
ok thx for the answer |
What does this PR do?
add a consul module state with the following function
this PR depend from this one #49232
because it need consul.acl_info
Tests written?
No
I'm already using this in production, the idea is the acl are fully manage by salt
all i have is this state consul/acl.sls
and all the acl are define in pillar
so when i have to update or create an acl, i just have to edit the pillar and use the state my consul.acl