Added support for passing values read from a file using --file#556
Added support for passing values read from a file using --file#556
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for a --file flag to the esc env set command, allowing users to read values from files or stdin instead of providing them as command-line arguments. Additionally, it fixes a bug where an unnecessary newline was being appended to string values in esc env open and esc env get commands.
- Adds
--fileparameter toesc env setcommand with support for reading from files or stdin (using "-") - Modifies argument validation to allow fewer arguments when
--fileflag is used - Fixes newline handling in string output format for
env openandenv getcommands
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| cmd/esc/cli/env_set.go | Implements --file flag functionality with UTF-8 validation and argument handling changes |
| cmd/esc/cli/env_open.go | Fixes string output format to avoid duplicate newlines and updates help text |
| cmd/esc/cli/env_get.go | Updates help text to include 'string' format option |
| CHANGELOG_PENDING.md | Documents the new --file parameter feature |
pgavlin
left a comment
There was a problem hiding this comment.
These changes need tests. We have a pretty robust test harness for the CLI's code--you can use the tests for env set and the tests for env edit -f for reference. I'd recommend adding tests in a new testdata file (e.g. env-set-file.yaml).
pgavlin
left a comment
There was a problem hiding this comment.
Could use one more test, but LGTM otherwise
rgharris
left a comment
There was a problem hiding this comment.
LGTM other than there may still be a leading newline issue.
|
I was able to reproduce the multiline issue that Robert mentioned. Will take a look into that |
ac42243 to
5c48797
Compare
|
This PR has been shipped in release v0.15.0. |
Description
This PR adds supports for
--file <path>modifier inesc env set.This modifier will read the file in and, if it's a valid string content, will use that to set the value of the specified key.
Usage
the
--fileflag also supports passing "-" to read fromstdinso its consistent with the behavior of--fileflag inesc env editThe flag can be combined with other flags. For example to store a file as a rawstring content and secret:
To simplify reading file content, we fixed a bug where a new line is always being added at the end of the value when using
--value stringinesc env openandesc env get.Users will be able to get the file content from esc.
eg.
Known Issues
--filedoes not currently supports binary files (or any other file that does not contain valid utf-8 characters). These files require special treatment and might be included in another change (see #483)