本文整理匯總了Golang中github.com/docker/machine/libmachine.API.Remove方法的典型用法代碼示例。如果您正苦於以下問題:Golang API.Remove方法的具體用法?Golang API.Remove怎麽用?Golang API.Remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/docker/machine/libmachine.API
的用法示例。
在下文中一共展示了API.Remove方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: removeLocalMachine
func removeLocalMachine(hostName string, api libmachine.API) error {
exist, _ := api.Exists(hostName)
if !exist {
return errors.New(hostName + " does not exist.")
}
return api.Remove(hostName)
}
示例2: Remove
// Remove removes a Docker Machine
func Remove(api libmachine.API, args map[string]string, form map[string][]string) (interface{}, error) {
name, present := args["name"]
if !present {
return nil, errRequireMachineName
}
exist, _ := api.Exists(name)
if !exist {
return Success{"removed", name}, nil
}
currentHost, err := api.Load(name)
if err != nil {
return nil, err
}
if err := currentHost.Driver.Remove(); err != nil {
return nil, err
}
if err := api.Remove(name); err != nil {
return nil, err
}
return Success{"removed", name}, nil
}
示例3: cmdRm
func cmdRm(c CommandLine, api libmachine.API) error {
if len(c.Args()) == 0 {
c.ShowHelp()
return errors.New("You must specify a machine name")
}
force := c.Bool("force")
for _, hostName := range c.Args() {
h, err := api.Load(hostName)
if err != nil {
return fmt.Errorf("Error removing host %q: %s", hostName, err)
}
if err := h.Driver.Remove(); err != nil {
if !force {
log.Errorf("Provider error removing machine %q: %s", hostName, err)
continue
}
}
if err := api.Remove(hostName); err != nil {
log.Errorf("Error removing machine %q from store: %s", hostName, err)
} else {
log.Infof("Successfully removed %s", hostName)
}
}
return nil
}
示例4: DeleteHost
// DeleteHost deletes the host VM.
func DeleteHost(api libmachine.API) error {
host, err := api.Load(constants.MachineName)
if err != nil {
return errors.Wrapf(err, "Error deleting host: %s", constants.MachineName)
}
m := util.MultiError{}
m.Collect(host.Driver.Remove())
m.Collect(api.Remove(constants.MachineName))
return m.ToError()
}
示例5: DeleteHost
// DeleteHost deletes the host VM.
func DeleteHost(api libmachine.API) error {
host, err := api.Load(constants.MachineName)
if err != nil {
return err
}
m := multiError{}
m.Collect(host.Driver.Remove())
m.Collect(api.Remove(constants.MachineName))
return m.ToError()
}
示例6: cmdRm
func cmdRm(c CommandLine, api libmachine.API) error {
if len(c.Args()) == 0 {
c.ShowHelp()
return ErrNoMachineSpecified
}
force := c.Bool("force")
confirm := c.Bool("y")
for _, hostName := range c.Args() {
h, loaderr := api.Load(hostName)
if loaderr != nil {
// On --force, continue to remove on-disk files/dir
if !force {
return fmt.Errorf("Error removing host %q: %s", hostName, loaderr)
}
log.Errorf("Error removing host %q: %s. Continuing on `-f`, host instance may by running", hostName, loaderr)
}
if !confirm && !force {
userinput, err := confirmInput(fmt.Sprintf("Do you really want to remove %q?", hostName))
if !userinput {
return err
}
}
if loaderr == nil {
if err := h.Driver.Remove(); err != nil {
if !force {
log.Errorf("Provider error removing machine %q: %s", hostName, err)
continue
}
}
}
if err := api.Remove(hostName); err != nil {
log.Errorf("Error removing machine %q from store: %s", hostName, err)
} else {
log.Infof("Successfully removed %s", hostName)
}
}
return nil
}
示例7: cmdRm
func cmdRm(c CommandLine, api libmachine.API) error {
if len(c.Args()) == 0 {
c.ShowHelp()
return ErrNoMachineSpecified
}
log.Info(fmt.Sprintf("About to remove %s", strings.Join(c.Args(), ",")))
force := c.Bool("force")
confirm := c.Bool("y")
var errorOccured string
if !userConfirm(confirm, force) {
return nil
}
for _, hostName := range c.Args() {
err := removeRemoteMachine(hostName, api)
if err != nil {
errorOccured = fmt.Sprintf("Error removing host %q: %s", hostName, err)
log.Errorf(errorOccured)
}
if err == nil || force {
removeErr := api.Remove(hostName)
if removeErr != nil {
log.Errorf("Error removing machine %q from store: %s", hostName, removeErr)
} else {
log.Infof("Successfully removed %s", hostName)
}
}
}
if errorOccured != "" {
return errors.New(errorOccured)
}
return nil
}