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

Simplify golang logic of hyphenated flags and env vars #3169

Open
1 task done
nitrocode opened this issue Feb 25, 2023 · 0 comments
Open
1 task done

Simplify golang logic of hyphenated flags and env vars #3169

nitrocode opened this issue Feb 25, 2023 · 0 comments
Labels
feature New functionality/enhancement Stale

Comments

@nitrocode
Copy link
Member

nitrocode commented Feb 25, 2023

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Describe the user story

I'd like to add a new feature flag to atlantis without having to add it both as a --xyz flag and as an environment variable.

Describe the solution you'd like

Add it in a single place and have it create the flag and the env var.

This will result in less code and fewer contirbutions that forget to add it to one or the other.

See this PR on how to automate it aquasecurity/tfsec#1990

See this for inspiration https://github.com/carolynvs/stingoftheviper/blob/main/main.go

Flags

atlantis/cmd/server.go

Lines 36 to 41 in 1bd5cc2

// To add a new flag you must:
// 1. Add a const with the flag name (in alphabetic order).
// 2. Add a new field to server.UserConfig and set the mapstructure tag equal to the flag name.
// 3. Add your flag's description etc. to the stringFlags, intFlags, or boolFlags slices.
const (
// Flag names.

Env var

// UserConfig holds config values passed in by the user.
// The mapstructure tags correspond to flags in cmd/server.go and are used when
// the config is parsed from a YAML file.
type UserConfig struct {

Describe the drawbacks of your solution

None

Describe alternatives you've considered

None

@nitrocode nitrocode added the feature New functionality/enhancement label Feb 25, 2023
@nitrocode nitrocode changed the title Simplify golang logic of hyphenated flags Simplify golang logic of hyphenated flags and env vars Feb 25, 2023
@dosubot dosubot bot added the Stale label Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New functionality/enhancement Stale
Projects
None yet
Development

No branches or pull requests

1 participant