Skip to content
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

Module 1 & 2 #18

Closed
wants to merge 2 commits into from
Closed

Conversation

jacobeicher
Copy link

@jacobeicher jacobeicher commented Jan 27, 2022

addresses #1 and #2


- name: Configure integration test run
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot accept this PR with this integration workflow present/active.

eval "echo \"$content\""
}

main "$@"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add newline.

token:
description:
- GitHub API token used to retrieve information
about repositories to which a user has access to
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to which a user has access to -> to which a user has access

current_repo_dict["is_template"] = repo.raw_data["is_template"]

output.append(current_repo_dict)
if module.check_mode:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a blank line above this line.

options:
token:
description:
- GitHub API token used to retrieve information about collaborators in repositories a user has access to
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

repositories a user has access to -> repositories to which a user has access.

Comment on lines 271 to 273
dict_repo.append(collab_output.copy())

output[repo] = dict_repo.copy()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calls to copy seem unnecessary.

Comment on lines 244 to 245
for collaborator in collaborators:
collaborator_list.append(collaborator.login)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a set instead of a list. Using a list results in line 247 having to do a linear search each time it is called.

status = True
for repo in repos:
r = g.get_repo(repo)
for user in user_to_check.items():
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make this more readable do

for user, permission in user_to_check.items() :  
    if r.get_colaborator_permission(user) != permission : 
        ....

r.add_to_collaborators(p, permission=to_add[p])


def check_permissions(g, repos, user_to_check):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not return which user or the repo in which the differences was found. How are playbook authors intended to use check_permissions?

Comment on lines 216 to 217
for p in to_add:
r.add_to_collaborators(p, permission=to_add[p])
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens if the user is already a collaborator?

Comment on lines 211 to 214
collaborator_list = []
collaborators = r.get_collaborators(affiliation="direct")
for collaborator in collaborators:
collaborator_list.append(collaborator.login)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of this is being used. Was the goal to use collaborator_list to control how which users are added?


Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use a consistent version of python in the GitHub workflows. The ansible test workflow is using 3.6.9. Please use 3.9.x for all workflows.

Comment on lines +242 to +243
for p in to_change:
if p in collaborator_set:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

p is a bad variable name. Please change it to something more meaningful.

Comment on lines +247 to +267
def get_collaborators(g, repo):
output = list()
collab_output = dict()
collaborators = g.get_repo(repo).get_collaborators(affiliation="direct")
for collaborator in collaborators:
collab_output['login'] = collaborator.login
collab_output['id'] = collaborator.id
collab_output['type'] = collaborator.type
collab_output['site_admin'] = collaborator.site_admin
permissions = {
'triage': collaborator.permissions.triage,
'push': collaborator.permissions.push,
'pull': collaborator.permissions.pull,
'admin': collaborator.permissions.admin
}
collab_output['permissions'] = permissions

output.append(collab_output)

return output

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code does not work. Please fix the bug and add unit tests that would have found the bug.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

output will be populated with objects that have the same values for all fields.

@jacobeicher jacobeicher closed this Mar 8, 2022
@jacobeicher jacobeicher deleted the squashed branch March 8, 2022 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants