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

Added the ability to work with secrets in the CLI. set, delete and get list of all secrets keys, per region. #100

Merged
merged 4 commits into from
Sep 10, 2024

Conversation

Shaharshaki2
Copy link
Contributor

No description provided.

@Shaharshaki2 Shaharshaki2 self-assigned this Sep 9, 2024
Copy link
Contributor

@maorb-dev maorb-dev left a comment

Choose a reason for hiding this comment

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

Very good job, now lets get it perfect.

value = await PromptService.promptForHiddenInput(
'value',
'Enter value for secret variable',
'You must enter a value value',
Copy link
Contributor

Choose a reason for hiding this comment

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

"value value"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It was also in env.ts. Fix that for both

src/commands/code/secret.ts Outdated Show resolved Hide resolved
src/commands/code/secret.ts Show resolved Hide resolved
key = await promptForKeyIfNotProvided(mode, appId, key);
value = await promptForValueIfNotProvided(mode, value);
this.preparePrintCommand(this, { appId, mode, key, value, region: selectedRegion });
console.log("1")
Copy link
Contributor

Choose a reason for hiding this comment

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

as you can see here, and further down the road, it's a best practice to use the commit modal in Webstorm and "cherry pick" specific changes that would go on the commit, reverting unwanted things like console logs or leaving them un-commited locally just for debugging.
If you're not familiar with that, lets sit together for 10 mins.

also, you see our code base has automatically enforced standarts- below you see an automatic message for lint/prettier errors - using double quotes "" instead of single quotes ''.

But anyway, to "pass the code-review" you'll have to do some fixes, start by removing all the unneeded console logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, i'm writing to me to talk with you about the "cherry pick".

LIST_KEYS = 'list-keys',
SET = 'set',
DELETE = 'delete',
}
Copy link
Contributor

Choose a reason for hiding this comment

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

this is identical to what we have in "Env" - is there any reason to duplicate this file and contents, instead of re-using what we already have?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I though that it will be the best to separate between those two action, because maybe in the future we would like to change some management mode only for one of them and not for the other. Let me know if you still think this duplication isn't necessary.

Copy link
Contributor

Choose a reason for hiding this comment

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

I understand, but this goes for everything really- but for types, interfaces, enums, consts and things that are "general" (i.e not business logic code) - we try to re-use what we can.
If we need to in the future, we can expand on that.


import { listAppSecretKeysResponseSchema } from 'services/schemas/manage-app-secret-service-schemas';

export type ListAppSecretKeysResponse = z.infer<typeof listAppSecretKeysResponseSchema>;
Copy link
Contributor

Choose a reason for hiding this comment

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

did you get a chance to look at some Zod documentation?
do you understand what this line of code does?

If not, it's a good example of something simple you can give to AI like ChatGPT and get some explanations of these under-the-hood operations. 🔍

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I read about Zod earlier. I added to my "todo list" to go through the documentation deeper.

Copy link
Contributor

Choose a reason for hiding this comment

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

I dont see a great value in going over the documentation in general- BUT- try to look through the CLI project and see usages of zod for validation, and definitions of zod schemas. If something isn't super-clear from the code, look it up in the documentation.

Specifically for this line that is the intention, because it uses a couple of typescript + zod magic tricks - so just make sure it makes sense for you.

* When setting or deleting value in specific region, list-keys for this region and not the default region.

* refactor the management mode and flags to handle for both secrets and env variables.
Copy link
Contributor

@maorb-dev maorb-dev left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@Shaharshaki2 Shaharshaki2 merged commit 6f3b3cf into master Sep 10, 2024
2 checks passed
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.

2 participants