spiegel_podman/cmd/podman/kube/down.go
Niall Crowe 5f719b533e podman kube play/down --read from URL
`podman kube play` can create pods and containers from YAML
read from a URL poiniting to a YAML file.
For example: `podman kube play https://example.com/demo.yml`.
`podman kube down` can also teardown pods and containers created
from that YAML file by also reading YAML from a URL, provided the
YAML file the URL points to has not been changed or altered since
it was used to create pods and containers

Closes #14955
Signed-off-by: Niall Crowe <nicrowe@redhat.com>
2022-08-23 12:55:53 +01:00

40 lines
1 KiB
Go

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 -
podman kube down https://example.com/nginx.yml`,
}
)
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)
}