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

Add Github Actions Secrets to organization #2006

Merged
merged 1 commit into from Oct 13, 2021

Conversation

peresypkinamarina
Copy link
Contributor

@peresypkinamarina peresypkinamarina commented Jul 27, 2021

Add functionality to create and delete Secrets for Organizations.
Usage:

g.get_organization("test").create_secret("secret-name", "unencrypted-value", visibility=all/private/selected, selected_repository_ids=[]) # selected_repository_ids in case when visibility=selected
g.get_organization("test").delete_secret("secret-name")

@peresypkinamarina
Copy link
Contributor Author

@s-t-e-v-e-n-k Could you please check it?

Copy link
Collaborator

@s-t-e-v-e-n-k s-t-e-v-e-n-k left a comment

Choose a reason for hiding this comment

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

This is looking excellent, I just have one issue before merging.

secret_name,
unencrypted_value,
visibility="all",
selected_repository_ids=[],
Copy link
Collaborator

Choose a reason for hiding this comment

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

It feels more true to our interpretation of the API to call this selected_repositories and then allow users to pass either Repository objects or ids, and then transform them to a list of IDs when we make the PUT request.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@s-t-e-v-e-n-k Thank you for review.
I made changes to pass list of repos, similar approach as in Organization.create_team. Please check it

Copy link
Collaborator

@s-t-e-v-e-n-k s-t-e-v-e-n-k left a comment

Choose a reason for hiding this comment

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

Loving the direction, I just have a few more concerns.

"encrypted_value": payload,
"visibility": visibility,
}
if selected_repositories:
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't guarded like the assert check, which means that if you don't pass visibility and do pass selected_repositories something that isn't a list of Repository objects, then we throw an exception.

Do we need to be more careful here and assert that it's an empy list (or NotSet) if visibility isn't selected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, it this was not covered, thanks
Made changes to handle cases:
visibility==selected and selected_repositories is NotSet
visibility!=selected and selected_repositories is not NotSet

@s-t-e-v-e-n-k Please check it

secret_name: str,
unencrypted_value: str,
visibility: str,
selected_repositories: List[Repository],
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you need to mark the visibility parameter with it's default value. Also, what does type checking return if you call create_secret() with no selected_repositories?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Marked and set NotSet as default value for selected_repositories

@s-t-e-v-e-n-k
Copy link
Collaborator

Lint failed, fix that up and we can get this merged.

@peresypkinamarina
Copy link
Contributor Author

Lint failed, fix that up and we can get this merged.

@s-t-e-v-e-n-k fixed, please check

@s-t-e-v-e-n-k
Copy link
Collaborator

Type hints this time:

  lint run-test: commands[1] | mypy github tests
  github/Organization.pyi:144: error: Name "PublicKey" is not defined

@peresypkinamarina
Copy link
Contributor Author

lint run-test: commands[1] | mypy github tests

fixed, please trigger check again

@s-t-e-v-e-n-k s-t-e-v-e-n-k merged commit bc5e595 into PyGithub:master Oct 13, 2021
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.

None yet

2 participants