Skip to content

CLI vs env vars #328

Description

@fredbi

Tracing here a thread in PR, for follow-up:

while we're in initConfig, could the viper.AutomaticEnvironment call get moved next to where viper parses the config file if present and before values are read out of viper into the config = newConfig() object?
there's something lurking about initConfig that bothers me. encoding that the generated config file must be at the same location as the config file read by initConfig is probably part of it, but i don't think that's the entire story..
.. that datamonFlags.context.Descriptor.Name is set either by env variable or flag could be part of it, although i suspect it's a combination of things.

@ransomw1c here is a more complete explanation about what is wrong with env-driven config here, why I did not change it at this time (because this requires some extra changes and some agreement) and a proposal to go. Please advise.

have considered the overall golang arg parse situation at more length over the weekend.
as far as environment variables are concerned, being able to encode a direct env var to config correspondence rather than this string munging mapping (via prefix or anything else) would be more in accord with my prior expectations from, e.g., Click.
a more drastic opinion is that all golang programs might as well be parameterized by either
a simple ARGBEGIN/ARGEND or optarg sort of for-switch construction
or
a config file, either standard unix .conf style or .yaml, plus validation routines.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions