mirror of
https://github.com/containers/podman.git
synced 2025-07-02 00:30:00 +08:00
Use the new checkAllAndLatest() function
Instead of duplicating the same code in multiple commands this uses the newly added function checkAllAndLatest() instead. Signed-off-by: Adrian Reber <areber@redhat.com>
This commit is contained in:

committed by
Adrian Reber

parent
215cf7b898
commit
fea37b387c
@ -41,19 +41,10 @@ var (
|
||||
|
||||
// killCmd kills one or more containers with a signal
|
||||
func killCmd(c *cli.Context) error {
|
||||
args := c.Args()
|
||||
if (!c.Bool("all") && !c.Bool("latest")) && len(args) == 0 {
|
||||
return errors.Errorf("you must specify one or more containers to kill")
|
||||
}
|
||||
if (c.Bool("all") || c.Bool("latest")) && len(args) > 0 {
|
||||
return errors.Errorf("you cannot specify any containers to kill with --latest or --all")
|
||||
}
|
||||
if c.Bool("all") && c.Bool("latest") {
|
||||
return errors.Errorf("--all and --latest cannot be used together")
|
||||
}
|
||||
if len(args) < 1 && !c.Bool("all") && !c.Bool("latest") {
|
||||
return errors.Errorf("you must provide at least one container name or id")
|
||||
if err := checkAllAndLatest(c); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := validateFlags(c, killFlags); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -96,6 +87,7 @@ func killCmd(c *cli.Context) error {
|
||||
}
|
||||
containers = append(containers, lastCtr)
|
||||
} else {
|
||||
args := c.Args()
|
||||
for _, i := range args {
|
||||
container, err := runtime.LookupContainer(i)
|
||||
if err != nil {
|
||||
|
Reference in New Issue
Block a user