summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal.go20
-rw-r--r--libpod/define/container_inspect.go15
-rw-r--r--libpod/define/errors.go3
-rw-r--r--libpod/image/errors.go2
-rw-r--r--libpod/image/image.go13
-rw-r--r--libpod/networking_linux.go16
6 files changed, 56 insertions, 13 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 73e0b2118..db64f5eeb 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -22,6 +22,7 @@ import (
"github.com/containers/libpod/pkg/selinux"
"github.com/containers/storage"
"github.com/containers/storage/pkg/archive"
+ "github.com/containers/storage/pkg/idtools"
"github.com/containers/storage/pkg/mount"
securejoin "github.com/cyphar/filepath-securejoin"
spec "github.com/opencontainers/runtime-spec/specs-go"
@@ -360,6 +361,25 @@ func (c *Container) setupStorageMapping(dest, from *storage.IDMappingOptions) {
}
dest.AutoUserNsOpts.InitialSize = initialSize + 1
}
+ } else if c.config.Spec.Linux != nil {
+ dest.UIDMap = nil
+ for _, r := range c.config.Spec.Linux.UIDMappings {
+ u := idtools.IDMap{
+ ContainerID: int(r.ContainerID),
+ HostID: int(r.HostID),
+ Size: int(r.Size),
+ }
+ dest.UIDMap = append(dest.UIDMap, u)
+ }
+ dest.GIDMap = nil
+ for _, r := range c.config.Spec.Linux.GIDMappings {
+ g := idtools.IDMap{
+ ContainerID: int(r.ContainerID),
+ HostID: int(r.HostID),
+ Size: int(r.Size),
+ }
+ dest.GIDMap = append(dest.GIDMap, g)
+ }
}
}
diff --git a/libpod/define/container_inspect.go b/libpod/define/container_inspect.go
index 27ada8706..3fbeb8f0b 100644
--- a/libpod/define/container_inspect.go
+++ b/libpod/define/container_inspect.go
@@ -5,7 +5,6 @@ import (
"github.com/containers/image/v5/manifest"
"github.com/containers/libpod/libpod/driver"
- "github.com/cri-o/ocicni/pkg/ocicni"
)
// InspectContainerConfig holds further data about how a container was initially
@@ -571,13 +570,13 @@ type InspectAdditionalNetwork struct {
type InspectNetworkSettings struct {
InspectBasicNetworkConfig
- Bridge string `json:"Bridge"`
- SandboxID string `json:"SandboxID"`
- HairpinMode bool `json:"HairpinMode"`
- LinkLocalIPv6Address string `json:"LinkLocalIPv6Address"`
- LinkLocalIPv6PrefixLen int `json:"LinkLocalIPv6PrefixLen"`
- Ports []ocicni.PortMapping `json:"Ports"`
- SandboxKey string `json:"SandboxKey"`
+ Bridge string `json:"Bridge"`
+ SandboxID string `json:"SandboxID"`
+ HairpinMode bool `json:"HairpinMode"`
+ LinkLocalIPv6Address string `json:"LinkLocalIPv6Address"`
+ LinkLocalIPv6PrefixLen int `json:"LinkLocalIPv6PrefixLen"`
+ Ports map[string][]InspectHostPort `json:"Ports"`
+ SandboxKey string `json:"SandboxKey"`
// Networks contains information on non-default CNI networks this
// container has joined.
// It is a map of network name to network information.
diff --git a/libpod/define/errors.go b/libpod/define/errors.go
index e0c9811fe..98dc603d1 100644
--- a/libpod/define/errors.go
+++ b/libpod/define/errors.go
@@ -17,6 +17,9 @@ var (
// ErrNoSuchImage indicates the requested image does not exist
ErrNoSuchImage = image.ErrNoSuchImage
+ // ErrNoSuchTag indicates the requested image tag does not exist
+ ErrNoSuchTag = image.ErrNoSuchTag
+
// ErrNoSuchVolume indicates the requested volume does not exist
ErrNoSuchVolume = errors.New("no such volume")
diff --git a/libpod/image/errors.go b/libpod/image/errors.go
index 4088946cb..ddbf7be4b 100644
--- a/libpod/image/errors.go
+++ b/libpod/image/errors.go
@@ -12,4 +12,6 @@ var (
ErrNoSuchPod = errors.New("no such pod")
// ErrNoSuchImage indicates the requested image does not exist
ErrNoSuchImage = errors.New("no such image")
+ // ErrNoSuchTag indicates the requested image tag does not exist
+ ErrNoSuchTag = errors.New("no such tag")
)
diff --git a/libpod/image/image.go b/libpod/image/image.go
index d81f7e911..83e7467e9 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -559,15 +559,24 @@ func (i *Image) TagImage(tag string) error {
return nil
}
-// UntagImage removes a tag from the given image
+// UntagImage removes the specified tag from the image.
+// If the tag does not exist, ErrNoSuchTag is returned.
func (i *Image) UntagImage(tag string) error {
if err := i.reloadImage(); err != nil {
return err
}
+
+ // Normalize the tag as we do with TagImage.
+ ref, err := NormalizedTag(tag)
+ if err != nil {
+ return err
+ }
+ tag = ref.String()
+
var newTags []string
tags := i.Names()
if !util.StringInSlice(tag, tags) {
- return nil
+ return errors.Wrapf(ErrNoSuchTag, "%q", tag)
}
for _, t := range tags {
if tag != t {
diff --git a/libpod/networking_linux.go b/libpod/networking_linux.go
index 0c9d28701..f53573645 100644
--- a/libpod/networking_linux.go
+++ b/libpod/networking_linux.go
@@ -587,10 +587,20 @@ func getContainerNetIO(ctr *Container) (*netlink.LinkStatistics, error) {
// network.
func (c *Container) getContainerNetworkInfo() (*define.InspectNetworkSettings, error) {
settings := new(define.InspectNetworkSettings)
- settings.Ports = []ocicni.PortMapping{}
+ settings.Ports = make(map[string][]define.InspectHostPort)
if c.config.PortMappings != nil {
- // TODO: This may not be safe.
- settings.Ports = c.config.PortMappings
+ for _, port := range c.config.PortMappings {
+ key := fmt.Sprintf("%d/%s", port.ContainerPort, port.Protocol)
+ mapping := settings.Ports[key]
+ if mapping == nil {
+ mapping = []define.InspectHostPort{}
+ }
+ mapping = append(mapping, define.InspectHostPort{
+ HostIP: port.HostIP,
+ HostPort: fmt.Sprintf("%d", port.HostPort),
+ })
+ settings.Ports[key] = mapping
+ }
}
// We can't do more if the network is down.