Support listing and removing user Codespaces secrets#4714
Conversation
When list secret is run outside the context of a tty, the selected repository count is not shown. Since fetching this information is an extra API call per secret, we should skip fetching it when it's not needed.
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Supports #4698
Follow-up to #4699 which adds support for creating user secrets.
This PR adds support for listing and removing Codespaces user secrets. These APIs will require
read:useranduserscopes.https://docs.github.com/en/rest/reference/codespaces#list-secrets-for-the-authenticated-user
https://docs.github.com/en/rest/reference/codespaces#delete-a-secret-for-the-authenticated-user
I've also updated the code that fetches the number of selected repositories for a secret to not run when outside the context of a TTY, since that information is only shown when in a TTY and requires extra API calls - 5b6827a
Testing
I validated that secrets were able to be listed and removed:
JSON API response for comparison
{ "total_count": 2, "secrets": [ { "name": "MY_PAT", "created_at": "2021-10-26T19:17:07.000+00:00", "updated_at": "2021-10-26T19:17:07.000+00:00", "visibility": "selected", "selected_repositories_url": "https://api.github.com/user/codespaces/secrets/MY_PAT/repositories" }, { "name": "COOL_SECRET", "created_at": "2021-11-07T20:55:53.000+00:00", "updated_at": "2021-11-11T03:34:15.000+00:00", "visibility": "selected", "selected_repositories_url": "https://api.github.com/user/codespaces/secrets/COOL_SECRET/repositories" } ] }