26 Commits

Author SHA1 Message Date
e9fb805522 update golangci/golangci-lint to v1.63.4
Fix new issues found by usetesting, mainly we should use t.TempDir() in
test which makes the code better as this will be removed on test end
automatically so no need for defer or any error checking.
Also fix issues reported by exptostd, these mainly show where we can
switch the imports to the std maps/slices packages instead of the
golang.org/x/exp/... packages.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2025-01-07 15:48:53 +01:00
d8bb637050 pkg/env.Join(): don't modify passed-in maps
Make sure that env.Join() doesn't modify passed-in maps by cloning them
and using only the clones.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2024-02-29 11:47:44 -05:00
39e53e6dcf chore: extract duplicate codes
Signed-off-by: xiaowu.zhu <xiaowu.zhu@daocloud.io>
2024-01-29 10:10:26 +08:00
522934d5cf Replace strings.SplitN with strings.Cut
Cut is a cleaner & more performant api relative to SplitN(_, _, 2) added in go 1.18

Previously applied this refactoring to buildah:
https://github.com/containers/buildah/pull/5239

Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-11 13:50:15 +00:00
2a2d0b0e18 chore: delete obsolete // +build lines
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-04 11:53:38 +02:00
617af9bea9 Revert "feat(env): support multiline in env-file"
This reverts commit 170a78631b4b0a0e5963e860cc3c3b297b4a7d09.

This was a breaking change and users are hitting it,
see https://github.com/containers/podman/issues/19565

Fixes #19565

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-04 17:06:21 +02:00
9599589f18 Revert "fix(env): parsing --env incorrect in cli"
This reverts commit 7ce654fea39195fae9f7f8d2cb1112b731e67fc3.

see https://github.com/containers/podman/issues/19565

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-04 17:06:05 +02:00
7ce654fea3 fix(env): parsing --env incorrect in cli
Signed-off-by: Black-Hole1 <bh@bugs.cc>
2023-08-09 18:52:30 +08:00
53d44a65e5 Check tty flag to set default terminal in Env
First, all the defaults for TERM=xterm were removed from c/common, then accordingly the same will be added if encountered a set tty flag.

Signed-off-by: Chetan Giradkar <cgiradka@redhat.com>
2023-08-03 12:29:21 +01:00
170a78631b feat(env): support multiline in env-file
Close: https://github.com/containers/podman/issues/18724

Signed-off-by: Black-Hole1 <bh@bugs.cc>
2023-07-31 09:59:45 +08:00
260bc3ec4c vendor: bump containers/(storage, common, buildah, image)
Bump containers/(storage, common, buildah and image)

Changes since 2023-01-01:
 - skip mount-cache-selinux-long-name test under remote, with
   a FIXME requesting that someone see if it can be made to work.

 - skip six tests that fail under rootless-remote

 - add new --build-arg-file option:
 - update man page

Squash of:
* cf56eb1865
* 561f082772

Signed-off-by: Ed Santiago <santiago@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Aditya R <arajan@redhat.com>
2023-04-10 17:30:14 +05:30
72966a32cd [CI:DOCS] Fix spelling and typos
Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2022-11-19 16:26:00 +01:00
2c63b8439b Fix stutters
Podman adds an Error: to every error message.  So starting an error
message with "error" ends up being reported to the user as

Error: error ...

This patch removes the stutter.

Also ioutil.ReadFile errors report the Path, so wrapping the err message
with the path causes a stutter.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-09-10 07:52:00 -04:00
65efcdf709 Allow podman to run in an environment with keys containing spaces
Fixes: https://github.com/containers/podman/issues/15251

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-08-23 14:44:23 -04:00
a46f798831 pkg: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

[NO NEW TESTS NEEDED]

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-08 08:54:47 +02:00
245151e62d Add more unit tests
Improve "code coverage" with more unit-tests.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2022-05-04 08:29:54 -05:00
68b94338ba linter: enable makezero
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-22 13:04:35 +01:00
ea08765f40 go fmt: use go 1.18 conditional-build syntax
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-03-18 09:11:53 +01:00
4693fc6db1 Implement env parsing on Windows
Fixes #12056
Also, enables existing parsing logic for all Unix derived OSs

Signed-off-by: Jason T. Greene <jason.greene@redhat.com>
2022-01-19 12:05:04 -06:00
185294cb8c Generate kube should'd add podman default environment vars
Currently we add the default PATH, TERM and container from Podman
to every kubernetes.yaml file. These values should not be recorded
in the yaml files.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-21 09:03:31 -04:00
a7e864e6e7 Ensure DefaultEnvVariables is used in Specgen
When we rewrote Podman's pkg/spec, one of the things that was
lost was our use of a set of default environment variables, that
ensure all containers have at least $PATH and $TERM set.

While we're in the process of re-adding it, change it from a
variable to a function, so we can ensure the Join function does
not overwrite it and corrupt the defaults.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-08-18 15:17:46 -04:00
70e6b2e6dd make env handling os dependent
environment variables are handled differently on windows vs linux.  here we split them to be handled but no actually processing of windows environment variables was done.  it can be added for future.  hoowever, now we dont get errors on windows about processing them.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-06-02 08:28:08 -05:00
797da2a57b Merge pull request #5381 from vrothberg/ENVFIX
env: set "container" to current binary
2020-03-04 13:26:48 -05:00
6d2d6898f8 env: don't set "container" env
Leave setting the "container" variable to consumers of pkg/env.
Podman is now hard-setting it to "podman" while "libpod" will
set it internally to "libpod" if it's unset.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-03-04 17:07:47 +01:00
822d5a486a avoid adding to nil map
we need to make the environment map to avoid throwing an error when trying to add an environment value from file.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-03-03 17:00:50 -06:00
ad8e0e5e49 consolidate env handling into pkg/env
Env-variable related code is scattered across several packages making it
hard to maintain and extend.  Consolidate the code into a new pkg/env
package.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-03-03 11:47:24 +01:00