本文整理汇总了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
}