当前位置: 首页>>代码示例>>Golang>>正文


Golang API.Remove方法代码示例

本文整理汇总了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)
}
开发者ID:RaulKite,项目名称:machine,代码行数:7,代码来源:rm.go

示例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
}
开发者ID:dgageot,项目名称:docker-machine-daemon,代码行数:27,代码来源:remove.go

示例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
}
开发者ID:ksasi,项目名称:machine,代码行数:30,代码来源:rm.go

示例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()
}
开发者ID:rawlingsj,项目名称:gofabric8,代码行数:11,代码来源:cluster.go

示例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()
}
开发者ID:tmrts,项目名称:minikube,代码行数:11,代码来源:cluster.go

示例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
}
开发者ID:sergey-stratoscale,项目名称:machine,代码行数:44,代码来源:rm.go

示例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
}
开发者ID:MerlinDMC,项目名称:machine,代码行数:37,代码来源:rm.go


注:本文中的github.com/docker/machine/libmachine.API.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。