-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
When I rewrote the envvar handling for otel-cli and removed Viper, one of the problems I tried to solve was envvars being read by both otel-cli and the otel collector backend it uses. Otel-cli allows some things that the collector doesn't, and besides, otel-cli can't make any guarantees for code paths that it doesn't test. So, envvars have to be deleted from the os environment to prevent that, but we still need to pass the original env through. The easy path forward is to back up the env early at startup, which happens now, and then have exec and status use that backup instead of os.Environ(). This commit implements that. Squashed commitlog follows: * add a private field to config to backup env * make a copy of env before envvar configuration We have to delete envvars during configuration that might also be read by the OTel collector client. Also, users of otel-cli exec expect envvars including OTEL stuff to pass through so they don't have to do weird backflips to configure embedded exec usage, which is one of the earliest documented features of otel-cli. To accomplish this, refactored the PersistentPreRun func to be a full func instead of inline. Modified it to inject os.Environ() into the private config field before calling the envvar config func. * persist env through to exec and status commands When I rewrote the envvar handling for otel-cli and removed Viper, one of the problems I tried to solve was envvars being read by both otel-cli and the otel collector backend it uses. Otel-cli allows some things that the collector doesn't, and besides, otel-cli can't make any guarantees for code paths that it doesn't test. So, envvars have to be deleted from the os environment to prevent that, but we still need to pass the original env through. The easy path forward is to back up the env early at startup, which happens now, and then have exec and status use that backup instead of os.Environ(). This commit implements that. status was updated to also pass through so it's easier to test. Added a test for pass-through, as well as updated tests that use `status` so they now expect envvars to pass through again.
- Loading branch information
Showing
5 changed files
with
70 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters