當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。