Pass process environment variables by reference#4702
Pass process environment variables by reference#4702rhatdan merged 2 commits intocontainers:mainfrom
Conversation
See: containers#4688 Signed-off-by: Chris Bandy <bandy.chris@gmail.com>
See: containers#4688 Signed-off-by: Chris Bandy <bandy.chris@gmail.com>
|
I should have opened this as a draft. This is only part of what has been discussed in #4688 because I quickly found differences in how the flags work across different commands.
@rhatdan I stopped implementing after (2) for feedback. Which of the three behaviors in (1), (2), and (3) should I use while implementing (1) ? Should I alter the other (either 2 or 3) to match? |
|
/approve |
| CNIConfigDir: iopts.CNIConfigDir, | ||
| AddCapabilities: iopts.capAdd, | ||
| DropCapabilities: iopts.capDrop, | ||
| Env: iopts.env, |
There was a problem hiding this comment.
I'm surprised this isn't being used elsewhere and that it's not complaining loudly...
| CNIConfigDir: iopts.CNIConfigDir, | ||
| AddCapabilities: iopts.capAdd, | ||
| DropCapabilities: iopts.capDrop, | ||
| Env: iopts.env, |
There was a problem hiding this comment.
The line below can be just used here, no reason to break it out.
Env: buildahcli.LookupEnvVarReferences(iopts.env, os.Environ())
| // | ||
| // - When a string in specs is exactly "*", all keys and values in environ | ||
| // are returned. | ||
| func LookupEnvVarReferences(specs, environ []string) []string { |
There was a problem hiding this comment.
Are you planning on making podman use this function as well?
There was a problem hiding this comment.
I have no plans for that. It would be nice for Buildah and Podman to do these things consistently, but the tools satisfy different use cases.
I encountered difficulty making env flags consistent within Buildah.
|
Since I want to get this into release, I am merging. But we could do some minor cleanups and add tests. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: cbandy, rhatdan, TomSweeneyRedHat The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
Sorry for the delay. I was expecting a response to this question:
|
|
@flouthoc Could you make these common between the two packages. |
|
Already modified podman to use this from buildah's package here: containers/podman#18130 |
What type of PR is this?
/kind api-change
Which issue(s) this PR fixes:
buildah run#4688Special notes for your reviewer:
This PR contains only some of the changes discussed in #4688.
Does this PR introduce a user-facing change?
The first commit allows
buildah run --envto lookup environment variables from the process environment using a rudimentary "glob" syntax.The second commit does the same for
buildah build --env, but alters the behavior when only a key is passed. Prior to this change, passing--env Awhen noAis defined in the environment setsA=(blank) in the container. After this change,Aremains unset in the container.