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

feat: Automatic token provisioning on deploy #178

Merged
merged 6 commits into from
Nov 11, 2023
Merged

Conversation

arnauorriols
Copy link
Member

@arnauorriols arnauorriols commented Oct 6, 2023

Notes on the current implementation

@CLAassistant
Copy link

CLAassistant commented Oct 6, 2023

CLA assistant check
All committers have signed the CLA.

Comment on lines +101 to +110
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;
}
Copy link
Member

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

Copy link
Member Author

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?

Copy link
Member Author

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?

Copy link
Member

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

Copy link
Member

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?

Copy link
Member Author

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in 4d28c6a

FTR though, #188


async function provision(): Promise<string> {
const spinnerInterrupted = interruptSpinner();
wait("").start().info("Provisioning a new access token...");
Copy link
Member

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:

  1. starting the spinner with no message along the spinner
  2. 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

Copy link
Member Author

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).

Copy link
Member Author

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)

Copy link
Member

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

Copy link
Member

@satyarohith satyarohith left a 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

@arnauorriols arnauorriols merged commit 420376e into main Nov 11, 2023
13 checks passed
@arnauorriols arnauorriols deleted the token-provisioning branch November 11, 2023 00:45
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.

4 participants