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

Support casing for environmental keys #18

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

davidblum
Copy link

  • Add new option for upper case or lower case on environmental variables.
  • Add test for new option.

Copy link
Contributor

@orfin orfin left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, especially for introducing test case :-)
It would be great if you could also add to README.md section of running the tests? (maybe some makefile shortcut like $ make test ?)

I'm wondering, why do we need that "case" parameter? Isn't it making the tool more complex? In my original idea, aws-env was exporting ssm parameters just as they are named into ENVs. So if one need uppercase params - he would just name them in that way in SSM:

/prod/DB/USERNAME ==> DB_USERNAME

aws-env.go Outdated
convertCase := flag.String("case", "upper", "Converts ENV Key to upper or lower case")
flag.Parse()

if *convertCase == "upper" || *convertCase == "lower" {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use consts here instead?

aws-env.go Outdated
recursivePtr := flag.Bool("recursive", false, "recursively process parameters on path")
flag.Parse()
recursivePtr := flag.Bool("recursive", false, "recursively process parameters on path")
convertCase := flag.String("case", "upper", "Converts ENV Key to upper or lower case")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use const here instead of "upper"?

aws-env.go Outdated

if *convertCase == "upper" || *convertCase == "lower" {
} else {
log.Fatal("Unsupported case option. Must be 'upper' or 'lower'")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use consts here instead of hardcoding upper/lower?

@davidblum
Copy link
Author

Hi @orfin ! Thanks for the response, I've made your suggested changes. In regard to the "why":

In our environment we had migrated several styles of secrets, passwords, and credentials to SSM. They were of all variety of case (some were all upper, some were lower, and some were even Pascal). To make this simpler we chose to down case all of them before uploading to the SSM. This made them uniform, but broke some of our base scripting that relied on traditional bash ENV variable style.

I felt this was a nice simple change the provided flexibility in accessing the keys, and exporting them as the scripting expected.

Thanks for writing a helpful tool!

Copy link
Contributor

@orfin orfin left a comment

Choose a reason for hiding this comment

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

Sorry for late reply, I've found one bug (BC-break) in your code. Can we fix it and then I will be able to merge PR as I tested rest of your code and its working great!

recursivePtr := flag.Bool("recursive", false, "recursively process parameters on path")
flag.Parse()
recursivePtr := flag.Bool("recursive", false, "recursively process parameters on path")
convertCase := flag.String("case", upper, "Converts ENV Key to upper or lower case")
Copy link
Contributor

Choose a reason for hiding this comment

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

"Case" should not be required and by default it should not change string-case as currently it breaks backward compatibility - it's now by default changing letters case to upper.

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