summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--libpod/container_commit.go2
-rw-r--r--libpod/image/image.go3
-rw-r--r--libpod/options.go11
-rw-r--r--libpod/runtime_ctr.go6
-rw-r--r--libpod/runtime_pod_linux.go2
-rw-r--r--libpod/volume.go14
-rw-r--r--libpod/volume_inspect.go10
-rw-r--r--pkg/bindings/connection.go11
-rw-r--r--pkg/bindings/test/common_test.go1
-rw-r--r--pkg/bindings/test/images_test.go10
-rw-r--r--pkg/bindings/test/test_suite_test.go13
12 files changed, 51 insertions, 35 deletions
diff --git a/Makefile b/Makefile
index 85f1036e0..420e3c4b2 100644
--- a/Makefile
+++ b/Makefile
@@ -524,7 +524,10 @@ install.libseccomp.sudo:
cmd/podman/varlink/iopodman.go: .gopathok cmd/podman/varlink/io.podman.varlink
+ifeq ("$(shell uname -o)", "GNU/Linux")
+ # Only generate the varlink code on Linux (see issue #4814).
GO111MODULE=off $(GO) generate ./cmd/podman/varlink/...
+endif
API.md: cmd/podman/varlink/io.podman.varlink
$(GO) generate ./docs/...
diff --git a/libpod/container_commit.go b/libpod/container_commit.go
index ccc23621e..fa6e95b38 100644
--- a/libpod/container_commit.go
+++ b/libpod/container_commit.go
@@ -137,7 +137,7 @@ func (c *Container) Commit(ctx context.Context, destImage string, options Contai
if err != nil {
return nil, errors.Wrapf(err, "volume %s used in container %s has been removed", v.Name, c.ID())
}
- if vol.IsCtrSpecific() {
+ if vol.Anonymous() {
importBuilder.AddVolume(v.Dest)
}
}
diff --git a/libpod/image/image.go b/libpod/image/image.go
index 7ee8c45d7..355249b12 100644
--- a/libpod/image/image.go
+++ b/libpod/image/image.go
@@ -831,7 +831,8 @@ func (i *Image) History(ctx context.Context) ([]*History, error) {
id := "<missing>"
if x == numHistories {
id = i.ID()
- } else if layer != nil {
+ }
+ if layer != nil {
if !oci.History[x].EmptyLayer {
size = layer.UncompressedSize
}
diff --git a/libpod/options.go b/libpod/options.go
index 593037382..923e7292c 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1546,17 +1546,16 @@ func WithVolumeGID(gid int) VolumeCreateOption {
}
}
-// withSetCtrSpecific sets a bool notifying libpod that a volume was created
-// specifically for a container.
-// These volumes will be removed when the container is removed and volumes are
-// also specified for removal.
-func withSetCtrSpecific() VolumeCreateOption {
+// withSetAnon sets a bool notifying libpod that this volume is anonymous and
+// should be removed when containers using it are removed and volumes are
+// specified for removal.
+func withSetAnon() VolumeCreateOption {
return func(volume *Volume) error {
if volume.valid {
return define.ErrVolumeFinalized
}
- volume.config.IsCtrSpecific = true
+ volume.config.IsAnon = true
return nil
}
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go
index e8952967d..3ad09f27c 100644
--- a/libpod/runtime_ctr.go
+++ b/libpod/runtime_ctr.go
@@ -319,7 +319,7 @@ func (r *Runtime) setupContainer(ctx context.Context, ctr *Container) (c *Contai
// The volume does not exist, so we need to create it.
volOptions := []VolumeCreateOption{WithVolumeName(vol.Name), WithVolumeUID(ctr.RootUID()), WithVolumeGID(ctr.RootGID())}
if isAnonymous {
- volOptions = append(volOptions, withSetCtrSpecific())
+ volOptions = append(volOptions, withSetAnon())
}
newVol, err := r.newVolume(ctx, volOptions...)
if err != nil {
@@ -569,7 +569,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool,
for _, v := range c.config.NamedVolumes {
if volume, err := runtime.state.Volume(v.Name); err == nil {
- if !volume.IsCtrSpecific() {
+ if !volume.Anonymous() {
continue
}
if err := runtime.removeVolume(ctx, volume, false); err != nil && errors.Cause(err) != define.ErrNoSuchVolume {
@@ -707,7 +707,7 @@ func (r *Runtime) evictContainer(ctx context.Context, idOrName string, removeVol
for _, v := range c.config.NamedVolumes {
if volume, err := r.state.Volume(v.Name); err == nil {
- if !volume.IsCtrSpecific() {
+ if !volume.Anonymous() {
continue
}
if err := r.removeVolume(ctx, volume, false); err != nil && err != define.ErrNoSuchVolume && err != define.ErrVolumeBeingUsed {
diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go
index 450c64d24..5b0111b85 100644
--- a/libpod/runtime_pod_linux.go
+++ b/libpod/runtime_pod_linux.go
@@ -261,7 +261,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool)
logrus.Errorf("Error retrieving volume %s: %v", volName, err)
continue
}
- if !volume.IsCtrSpecific() {
+ if !volume.Anonymous() {
continue
}
if err := r.removeVolume(ctx, volume, false); err != nil {
diff --git a/libpod/volume.go b/libpod/volume.go
index c4771bbb8..1ffed872e 100644
--- a/libpod/volume.go
+++ b/libpod/volume.go
@@ -38,9 +38,8 @@ type VolumeConfig struct {
// a list of mount options. For other drivers, they are passed to the
// volume driver handling the volume.
Options map[string]string `json:"volumeOptions,omitempty"`
- // Whether this volume was created for a specific container and will be
- // removed with it.
- IsCtrSpecific bool `json:"ctrSpecific"`
+ // Whether this volume is anonymous (will be removed on container exit)
+ IsAnon bool `json:"isAnon"`
// UID the volume will be created as.
UID int `json:"uid"`
// GID the volume will be created as.
@@ -106,11 +105,10 @@ func (v *Volume) Options() map[string]string {
return options
}
-// IsCtrSpecific returns whether this volume was created specifically for a
-// given container. Images with this set to true will be removed when the
-// container is removed with the Volumes parameter set to true.
-func (v *Volume) IsCtrSpecific() bool {
- return v.config.IsCtrSpecific
+// Anonymous returns whether this volume is anonymous. Anonymous volumes were
+// created with a container, and will be removed when that container is removed.
+func (v *Volume) Anonymous() bool {
+ return v.config.IsAnon
}
// UID returns the UID the volume will be created as.
diff --git a/libpod/volume_inspect.go b/libpod/volume_inspect.go
index c333b8961..136f9da5e 100644
--- a/libpod/volume_inspect.go
+++ b/libpod/volume_inspect.go
@@ -37,10 +37,10 @@ type InspectVolumeData struct {
UID int `json:"UID,omitempty"`
// GID is the GID that the volume was created with.
GID int `json:"GID,omitempty"`
- // ContainerSpecific indicates that the volume was created as part of a
- // specific container, and will be removed when that container is
- // removed.
- ContainerSpecific bool `json:"ContainerSpecific,omitempty"`
+ // Anonymous indicates that the volume was created as an anonymous
+ // volume for a specific container, and will be be removed when any
+ // container using it is removed.
+ Anonymous bool `json:"Anonymous,omitempty"`
}
// Inspect provides detailed information about the configuration of the given
@@ -67,7 +67,7 @@ func (v *Volume) Inspect() (*InspectVolumeData, error) {
}
data.UID = v.config.UID
data.GID = v.config.GID
- data.ContainerSpecific = v.config.IsCtrSpecific
+ data.Anonymous = v.config.IsAnon
return data, nil
}
diff --git a/pkg/bindings/connection.go b/pkg/bindings/connection.go
index 3dec6ca20..2e5fc9cb8 100644
--- a/pkg/bindings/connection.go
+++ b/pkg/bindings/connection.go
@@ -115,11 +115,12 @@ func (c *Connection) DoRequest(httpBody io.Reader, httpMethod, endpoint string,
)
safePathValues := make([]interface{}, len(pathValues))
// Make sure path values are http url safe
- for _, pv := range pathValues {
- safePathValues = append(safePathValues, url.QueryEscape(pv))
+ for i, pv := range pathValues {
+ safePathValues[i] = url.QueryEscape(pv)
}
+ // Lets eventually use URL for this which might lead to safer
+ // usage
safeEndpoint := fmt.Sprintf(endpoint, safePathValues...)
-
e := c.makeEndpoint(safeEndpoint)
req, err := http.NewRequest(httpMethod, e, httpBody)
if err != nil {
@@ -150,8 +151,8 @@ func GetConnectionFromContext(ctx context.Context) (*Connection, error) {
if c == nil {
return nil, errors.New("unable to get connection from context")
}
- conn := c.(Connection)
- return &conn, nil
+ conn := c.(*Connection)
+ return conn, nil
}
// FiltersToHTML converts our typical filter format of a
diff --git a/pkg/bindings/test/common_test.go b/pkg/bindings/test/common_test.go
index 4f2a98f2b..e3e66c89f 100644
--- a/pkg/bindings/test/common_test.go
+++ b/pkg/bindings/test/common_test.go
@@ -15,6 +15,7 @@ import (
const (
defaultPodmanBinaryLocation string = "/usr/bin/podman"
+ alpine string = "docker.io/library/alpine:latest"
)
type bindingTest struct {
diff --git a/pkg/bindings/test/images_test.go b/pkg/bindings/test/images_test.go
index d600197bb..2906d55cd 100644
--- a/pkg/bindings/test/images_test.go
+++ b/pkg/bindings/test/images_test.go
@@ -34,7 +34,7 @@ var _ = Describe("Podman images", func() {
//podmanTest.Setup()
//podmanTest.SeedImages()
bt = newBindingTest()
- p := bt.runPodman([]string{"pull", "docker.io/library/alpine:latest"})
+ p := bt.runPodman([]string{"pull", alpine})
p.Wait(45)
s = bt.startAPIService()
time.Sleep(1 * time.Second)
@@ -68,13 +68,13 @@ var _ = Describe("Podman images", func() {
_, err = images.GetImage(connText, data.ID[0:12], nil)
Expect(err).To(BeNil())
// Inspect by ID
- // Inspect by long name should work, it doesnt (yet) i think it needs to be html escaped
- //_, err = images.GetImage(connText, )
+ //Inspect by long name should work, it doesnt (yet) i think it needs to be html escaped
+ //_, err = images.GetImage(connText, alpine, nil)
//Expect(err).To(BeNil())
})
It("remove image", func() {
// Remove invalid image should be a 404
- _, err = images.RemoveImage(connText, "foobar5000", &false)
+ _, err = images.Remove(connText, "foobar5000", &false)
Expect(err).ToNot(BeNil())
code, _ := bindings.CheckResponseCode(err)
Expect(code).To(BeNumerically("==", 404))
@@ -82,7 +82,7 @@ var _ = Describe("Podman images", func() {
_, err := images.GetImage(connText, "alpine", nil)
Expect(err).To(BeNil())
- response, err := images.RemoveImage(connText, "alpine", &false)
+ response, err := images.Remove(connText, "alpine", &false)
Expect(err).To(BeNil())
fmt.Println(response)
// to be continued
diff --git a/pkg/bindings/test/test_suite_test.go b/pkg/bindings/test/test_suite_test.go
new file mode 100644
index 000000000..dc2b49b88
--- /dev/null
+++ b/pkg/bindings/test/test_suite_test.go
@@ -0,0 +1,13 @@
+package test_bindings_test
+
+import (
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+func TestTest(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Test Suite")
+}