mirror of https://github.com/docker/docs.git
45 lines
943 B
Go
45 lines
943 B
Go
package commands
|
|
|
|
import (
|
|
"github.com/codegangsta/cli"
|
|
"github.com/docker/machine/log"
|
|
)
|
|
|
|
func cmdRm(c *cli.Context) {
|
|
if len(c.Args()) == 0 {
|
|
cli.ShowCommandHelp(c, "rm")
|
|
log.Fatal("You must specify a machine name")
|
|
}
|
|
|
|
force := c.Bool("force")
|
|
|
|
isError := false
|
|
|
|
certInfo := getCertPathInfo(c)
|
|
defaultStore, err := getDefaultStore(
|
|
c.GlobalString("storage-path"),
|
|
certInfo.CaCertPath,
|
|
certInfo.CaKeyPath,
|
|
)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
provider, err := newProvider(defaultStore)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
for _, host := range c.Args() {
|
|
if err := provider.Remove(host, force); err != nil {
|
|
log.Errorf("Error removing machine %s: %s", host, err)
|
|
isError = true
|
|
} else {
|
|
log.Infof("Successfully removed %s", host)
|
|
}
|
|
}
|
|
if isError {
|
|
log.Fatal("There was an error removing a machine. To force remove it, pass the -f option. Warning: this might leave it running on the provider.")
|
|
}
|
|
}
|