summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@gmail.com>2018-10-02 13:34:58 -0400
committerMatthew Heon <matthew.heon@gmail.com>2018-10-11 11:10:23 -0400
commit5c5163107cb31d83eb6cd05427e818182c1f6112 (patch)
treeb91346bb9b50a776af5a551e2ea52dddc24ca314 /libpod/options.go
parent6b80986194c0ec525775e24d7fa973cd5c067ed0 (diff)
downloadpodman-5c5163107cb31d83eb6cd05427e818182c1f6112.tar.gz
podman-5c5163107cb31d83eb6cd05427e818182c1f6112.tar.bz2
podman-5c5163107cb31d83eb6cd05427e818182c1f6112.zip
Temporary commit to swap branches
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go25
1 files changed, 25 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index 977f3f4c2..6a8529b8b 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -828,6 +828,31 @@ func WithNetNS(portMappings []ocicni.PortMapping, postConfigureNetNS bool, netwo
}
}
+// WithStaticIP indicates that the container should request a static IP 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 WithStaticIP(ip net.IP) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+
+ if !ctr.config.CreateNetNS {
+ return errors.Wrapf(ErrInvalidArg, "cannot set a static IP if the container is not creating a network namespace")
+ }
+
+ if len(ctr.config.Networks) != 0 {
+ return errors.Wrapf(ErrInvalidArg, "cannot set a static IP if joining additional CNI networks")
+ }
+
+ ctr.config.StaticIP = ip
+
+ return nil
+ }
+}
+
// WithLogPath sets the path to the log file.
func WithLogPath(path string) CtrCreateOption {
return func(ctr *Container) error {