-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: Automatic token provisioning on deploy #178
Conversation
function base64url(binary: Uint8Array): string { | ||
const binaryString = Array.from(binary).map((b) => String.fromCharCode(b)) | ||
.join(""); | ||
const output = btoa(binaryString); | ||
const urlSafeOutput = output | ||
.replaceAll("=", "") | ||
.replaceAll("+", "-") | ||
.replaceAll("/", "_"); | ||
return urlSafeOutput; | ||
} |
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.
Would be good to have a unit test for this
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.
Any suggestion on test cases I should implement?
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.
Also, is there a way to test it while keeping the function private to the module?
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.
No, I don't think so. The test should be in a *_test.ts
file
src/subcommands/logs.ts
Outdated
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.
This PR adds auto-provisioning to deploy
subcommand only, but we'll extend it to other subcommands, right?
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.
Yes. I can add it in this PR as well
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.
|
||
async function provision(): Promise<string> { | ||
const spinnerInterrupted = interruptSpinner(); | ||
wait("").start().info("Provisioning a new access token..."); |
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.
Not really sure how spinner exactly works, but what wait("").start().info("some message")
does is basically:
- starting the spinner with no message along the spinner
- then stopping (and clearing) the spinner with an info message printed
Is this correct? If correct, then starting the spinner will have essentially no effect because it's immediately stopped and cleared - I wonder if we could just use console.info
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.
The beauty of it is that the output is consistent with the rest of spinner result messages (the info/warn icon, the identation, etc).
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.
(this pattern is used everywhere in deployctl)
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 this file should be moved to token_storage/mod.ts
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 tested the changes on mac and It's an amazing experience when the access token is provisioned automatically. Nice work!
LGTM apart from the nits
Notes on the current implementation