Open
Conversation
Signed-off-by: Marco Slaviero <marco@thinkst.com>
|
can anyone merge this |
mat007
suggested changes
Oct 13, 2021
| // CreateToken creates a Personal Access Token and returns the token field only once | ||
| func (c *Client) CreateToken(description string) (*Token, error) { | ||
| data, err := json.Marshal(hubTokenRequest{Description: description}) | ||
| func (c *Client) CreateToken(description string, scope string) (*Token, error) { |
Member
There was a problem hiding this comment.
nit:
Suggested change
| func (c *Client) CreateToken(description string, scope string) (*Token, error) { | |
| func (c *Client) CreateToken(description, scope string) (*Token, error) { |
Comment on lines
+56
to
+58
| scopes := []string{scope} | ||
| scopes[0] = "repo:" + scope | ||
| tokenRequest.Scopes = scopes |
Member
There was a problem hiding this comment.
Am I missing something? Why can’t it be
Suggested change
| scopes := []string{scope} | |
| scopes[0] = "repo:" + scope | |
| tokenRequest.Scopes = scopes | |
| tokenRequest.Scopes = []string{"repo:" + scope} |
?
| if len(t.Scopes) == 0 { | ||
| return "", 0 | ||
| } | ||
| return t.Scopes[0][5:], len(t.Scopes[0]) - 5 |
Member
There was a problem hiding this comment.
I guess 5 is because it’s the length of "repo:", could we factor out the string and use len()?
Comment on lines
+48
to
+51
| "admin", | ||
| "write", | ||
| "read", | ||
| "public_read": |
Member
There was a problem hiding this comment.
I would extract these into a []string and use it with strings.Join to build the description for the flag l.78
|
Is there new update here? Or code review required? |
Merged
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.
- What I did
Add support for token scopes. Access Tokens created in the web interface can take a single scope value but this isn't available in
hub-tool. This change lets the user create tokens with a specific scope.- How I did it
Two user-facing changes:
--scopeparameter totoken create.token ls- How to verify it
The following calls add tokens with the specified scopes:
Showing the added column in
token ls:- Description for the changelog
Add scope support to access tokens
- A picture of a cute animal (not mandatory)