diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-11-07 20:26:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-07 20:26:14 +0100 |
commit | d919961f621d0b9eb70b971fc8e8915ee279ab60 (patch) | |
tree | 05272b838219ba06a56c4d06038ae2f7d6fa1fe1 /libpod/options.go | |
parent | 347499778cb1a7045dc831f99b9539bc20fe008d (diff) | |
parent | 82e4116e578f72bd627330ac10d541c3e234738c (diff) | |
download | podman-d919961f621d0b9eb70b971fc8e8915ee279ab60.tar.gz podman-d919961f621d0b9eb70b971fc8e8915ee279ab60.tar.bz2 podman-d919961f621d0b9eb70b971fc8e8915ee279ab60.zip |
Merge pull request #4451 from giuseppe/set-mac
podman: add support for specifying MAC
Diffstat (limited to 'libpod/options.go')
-rw-r--r-- | libpod/options.go | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go index 66e8ef93c..00b5626b4 100644 --- a/libpod/options.go +++ b/libpod/options.go @@ -1052,6 +1052,31 @@ func WithStaticIP(ip net.IP) CtrCreateOption { } } +// WithStaticMAC indicates that the container should request a static MAC from +// the CNI plugins. +// It cannot be set unless WithNetNS has already been passed. +// Further, it cannot be set if additional CNI networks to join have been +// specified. +func WithStaticMAC(mac net.HardwareAddr) CtrCreateOption { + return func(ctr *Container) error { + if ctr.valid { + return define.ErrCtrFinalized + } + + if !ctr.config.CreateNetNS { + return errors.Wrapf(define.ErrInvalidArg, "cannot set a static MAC if the container is not creating a network namespace") + } + + if len(ctr.config.Networks) != 0 { + return errors.Wrapf(define.ErrInvalidArg, "cannot set a static MAC if joining additional CNI networks") + } + + ctr.config.StaticMAC = mac + + return nil + } +} + // WithLogDriver sets the log driver for the container func WithLogDriver(driver string) CtrCreateOption { return func(ctr *Container) error { |