diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-10-11 10:40:37 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-11 10:40:37 -0700 |
commit | 6983e00a2808b29481d1cb460aab2eea1db6ef73 (patch) | |
tree | 2ee6bc368cc698e13d5dd5249061ecd2e2f93f6e /pkg/spec | |
parent | 3c23bfca807eab55c145092c73dd8eb1e6599f38 (diff) | |
parent | 112e1402c9e2ee29a387cd84a973471c1888e4b9 (diff) | |
download | podman-6983e00a2808b29481d1cb460aab2eea1db6ef73.tar.gz podman-6983e00a2808b29481d1cb460aab2eea1db6ef73.tar.bz2 podman-6983e00a2808b29481d1cb460aab2eea1db6ef73.zip |
Merge pull request #1623 from mheon/static_ip
Add ability to specify static IPs with --ip flag
Diffstat (limited to 'pkg/spec')
-rw-r--r-- | pkg/spec/createconfig.go | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 887ef8e95..e9a5dc9dc 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -2,6 +2,7 @@ package createconfig import ( "encoding/json" + "net" "os" "strconv" "strings" @@ -311,9 +312,6 @@ func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime) ([]lib var pod *libpod.Pod var err error - // Uncomment after talking to mheon about unimplemented funcs - // options = append(options, libpod.WithLabels(c.labels)) - if c.Interactive { options = append(options, libpod.WithStdin()) } @@ -442,6 +440,15 @@ func (c *CreateConfig) GetContainerCreateOptions(runtime *libpod.Runtime) ([]lib if logPath != "" { options = append(options, libpod.WithLogPath(logPath)) } + if c.IPAddress != "" { + ip := net.ParseIP(c.IPAddress) + if ip == nil { + return nil, errors.Wrapf(libpod.ErrInvalidArg, "cannot parse %s as IP address", c.IPAddress) + } else if ip.To4() == nil { + return nil, errors.Wrapf(libpod.ErrInvalidArg, "%s is not an IPv4 address", c.IPAddress) + } + options = append(options, libpod.WithStaticIP(ip)) + } options = append(options, libpod.WithPrivileged(c.Privileged)) |