diff options
Diffstat (limited to 'pkg/bindings')
-rw-r--r-- | pkg/bindings/generate/types.go | 2 | ||||
-rw-r--r-- | pkg/bindings/images/types.go | 2 | ||||
-rw-r--r-- | pkg/bindings/network/types_create_options.go | 4 | ||||
-rw-r--r-- | pkg/bindings/test/images_test.go | 2 | ||||
-rw-r--r-- | pkg/bindings/test/pods_test.go | 2 | ||||
-rw-r--r-- | pkg/bindings/test/system_test.go | 57 |
6 files changed, 63 insertions, 6 deletions
diff --git a/pkg/bindings/generate/types.go b/pkg/bindings/generate/types.go index 2edf58768..4e9d7a0ff 100644 --- a/pkg/bindings/generate/types.go +++ b/pkg/bindings/generate/types.go @@ -8,7 +8,7 @@ type KubeOptions struct { } //go:generate go run ../generator/generator.go SystemdOptions -// SystemdOptions are optional options for generating ssytemd files +// SystemdOptions are optional options for generating systemd files type SystemdOptions struct { // Name - use container/pod name instead of its ID. UseName *bool diff --git a/pkg/bindings/images/types.go b/pkg/bindings/images/types.go index e389ac9d6..3adb4356b 100644 --- a/pkg/bindings/images/types.go +++ b/pkg/bindings/images/types.go @@ -136,7 +136,7 @@ type PushOptions struct { } //go:generate go run ../generator/generator.go SearchOptions -// SearchOptions are optional options for seaching images on registies +// SearchOptions are optional options for searching images on registries type SearchOptions struct { // Authfile is the path to the authentication file. Ignored for remote // calls. diff --git a/pkg/bindings/network/types_create_options.go b/pkg/bindings/network/types_create_options.go index e35762912..daec6a254 100644 --- a/pkg/bindings/network/types_create_options.go +++ b/pkg/bindings/network/types_create_options.go @@ -193,9 +193,9 @@ func (o *CreateOptions) WithIPRange(value net.IPNet) *CreateOptions { // GetIPRange func (o *CreateOptions) GetIPRange() net.IPNet { - var iPRange net.IPNet + var ipRange net.IPNet if o.IPRange == nil { - return iPRange + return ipRange } return *o.IPRange } diff --git a/pkg/bindings/test/images_test.go b/pkg/bindings/test/images_test.go index ae41eced9..e178f4219 100644 --- a/pkg/bindings/test/images_test.go +++ b/pkg/bindings/test/images_test.go @@ -70,7 +70,7 @@ var _ = Describe("Podman images", func() { // Inspect by long name _, err = images.GetImage(bt.conn, alpine.name, nil) Expect(err).To(BeNil()) - // TODO it looks like the images API alwaays returns size regardless + // TODO it looks like the images API always returns size regardless // of bool or not. What should we do ? // Expect(data.Size).To(BeZero()) diff --git a/pkg/bindings/test/pods_test.go b/pkg/bindings/test/pods_test.go index 17b142fc2..38c5997ef 100644 --- a/pkg/bindings/test/pods_test.go +++ b/pkg/bindings/test/pods_test.go @@ -169,7 +169,7 @@ var _ = Describe("Podman pods", func() { // This test validates if All running containers within // each specified pod are paused and unpaused - It("pause upause pod", func() { + It("pause unpause pod", func() { // TODO fix this Skip("Pod behavior is jacked right now.") // Pause invalid container diff --git a/pkg/bindings/test/system_test.go b/pkg/bindings/test/system_test.go index 5cb0f9125..25fda5575 100644 --- a/pkg/bindings/test/system_test.go +++ b/pkg/bindings/test/system_test.go @@ -158,4 +158,61 @@ var _ = Describe("Podman system", func() { // Volume should be pruned now as flag set true Expect(len(systemPruneResponse.VolumePruneReport)).To(Equal(1)) }) + + It("podman system prune running alpine container volume prune --filter", func() { + // Start a pod and leave it running + _, err := pods.Start(bt.conn, newpod, nil) + Expect(err).To(BeNil()) + + // Start and stop a container to enter in exited state. + var name = "top" + _, err = bt.RunTopContainer(&name, bindings.PFalse, nil) + Expect(err).To(BeNil()) + err = containers.Stop(bt.conn, name, nil) + Expect(err).To(BeNil()) + + // Start second container and leave in running + var name2 = "top2" + _, err = bt.RunTopContainer(&name2, bindings.PFalse, nil) + Expect(err).To(BeNil()) + + // Adding an unused volume should work + _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{}, nil) + Expect(err).To(BeNil()) + + // Adding an unused volume with label should work + _, err = volumes.Create(bt.conn, entities.VolumeCreateOptions{Label: map[string]string{ + "label1": "value1", + }}, nil) + Expect(err).To(BeNil()) + + f := make(map[string][]string) + f["label"] = []string{"label1=idontmatch"} + + options := new(system.PruneOptions).WithAll(true).WithVolumes(true).WithFilters(f) + systemPruneResponse, err := system.Prune(bt.conn, options) + Expect(err).To(BeNil()) + Expect(len(systemPruneResponse.PodPruneReport)).To(Equal(0)) + // TODO fix system filter handling so all components can handle filters + // This check **should** be "Equal(0)" since we are passing label + // filters however the Prune function doesn't seem to pass filters + // to each component. + Expect(len(systemPruneResponse.ContainerPruneReport.ID)).To(Equal(1)) + Expect(len(systemPruneResponse.ImagePruneReport.Report.Id)). + To(BeNumerically(">", 0)) + // Alpine image should not be pruned as used by running container + Expect(systemPruneResponse.ImagePruneReport.Report.Id). + ToNot(ContainElement("docker.io/library/alpine:latest")) + // Volume shouldn't be pruned because the PruneOptions filters doesn't match + Expect(len(systemPruneResponse.VolumePruneReport)).To(Equal(0)) + + // Fix filter and re prune + f["label"] = []string{"label1=value1"} + options = new(system.PruneOptions).WithAll(true).WithVolumes(true).WithFilters(f) + systemPruneResponse, err = system.Prune(bt.conn, options) + Expect(err).To(BeNil()) + + // Volume should be pruned because the PruneOptions filters now match + Expect(len(systemPruneResponse.VolumePruneReport)).To(Equal(1)) + }) }) |