summaryrefslogtreecommitdiff
path: root/pkg/bindings
diff options
context:
space:
mode:
authorBrent Baude <bbaude@redhat.com>2021-08-16 09:37:50 -0500
committerBrent Baude <bbaude@redhat.com>2021-08-24 14:26:14 -0500
commit1e176923b15360559d859000f2fb0c0a3e30f792 (patch)
tree5a888021a0fa58375ebe947b86e5dc37fd8d22a0 /pkg/bindings
parente9daaf62e3921b8c696f3abd92f001a9447c8aa1 (diff)
downloadpodman-1e176923b15360559d859000f2fb0c0a3e30f792.tar.gz
podman-1e176923b15360559d859000f2fb0c0a3e30f792.tar.bz2
podman-1e176923b15360559d859000f2fb0c0a3e30f792.zip
teardown play kube
add the ability for play kube to tear down based on the yaml used to play it. it is indicated by --down in the play kube command. volumes are NOT deleted during the teardown. pods and their containers are stopped and removed. Signed-off-by: Brent Baude <bbaude@redhat.com>
Diffstat (limited to 'pkg/bindings')
-rw-r--r--pkg/bindings/play/play.go29
-rw-r--r--pkg/bindings/play/types.go4
2 files changed, 32 insertions, 1 deletions
diff --git a/pkg/bindings/play/play.go b/pkg/bindings/play/play.go
index 4b735c821..a45508fed 100644
--- a/pkg/bindings/play/play.go
+++ b/pkg/bindings/play/play.go
@@ -6,6 +6,8 @@ import (
"os"
"strconv"
+ "github.com/sirupsen/logrus"
+
"github.com/containers/podman/v3/pkg/auth"
"github.com/containers/podman/v3/pkg/bindings"
"github.com/containers/podman/v3/pkg/domain/entities"
@@ -54,3 +56,30 @@ func Kube(ctx context.Context, path string, options *KubeOptions) (*entities.Pla
return &report, nil
}
+
+func KubeDown(ctx context.Context, path string) (*entities.PlayKubeReport, error) {
+ var report entities.PlayKubeReport
+ conn, err := bindings.GetClient(ctx)
+ if err != nil {
+ return nil, err
+ }
+
+ f, err := os.Open(path)
+ if err != nil {
+ return nil, err
+ }
+ defer func() {
+ if err := f.Close(); err != nil {
+ logrus.Warn(err)
+ }
+ }()
+ response, err := conn.DoRequest(f, http.MethodDelete, "/play/kube", nil, nil)
+ if err != nil {
+ return nil, err
+ }
+ if err := response.Process(&report); err != nil {
+ return nil, err
+ }
+
+ return &report, nil
+}
diff --git a/pkg/bindings/play/types.go b/pkg/bindings/play/types.go
index 52a72c7b6..787069169 100644
--- a/pkg/bindings/play/types.go
+++ b/pkg/bindings/play/types.go
@@ -1,6 +1,8 @@
package play
-import "net"
+import (
+ "net"
+)
//go:generate go run ../generator/generator.go KubeOptions
// KubeOptions are optional options for replaying kube YAML files