diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-03-02 12:33:25 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-02 19:20:26 +0000 |
commit | cd670ff83978f27dd781696496d1328785329dbf (patch) | |
tree | a53793e4cbe75f972ee80985088e8f29cbec8897 /libpod/container.go | |
parent | 02c6ba994949e2c5b606df56d43e923d9b044f67 (diff) | |
download | podman-cd670ff83978f27dd781696496d1328785329dbf.tar.gz podman-cd670ff83978f27dd781696496d1328785329dbf.tar.bz2 podman-cd670ff83978f27dd781696496d1328785329dbf.zip |
Fix gofmt & golint
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #440
Approved by: baude
Diffstat (limited to 'libpod/container.go')
-rw-r--r-- | libpod/container.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/libpod/container.go b/libpod/container.go index d730fba3a..0e57f7296 100644 --- a/libpod/container.go +++ b/libpod/container.go @@ -145,11 +145,11 @@ type containerState struct { // IPs contains IP addresses assigned to the container // Only populated if we created a network namespace for the container, // and the network namespace is currently active - IPs []*cnitypes.IPConfig `json:"ipAddresses,omitempty"` + IPs []*cnitypes.IPConfig `json:"ipAddresses,omitempty"` // Routes contains network routes present in the container // Only populated if we created a network namespace for the container, // and the network namespace is currently active - Routes []*types.Route `json:"routes,omitempty"` + Routes []*types.Route `json:"routes,omitempty"` } // ExecSession contains information on an active exec session @@ -649,7 +649,7 @@ func (c *Container) ExecSession(id string) (*ExecSession, error) { return returnSession, nil } -// IPs() retrieves a container's IP addresses +// IPs retrieves a container's IP address(es) // This will only be populated if the container is configured to created a new // network namespace, and that namespace is presently active func (c *Container) IPs() ([]net.IPNet, error) { @@ -662,6 +662,10 @@ func (c *Container) IPs() ([]net.IPNet, error) { } } + if !c.config.CreateNetNS { + return errors.Wrapf(ErrInvalidArg, "container %s network namespace is not managed by libpod") + } + ips := make([]net.IPNet, 0, len(c.state.IPs)) for _, ip := range c.state.IPs { @@ -686,10 +690,14 @@ func (c *Container) Routes() ([]types.Route, error) { routes := make([]types.Route, 0, len(c.state.Routes)) + if !c.config.CreateNetNS { + return errors.Wrapf(ErrInvalidArg, "container %s network namespace is not managed by libpod") + } + for _, route := range c.state.Routes { newRoute := types.Route{ Dst: route.Dst, - GW: route.GW, + GW: route.GW, } routes = append(routes, newRoute) |