-
Notifications
You must be signed in to change notification settings - Fork 23.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Heroku collaborator module #39001
Heroku collaborator module #39001
Conversation
The test
The test
The test
|
The test
|
0e39558
to
12d1161
Compare
ready_for_review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for PR.
@@ -0,0 +1,142 @@ | |||
#!/usr/bin/python | |||
|
|||
# Copyright: Ansible Project |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copyright: (c) 2018, Ansible Project
required: true | ||
state: | ||
description: | ||
- Create or remove the heroku collaborator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add description like with all possible combinations -
If set to C(present) and heroku user is already collaborator, then ...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, we added requested documentation.
default: "present" | ||
notes: | ||
- C(HEROKU_API_KEY) and C(TF_VAR_HEROKU_API_KEY) env variable can be used instead setting c(api_key). | ||
- If you use I(--check), you can also pass the I(-v) flag to see affected apps in msg. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New person will be confused when you refer to msg
, adding a brief description will help.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we tried to add more documentation, but after several tries couldn't get YAML to validate. If you think that our current suggestion is still not acceptable, we would appreciate your help.
- { user: 'x.y@example.com', apps: ["heroku-example-app"] } | ||
''' | ||
|
||
RETURN = ''' # ''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return is not compulsory but will help end user to understand return value of module.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation says:
If your module doesn't return anything (apart from the standard returns), you can use ``RETURN = ''' # '''``.
Our module indeed doesn't return anything apart from the standard returns (msg
). If you think that we should document something we would appreciate further hints.
|
||
import os | ||
|
||
DEPENDENCY_CHECK = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might want to change to HAS_HEROKU
to match other Ansible modules code.
def main(): | ||
module = AnsibleModule( | ||
argument_spec=dict( | ||
api_key=dict(default=os.getenv('HEROKU_API_KEY', os.getenv('TF_VAR_HEROKU_API_KEY')), type='str'), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use env_fallback
from ansible.module_utils.basic import env_fallback
...
api_key=dict(fallback=(env_fallback, ['HEROKU_API_KEY', TF_VAR_HEROKU_API_KEY']), type='str', no_log=True),
module.fail_json(msg='Heroku authentication failure, please check your API Key') | ||
|
||
# Prevent API key from appearing in debug logs | ||
del module.params['api_key'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no_log=True
is argument spec will handle this.
supports_check_mode=True | ||
) | ||
|
||
if not DEPENDENCY_CHECK: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One suggestion, it will be helpful to create a common library under module_utils so that in future all Heroku module will use same like DigitalOcean or influxdb.
@Akasurde thank you very much for your review and hints, we have implemented everything to the best of our knowledge. ready_for_review |
LGTM. We need one more person to take a look and then we are good to go. |
Hi @Akasurde, do you think you could help us to find a second reviewer? Quite honestly we're not quite sure as to how to proceed. Many thanks! |
@resmo @ryansb @willthames Could you please provide your valuable reviews ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong license in module_utils is a blocker. Few minor things noted but would not hold it back. looks good to me when module_utils code is bsd licensed.
lib/ansible/module_utils/heroku.py
Outdated
@@ -0,0 +1,38 @@ | |||
# Copyright: (c) 2018, Ansible Project | |||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blocker: code under module_utils/* has to be BSD licensed.
- If set to C(present) and heroku user is not collaborator, then add user to app. | ||
- If set to C(absent) and heroku user is collaborator, then delete user from app. | ||
author: | ||
- Marcel Arns <marcel.arns@moneymeets.com> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker, but please replace your mail with your github handle.
- Suppress email invitation when creating collaborator | ||
type: bool | ||
required: false | ||
default: "False" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker, but it looks better in the docs if you use (yes/no) for type bool.
api_key: | ||
description: | ||
- Heroku API key | ||
required: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a blocker, but requried=false is the default and can be omitted.
6f01c92
to
6c435d7
Compare
@resmo thank you for the review, we have addressed your comments in 6f01c92. We have also rebased the PR against latest devel and squashed fixup commits. We have noticed that changelogs are apparently automatically generated now, so we have removed the changelog commit. If we've got it wrong, we will appreciate further guidance on your part. Many thanks! |
shipit |
SUMMARY
This module allows managing Heroku app collaborators. Heroku doesn't offer an interface that provides overview across all organization apps, therefore managing collaborators without Ansible is difficult and error-prone. The module solves this problem.
ISSUE TYPE
COMPONENT NAME
heroku_collaborator