Commit Graph

72 Commits

Author SHA1 Message Date
Daniel J Walsh 00631f7fa2 Add support for CONTAINER_CONNECTION environment variable
Users on the MAC have pointed out that they could have multiple connections
to different servers, and they asked to be able to specify the connection
name via environmnet variable rather then to always have to specify the
connection on the command line if they did not want to use the default
setting.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-16 07:06:04 -04:00
Daniel J Walsh fd6f9bf750 Fix problems found by codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-09-12 05:50:05 -04:00
Qi Wang f1c4d645f6 ValidatePullPolicy case-insensitive
Set pullpolicy case-insensitive for fixing https://github.com/containers/podman/issues/7246. And replce the duplicate code in podman with c/common code.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-09-10 17:05:35 -04:00
Sascha Grunert 89b399d4cf Fix all gocritic lints
This enables the missing gocritic checks and fixes all of the lints.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-25 20:58:15 +02:00
Sascha Grunert b494081304 Change fmt.Errorf calls to be replaced by errors package
We now use wrapped errors instead of indirectly wrapping them by
`fmt.Errorf`. The error messages have also been cleaned-up to reduce
duplicate words like `failed`.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-08-25 11:37:12 +02:00
Brent Baude 054d133710 getCustomConfigFile for windows and darwin
podman remote clients that run on windows and darwin cannot use the isRootless to determine the configuration file locations.  here we do by OS and also honor the environment variable.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-08-22 09:11:12 -04:00
Valentin Rothberg f217b00ded multi_image_archive: add option for `podman save`
Add an option to control the default behavior of `podman save` or other
container engines.  If set to "true", the engine will create a
multi-image (docker) archive.  By default, Podman will interpret
additional arguments as tags that'll be stored in the archive's
manifest.  Docker interprets additional arguments as images to allow for
creating multi-image archives.  This option allows users to chose how
they wish the default behavior to look like, so we don't break
compatibility with existing Podman workloads while being compatible
with Docker.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-08-17 14:44:43 +02:00
Valentin Rothberg 988b089a30 Merge pull request #221 from giuseppe/permit-rootless-cni
rootless: permit custom configuration for cni
2020-07-21 11:46:04 +02:00
Daniel J Walsh b6bb9b862f Remove extra lock in Reload function
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-07-19 07:13:12 -04:00
Tom Sweeney b0dff4761d Merge pull request #223 from ashley-cui/umask
Add support for Umask
2020-07-15 19:43:44 -04:00
Daniel J Walsh 3e3982860a Merge pull request #224 from QiWang19/default-cfg
Fix config reload race
2020-07-15 18:07:46 -04:00
Qi Wang bf0929d101 Fix config reload race
Fix the config reload race following the comments #219.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-07-15 18:06:09 -04:00
Jhon Honce 4f496fde52 Add support for multiple service destinations
Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-07-15 14:02:00 -07:00
Ashley Cui 93a6847b2d Add support for Umask
Signed-off-by: Ashley Cui <acui@redhat.com>
2020-07-15 13:59:29 -04:00
Qi Wang 4c9e0ba4cd Add config reload
Add Reload() to reload configurations from containers.conf files.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-07-14 15:08:18 -04:00
Giuseppe Scrivano d6300be2bb rootless: permit custom configuration for cni
I am experimenting with supporting CNI in rootless Podman.  There is
no harm in preparing common to support such case and allow a custom
per-user configuration.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-07-14 15:43:59 +02:00
Daniel J Walsh 9c7d0b5a00 Merge pull request #204 from nalind/discard
readConfig(): don't return a pointer that's often ignored
2020-06-30 20:33:00 -04:00
Daniel J Walsh 560bd489ae Merge pull request #200 from ashley-cui/master
Add support for timezone
2020-06-30 17:07:39 -04:00
Ashley Cui bf1b8b15b6 Add support for timezone
Signed-off-by: Ashley Cui <acui@redhat.com>
2020-06-30 15:07:49 -04:00
Nalin Dahyabhai d045e7f373 readConfig(): don't return a pointer
Remove the often-unused result value from readConfig().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-06-30 15:02:39 -04:00
Qi Wang 3d8b92bdb2 Specify container engine in comments of engine env
Specify that the container engines are Podman, Buildah

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-30 11:59:46 -04:00
Qi Wang 82a0ff9d5c Add container_engine_env for engine to use
Add container_env_var for setting envariables for engin to use.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-06-29 16:50:14 -04:00
Daniel J Walsh dd0b47bedf Fix testing to not race on containers.conf
Looks like the Write test has to run last.  Not sure why this is
crashing but this fixes the issue.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-25 06:04:39 -04:00
Daniel J Walsh 467bf8407a Remove race condition on sync.Once
We had a race condition where the sync.Once was called, and initializing
the default Config, but another thread hit it simultaniously and got the
nil value.
This patch will always return a correct value.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-24 08:52:44 -04:00
Daniel J Walsh b804d2aa5f Add ability to read and write a default config file
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-06-16 10:31:01 -04:00
Jhon Honce a6e9a791a4 V2 Store identity associated with remote URL
* as workaround user can use --identity option when given commands
  requiring a SSH key

