diff options
author | Matthew Heon <matthew.heon@pm.me> | 2020-10-26 17:17:45 -0400 |
---|---|---|
committer | Matthew Heon <matthew.heon@pm.me> | 2020-10-27 14:17:41 -0400 |
commit | 6af7e544636ae66ce237489ce6948123e1b3249d (patch) | |
tree | b95ead53ec2419d750c56ca008ed0965457d6d10 /libpod/options.go | |
parent | 51fa8ded9ffb7924288a2728ce92af7f6cc66d34 (diff) | |
download | podman-6af7e544636ae66ce237489ce6948123e1b3249d.tar.gz podman-6af7e544636ae66ce237489ce6948123e1b3249d.tar.bz2 podman-6af7e544636ae66ce237489ce6948123e1b3249d.zip |
Add network aliases for containers to DB
This adds the database backend for network aliases. Aliases are
additional names for a container that are used with the CNI
dnsname plugin - the container will be accessible by these names
in addition to its name. Aliases are allowed to change over time
as the container connects to and disconnects from networks.
Aliases are implemented as another bucket in the database to
register all aliases, plus two buckets for each container (one to
hold connected CNI networks, a second to hold its aliases). The
aliases are only unique per-network, to the global and
per-container aliases buckets have a sub-bucket for each CNI
network that has aliases, and the aliases are stored within that
sub-bucket. Aliases are formatted as alias (key) to container ID
(value) in both cases.
Three DB functions are defined for aliases: retrieving current
aliases for a given network, setting aliases for a given network,
and removing all aliases for a given network.
Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'libpod/options.go')
-rw-r--r-- | libpod/options.go | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go index 1ffb78da9..da2fc983a 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -1487,6 +1487,20 @@ func WithCreateWorkingDir() CtrCreateOption { } } +// WithNetworkAliases sets network aliases for the container. +// Accepts a map of network name to aliases. +func WithNetworkAliases(aliases map[string][]string) CtrCreateOption { + return func(ctr *Container) error { + if ctr.valid { + return define.ErrCtrFinalized + } + + ctr.config.NetworkAliases = aliases + + return nil + } +} + // Volume Creation Options // WithVolumeName sets the name of the volume. |