aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/kube/down.go
blob: a670d911cbc4f3e42cf3fb51ae492c869e498025 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package kube

import (
	"github.com/containers/podman/v4/cmd/podman/common"
	"github.com/containers/podman/v4/cmd/podman/registry"
	"github.com/spf13/cobra"
)

var (
	downDescription = `Reads in a structured file of Kubernetes YAML.

  Removes pods that have been based on the Kubernetes kind described in the YAML.`

	downCmd = &cobra.Command{
		Use:               "down KUBEFILE|-",
		Short:             "Remove pods based on Kubernetes YAML.",
		Long:              downDescription,
		RunE:              down,
		Args:              cobra.ExactArgs(1),
		ValidArgsFunction: common.AutocompleteDefaultOneArg,
		Example: `podman kube down nginx.yml
   cat nginx.yml | podman kube down -`,
	}
)

func init() {
	registry.Commands = append(registry.Commands, registry.CliCommand{
		Command: downCmd,
		Parent:  kubeCmd,
	})
}

func down(cmd *cobra.Command, args []string) error {
	reader, err := readerFromArg(args[0])
	if err != nil {
		return err
	}
	return teardown(reader)
}