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: add options for import and delete normalization handling #370

Merged
merged 7 commits into from
Feb 27, 2023

Conversation

alecjacobs5401
Copy link
Contributor

Description

Mitigates #160, #324, #369

Adds two forward-thinking options in lieu of implementing breaking change behavior.

  • minor refactor to move some shared code logic/expectations to a utils package
  • chamber import
    • added the --normalize-keys flag
  • chamber delete
    • added the --preserve-key flag

For the Reviewer

The first two commits are just minor refactors. It is recommended to review by each commit to reduce styling/refactor noise.

Please excuse my Prettier running rampant on README.md

@alecjacobs5401 alecjacobs5401 requested a review from a team as a code owner February 13, 2023 23:43
@alecjacobs5401 alecjacobs5401 requested review from Sabrina0614 and removed request for a team February 13, 2023 23:43
@alecjacobs5401 alecjacobs5401 force-pushed the ajacobs/import-and-delete-normalization branch from 3dd1120 to 86d1325 Compare February 13, 2023 23:53
cmd/delete.go Outdated Show resolved Hide resolved
@mckern mckern self-requested a review February 15, 2023 22:34
README.md Show resolved Hide resolved
Comment on lines +6 to +13
func NormalizeService(service string) string {
return strings.ToLower(service)
}

// NormalizeKey normalizes a provided secret key to a common format
func NormalizeKey(key string) string {
return strings.ToLower(key)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the intent in moving these to a separate package? Since these both just call strings.ToLower(), right now it's just indirection on top of stdlib.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just standardization/normalization. There are separate packages in this repo that rely on the same logic, so was attempting to DRY it out by giving it an interface

Copy link
Contributor

Choose a reason for hiding this comment

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

🤷🏻‍♂️ I'd argue that 2 new methods that both lowercase a string is a worse deal than just using strings.ToLower() when needed buuuuuuut it's not a hill I care about dying on.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Totally fair - I might be overthinking the need to update how or what normalization means in the future and implemented this as a measure.

I may have also thought that the lack of a normalizing function (and just raw strings.ToLower) may have results in missed normalization in the past, which lead me to move towards it

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I can see that; if any of the other normalizion/sanitization happened in these functions, I think it'd make more sense to have them. As they're written right now, they're just 1:1 wrappers around strings.ToLower() without any benefit for the indirection.

Copy link
Contributor

@mckern mckern left a comment

Choose a reason for hiding this comment

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

I'm not going to block on the question I left but I did have a question.

Copy link
Contributor

@Sabrina0614 Sabrina0614 left a comment

Choose a reason for hiding this comment

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

LGTM!

@alecjacobs5401 alecjacobs5401 merged commit 031ac90 into master Feb 27, 2023
@alecjacobs5401 alecjacobs5401 deleted the ajacobs/import-and-delete-normalization branch February 27, 2023 17:05
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.

None yet

3 participants