Signed-off-by: Jhon Honce <jhonce@redhat.com>
2020-06-08 10:15:06 -07:00
Daniel J Walsh a3a0a08b50 Add support for Remote flags in containers.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-28 15:47:01 -04:00
Daniel J Walsh 7b97b08724 Do not validate paths on remote platforms
Modify validate functions to work on a remote clients.
Any of the path checks will not work on remote machines or make
sense on remote clients. Therefore they should not be checked.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-28 13:29:37 -04:00
Daniel J Walsh ef4c52742f Add full path for error messages on containers.conf
Also add new function to allow container engines to tell users
where to edit containers.conf file.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-26 15:36:10 -04:00
Daniel J Walsh e371ed9f34 Revert removal of Set flags
Even though these are not read from the config file, they are
still required as fields to pass data in libpod.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-16 06:38:31 -04:00
Daniel J Walsh eab34f5581 Ignore empty strings from libpod.conf
If the user has a libpod.conf file with an option of "", then
we will ignore it and use the value from containers.conf.

Also the Set variables are only to be set, if a user specified an
override command, not if they were set in the libpod.conf file.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-15 17:05:28 -04:00
Valentin Rothberg 0ef2bfea2e pkg/config: set correct path in XDG_CONFIG_HOME
The rootless config path was wrong when running with XDG_CONFIG_HOME
set.

Reported-in: github.com/containers/libpod/issues/6163
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-11 13:42:43 +02:00
Daniel J Walsh cd83b65ee2 Do not set StaticDirSet, TmpDirSet,VolumePathSet
These indicate that the user has modified the settings.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-07 16:09:27 -04:00
Daniel J Walsh f681e24f01 Fix config.Capabilities function call
We need to normalize the capadd and capdrop functions, and
we need to return errors if the caller gives us bad input.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-30 17:41:07 -04:00
Daniel J Walsh c58a215838 Add support for cgroups configuration
We need to be able to disable cgroups when running container engines inside of containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-13 13:56:16 -04:00
Daniel J Walsh c719975a94 Add RuntimeSupportsKVM to config.Engine
We need to identify the list of containers that support KVM separation, these
containers can run with a different SELinux label, and we might be able to
make different decisions in the container engines about how to launch these
containers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-07 10:11:59 -04:00
Daniel J Walsh ed25ff4eb6 Add more utils for returning defaults
Move pkg/sysinfo and pkg/apparmor out of libpod into containers/common.

This will allow other packages to use these libraries without requiring all of libpod.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-01 08:39:44 -04:00
Daniel J Walsh a21cf229ee Move pkg/unshare to containers/storage/pkg/unshare
This removes a circular dependancy

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-31 08:42:12 -04:00
Raphael Höser 2c144acb11 isDirectory resolve ~ to User HomeDir
When using podman by putting the prebuild binarys into the users homedirectory, paths in the config starting with "~" are not resolved as this is normally done by the shell.
Resolving "~" to HomeDir enables the user (or a config provider) to publish a config which doesn't require adaption for each user (e.G. by changing /home/<username>/usr/bin/cni as this now becomes ~/usr/bin/cni).

This commit adds a new func resolveHomeDir(string) (string, error) which resolves a given path if it contains a reference to homedir or returns the path unchanged when not.
It throws an error when it's unable to get the users HomeDir.

Signed-off-by: Raphael Höser <raphael@hoeser.info>
2020-03-21 12:18:05 +01:00
Daniel J Walsh f935da11c9 Move SignaturePolicyPath to Engine instead of Containers
Signatures are an engine struct rather then something
per/container.  Moving to proper location.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-17 16:52:32 -04:00
Giuseppe Scrivano 9322b03394 config: honor XDG_CONFIG_HOME
when the env variable is set, use its value for locating the user
configuration file.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-03-13 15:03:29 +01:00
Daniel J Walsh fb3a7428e0 Merge pull request #89 from rhatdan/master
Directories should allow for empty paths
2020-03-12 09:55:14 -04:00
Daniel J Walsh 8fed67b97e Directories should allow for empty paths
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-12 08:49:30 -04:00
Daniel J Walsh 50135a792d Change references to libpod to engine
containers/common pkg/config is for more engines then just libpod.

We want to use the 'libpod' section to configure parts of buildah.  Renaming this
section to engine, makes it more obvious to users that these fields can effect other
container engines.

Certain fields are still libpod specific, so we do not change those fields.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-11 14:56:32 -04:00
Daniel J Walsh cf37573798 Drop StorageConfig from containers config structures
Callers should use containers/storage directly.

Also remove MergeDBConfig, this is no longer used by any callers.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-11 05:39:35 -04:00
Daniel J Walsh 357a5402c6 NewConfig(): passed-in configuration file should matter most
In NewConfig(), settings in the file whose name we're passed should
matter more than the hardwired default files, or the file named in the
CONTAINERS_CONF environment variable.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-09 17:29:26 -04:00
Qi Wang eee0f4f7f8 remove CgroupsAndAdjust from NewConfig
Export CheckCgroupsAndAdjustConfig() as global function and remove it from NewConfig(). So we can handle it in libpod and avoid Buildah to display cgroup warning message when reading containers.conf.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-03-09 15:18:15 -04:00
Qi Wang 0c613a6abe Support and prefer libpod.conf if exists
During the transision period of replacing libpod.conf with containers.conf, pkg/config should also read the libpod.conf if it exist.
This patch reads the libpod.conf in NewConfig() and converts the configurations to ContainersConfig Struct.

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-03-09 14:37:19 -04:00
Qi Wang bec93b6703 Add pull_policy to LibpodConfig
pull_policy is the same as podman run --pull option to determin whether to pull a new image when running a container.
Accepted "always", "missing", and "never". Default value is "missing".

Signed-off-by: Qi Wang <qiwan@redhat.com>
2020-03-03 11:13:38 -05:00
Daniel J Walsh 00b0aae703 Add StopTimeout for podman
Allow users to modify the default ammount of time to wait to send SIGKILL
after you tell a container to stop with a SIGINT.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-21 11:32:16 -05:00