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

Cavebeavis/add printenvs #81

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

cavebeavis
Copy link

@cavebeavis cavebeavis commented Aug 16, 2021

OVERVIEW

So, have to say I love this tool. Thank you for your work on this! I am in the middle of a major refactor of about 50 services and this was the answer. I made a few modifications to fit my specific use case and some of this may be too specific for your tool but wanted to run these modifications by you in case you liked any of this. Feel free to ask for more general modification to fit your vision, or just say thanks but no thanks if you want -- no worries at all my friend.

So the specifics are I am tooling our golang services to use https://github.com/ardanlabs/conf as our configuration loader and needed our config structures to support the env specific tags like conf:"env:IM_A_ENV". I also needed a simple way to print an env template for our ansible playbooks (company's choice).

I felt it was important for the env to reflect the golang struct name first, then the property next.

SPECIFIC REQUIREMENTS

  • Need support for environmental variable envcase like ENV_VARIABLE in order to refactor current non-docker services to support an .env file.
  • Need to be able to easily print the env template in the ENV_VARIABLE=variable format for the dev-ops team.

ADDITIONAL

  • Updated go.mod to version 1.16
  • Updated go.mod dependencies
  • Updated README.md and tests where applicable.
  • A few minor refactoring -- like splitted to split, and realMain to a run function...
  • Updated README.md for the $field documentation to single quotes in lieu of double quotes (worked on Linux -- to be honest, did not test this on Windows or MAC).

cavebeavis and others added 3 commits August 14, 2021 14:55
- add envcase to addTags, the flag description, README.md, and the test cases
- BREAKING CHANGE: bump go version to 1.16
- update dependencies
feat(template): Add envcase like `ENV_VARIABLE`
…ied envcase

- add `-print-envs` flag which defaults to false in order to print an env template file
- add `-envs-filename` flag to change the default `./.env` file location
- modified envcase to add the struct name at the beginning of the env like: `STRUCT_ENV_VARIABLE`
- modified test cases
- modified README.md
- minor spelling change -- splitted to split
- changed main.go ln 676 from errors.New(fmt.Sprintf(...)) to fmt.Errorf(...) to make the linter a happy camper
@cavebeavis
Copy link
Author

cavebeavis commented Aug 16, 2021

Hold on this -- have some weirdness in the generation of the tag names. Once I sort this out, I will fix this PR...

  • Fix PR

@cavebeavis cavebeavis marked this pull request as draft August 16, 2021 17:52
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.

1 participant