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 dep api token crud #1564
Add dep api token crud #1564
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1564 +/- ##
==========================================
+ Coverage 86.41% 86.51% +0.09%
==========================================
Files 113 114 +1
Lines 15668 15918 +250
==========================================
+ Hits 13540 13771 +231
- Misses 1280 1290 +10
- Partials 848 857 +9 ☔ View full report in Codecov by Sentry. |
cloud/apitoken/apitoken.go
Outdated
} | ||
err = astrocore.NormalizeAPIError(resp.HTTPResponse, resp.Body) | ||
if err != nil { | ||
fmt.Println("error in NormalizeAPIError") |
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.
@sunkickr @kushalmalani
do we normally have this here and if so do we want to keep doing it like this?
I'm wondering since it would be meaningless for the user to see, but I guess it would be useful for us if we need to debug
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.
I think most API calls have this but I have never seen it actually come up
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.
Yeah would be useful for debugging. Can we improve that error message though? it looks like a debugging log
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.
tbh it seems unecessary to me as the method that calls it prints out a prettier error message
e.g.
shrividyahegde@Hegde ~ % astro deployment user update --deployment-id clt6yb6vm001r01nmwzffhbs9
Enter a user Deployment role or custom role name to update user: sample
error in NormalizeAPIError
Error: Invalid request: Role sample does not exist
shrividyahegde@Hegde ~ %
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.
I removed them
cloud/apitoken/apitoken.go
Outdated
} | ||
|
||
if apiTokenID == "" { | ||
// Get all org apiTokens. Setting limit to 1000 for now |
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.
// Get all org apiTokens. Setting limit to 1000 for now | |
// Get all deployment apiTokens. Setting limit to 1000 for now |
@shri-astro @sreenusuuda |
Why do we call it remove instead of delete? The api token is being deleted correct? Remove makes it sound like the token is being removed from the deployment but still exists |
Good call. That verbiage was a holdover from remove user/team from deployment (where I was riffing from) but does not fit here. I will update to delete. |
done |
return createDeploymentAPIToken(cmd, nil, out) | ||
}, | ||
} | ||
cmd.Flags().StringVarP(&apiTokenRole, "role", "r", "", "The role for the "+ |
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.
Should DEPLOYMENT_ADMIN be default role?
DynamicPadding: true, | ||
Header: []string{"NAME", "DESCRIPTION", "ID", "DEPLOYMENT ROLE", "CREATE DATE", "UPDATE DATE"}, | ||
} | ||
apiTokens, err := GetDeploymentAPITokens(client, deployment, apiTokenPagnationLimit) |
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.
if there are no api tokens, we should display an error message, rather than an empty table with only headers
Name: name, | ||
Description: &description, | ||
} | ||
resp, err := client.CreateDeploymentApiTokenWithResponse(httpContext.Background(), ctx.Organization, deployment, mutateAPITokenInput) |
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.
we should save the api token from response to ASTRO_API_TOKEN variable. Right now, the token gets created, but user cannot use the token value
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.
will get a pr up for your comments
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.
I think instead of setting it we really want to print it to screen so they can use it where they want to.
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.
worried about the token leaking in ci cd logs...
Description
Adds the ability to manage deployment api tokens including Creation, Removal, Updating the apiToken role, and Listing.
🎟 Issue(s)
Related #18928
🧪 Functional Testing
Use the cli to create, update, remove and delete deployment api tokens passing in the flags that are required and testing both passing in and not passing in the optional flags
📸 Screenshots
📋 Checklist
make test
before taking out of draftmake lint
before taking out of draft