Closed rossmcf closed 5 years ago
Thanks for the diff @rossmcf, it's not a bad high-level idea.
This does more than just "check" though, it will actually populate spec
from the map (the only difference from Process
is the "environment" source). There might be a nasty surprise for someone who constructs their program like this:
Check
against a sample map to make sure the spec
is in good shapeProcess
with the same spec
to actually populate it from the environmentNow if the environment was missing an optional field which had been present in the sample map, they've got a sample test value populated instead of, say, the default
tag value.
If we don't expect users to put this in their production programs (maybe just in a test), it's not any different from them iterating over a map and calling os.Setenv
themselves, then checking with Process
as-is.
This PR adds a function called
Check()
, which allows users to validate keys/values from other sources. This is intended to support the development of other tools, that might check — for example — environment variables defined in docker-compose files.This resolves #126.