summaryrefslogtreecommitdiff
path: root/pkg/domain
diff options
context:
space:
mode:
authorSujil02 <sushah@redhat.com>2020-04-02 22:56:59 -0400
committerSujil02 <sushah@redhat.com>2020-04-17 17:30:58 -0400
commit37f3b191d5318b7d25893eabf4e57b568c326773 (patch)
tree8c2792aa1e7b4846dffc5708cf13a0eb500f4a19 /pkg/domain
parentaa97cb5f42a35de02d520f6c3006600505a3d6d9 (diff)
downloadpodman-37f3b191d5318b7d25893eabf4e57b568c326773.tar.gz
podman-37f3b191d5318b7d25893eabf4e57b568c326773.tar.bz2
podman-37f3b191d5318b7d25893eabf4e57b568c326773.zip
Add pod prune for api v2.
Add the ability to prune pods for api v2, Includes the addition of force flag, for client side prompt. Update test suite to support this use case. Signed-off-by: Sujil02 <sushah@redhat.com>
Diffstat (limited to 'pkg/domain')
-rw-r--r--pkg/domain/entities/engine_container.go1
-rw-r--r--pkg/domain/entities/pods.go9
-rw-r--r--pkg/domain/entities/types.go2
-rw-r--r--pkg/domain/infra/abi/pods.go17
-rw-r--r--pkg/domain/infra/tunnel/pods.go4
5 files changed, 31 insertions, 2 deletions
diff --git a/pkg/domain/entities/engine_container.go b/pkg/domain/entities/engine_container.go
index 02938413a..b730f8743 100644
--- a/pkg/domain/entities/engine_container.go
+++ b/pkg/domain/entities/engine_container.go
@@ -49,6 +49,7 @@ type ContainerEngine interface {
PodPs(ctx context.Context, options PodPSOptions) ([]*ListPodsReport, error)
PodRestart(ctx context.Context, namesOrIds []string, options PodRestartOptions) ([]*PodRestartReport, error)
PodRm(ctx context.Context, namesOrIds []string, options PodRmOptions) ([]*PodRmReport, error)
+ PodPrune(ctx context.Context, options PodPruneOptions) ([]*PodPruneReport, error)
PodStart(ctx context.Context, namesOrIds []string, options PodStartOptions) ([]*PodStartReport, error)
PodStop(ctx context.Context, namesOrIds []string, options PodStopOptions) ([]*PodStopReport, error)
PodTop(ctx context.Context, options PodTopOptions) (*StringSliceReport, error)
diff --git a/pkg/domain/entities/pods.go b/pkg/domain/entities/pods.go
index b280203de..04673ef18 100644
--- a/pkg/domain/entities/pods.go
+++ b/pkg/domain/entities/pods.go
@@ -147,6 +147,15 @@ func (p PodCreateOptions) ToPodSpecGen(s *specgen.PodSpecGenerator) {
s.CgroupParent = p.CGroupParent
}
+type PodPruneOptions struct {
+ Force bool `json:"force" schema:"force"`
+}
+
+type PodPruneReport struct {
+ Err error
+ Id string
+}
+
type PodTopOptions struct {
// CLI flags.
ListDescriptors bool
diff --git a/pkg/domain/entities/types.go b/pkg/domain/entities/types.go
index e4e1c3ad2..b89aa869a 100644
--- a/pkg/domain/entities/types.go
+++ b/pkg/domain/entities/types.go
@@ -25,9 +25,7 @@ type Report struct {
}
type PodDeleteReport struct{ Report }
-type PodPruneOptions struct{}
-type PodPruneReport struct{ Report }
type VolumeDeleteOptions struct{}
type VolumeDeleteReport struct{ Report }
diff --git a/pkg/domain/infra/abi/pods.go b/pkg/domain/infra/abi/pods.go
index 59bf0f636..6b6e13e24 100644
--- a/pkg/domain/infra/abi/pods.go
+++ b/pkg/domain/infra/abi/pods.go
@@ -243,6 +243,23 @@ func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, optio
return reports, nil
}
+func (ic *ContainerEngine) PodPrune(ctx context.Context, options entities.PodPruneOptions) ([]*entities.PodPruneReport, error) {
+ var (
+ reports []*entities.PodPruneReport
+ )
+ response, err := ic.Libpod.PrunePods(ctx)
+ if err != nil {
+ return nil, err
+ }
+ for k, v := range response {
+ reports = append(reports, &entities.PodPruneReport{
+ Err: v,
+ Id: k,
+ })
+ }
+ return reports, nil
+}
+
func (ic *ContainerEngine) PodCreate(ctx context.Context, opts entities.PodCreateOptions) (*entities.PodCreateReport, error) {
podSpec := specgen.NewPodSpecGenerator()
opts.ToPodSpecGen(podSpec)
diff --git a/pkg/domain/infra/tunnel/pods.go b/pkg/domain/infra/tunnel/pods.go
index dad77284f..e7641c077 100644
--- a/pkg/domain/infra/tunnel/pods.go
+++ b/pkg/domain/infra/tunnel/pods.go
@@ -173,6 +173,10 @@ func (ic *ContainerEngine) PodRm(ctx context.Context, namesOrIds []string, optio
return reports, nil
}
+func (ic *ContainerEngine) PodPrune(ctx context.Context, opts entities.PodPruneOptions) ([]*entities.PodPruneReport, error) {
+ return pods.Prune(ic.ClientCxt)
+}
+
func (ic *ContainerEngine) PodCreate(ctx context.Context, opts entities.PodCreateOptions) (*entities.PodCreateReport, error) {
podSpec := specgen.NewPodSpecGenerator()
opts.ToPodSpecGen(podSpec)