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


Golang Do.Operations方法代码示例

本文整理汇总了Golang中github.com/eris-ltd/eris-cli/definitions.Do.Operations方法的典型用法代码示例。如果您正苦于以下问题:Golang Do.Operations方法的具体用法?Golang Do.Operations怎么用?Golang Do.Operations使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/eris-ltd/eris-cli/definitions.Do的用法示例。


在下文中一共展示了Do.Operations方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: DefineAppActionService

func DefineAppActionService(do *definitions.Do, app *definitions.Contracts) error {
	var cmd string

	switch do.Name {
	case "test":
		cmd = app.AppType.TestCmd
	case "deploy":
		cmd = app.AppType.DeployCmd
	default:
		return fmt.Errorf("I do not know how to perform that task (%s)\nPlease check what you can do with contracts by typing [eris contracts].\n", do.Name)
	}

	// if manual, set task
	if app.AppType.Name == "manual" {
		switch do.Name {
		case "test":
			cmd = app.TestTask
		case "deploy":
			cmd = app.DeployTask
		}
	}

	// task flag override
	if do.Task != "" {
		app.AppType = definitions.GulpApp()
		cmd = do.Task
	}

	if cmd == "nil" {
		return fmt.Errorf("I cannot perform that task against that app type.\n")
	}

	// build service that will run
	do.Service.Name = app.Name + "_tmp_" + do.Name
	do.Service.Image = app.AppType.BaseImage
	do.Service.AutoData = true
	do.Service.EntryPoint = app.AppType.EntryPoint
	do.Service.Command = cmd
	if do.Path != pwd {
		do.Service.WorkDir = do.Path // do.Path is actually where the workdir inside the container goes
	} else {
		do.Service.WorkDir = filepath.Join(common.ErisContainerRoot, "apps", app.Name)
	}
	do.Service.User = "eris"

	srv := definitions.BlankServiceDefinition()
	srv.Service = do.Service
	srv.Operations = do.Operations
	loaders.ServiceFinalizeLoad(srv)
	do.Service = srv.Service
	do.Operations = srv.Operations
	do.Operations.Follow = true

	linkAppToChain(do, app)

	if app.AppType.Name == "epm" {
		prepareEpmAction(do, app)
	}

	// make data container and import do.Path to do.Path (if exists)
	doData := definitions.NowDo()
	doData.Name = do.Service.Name
	doData.Operations = do.Operations
	if do.Path != pwd {
		doData.Destination = do.Path
	} else {
		doData.Destination = common.ErisContainerRoot
	}

	doData.Source = filepath.Join(common.DataContainersPath, doData.Name)
	var loca string
	if do.Path != pwd {
		loca = filepath.Join(common.DataContainersPath, doData.Name, do.Path)
	} else {
		loca = filepath.Join(common.DataContainersPath, doData.Name, "apps", app.Name)
	}
	log.WithFields(log.Fields{
		"path":     do.Path,
		"location": loca,
	}).Debug("Creating app data container")
	common.Copy(do.Path, loca)
	if err := data.ImportData(doData); err != nil {
		return err
	}
	do.Operations.DataContainerName = util.DataContainersName(doData.Name, doData.Operations.ContainerNumber)

	log.Debug("App action built")
	return nil
}
开发者ID:mxjxn,项目名称:eris-cli,代码行数:89,代码来源:operate.go

示例2: DefineDappActionService

func DefineDappActionService(do *definitions.Do, dapp *definitions.Contracts) error {
	var cmd string

	switch do.Name {
	case "test":
		cmd = dapp.DappType.TestCmd
	case "deploy":
		cmd = dapp.DappType.DeployCmd
	default:
		return fmt.Errorf("I do not know how to perform that task (%s)\nPlease check what you can do with contracts by typing [eris contracts].\n", do.Name)
	}

	// if manual, set task
	if dapp.DappType.Name == "manual" {
		switch do.Name {
		case "test":
			cmd = dapp.TestTask
		case "deploy":
			cmd = dapp.DeployTask
		}
	}

	// task flag override
	if do.Task != "" {
		dapp.DappType = definitions.GulpDapp()
		cmd = do.Task
	}

	if cmd == "nil" {
		return fmt.Errorf("I cannot perform that task against that dapp type.\n")
	}

	// dapp-specific tests
	if dapp.DappType.Name == "pyepm" {
		if do.ConfigFile == "" {
			return fmt.Errorf("The pyepm dapp type requires a --yaml flag for the package definition you would like to deploy.\n")
		} else {
			cmd = do.ConfigFile
		}
	}

	// build service that will run
	do.Service.Name = dapp.Name + "_tmp_" + do.Name
	do.Service.Image = dapp.DappType.BaseImage
	do.Service.AutoData = true
	do.Service.EntryPoint = dapp.DappType.EntryPoint
	do.Service.Command = cmd
	if do.NewName != "" {
		do.Service.WorkDir = do.NewName // do.NewName is actually where the workdir inside the container goes
	}
	do.Service.User = "eris"

	srv := definitions.BlankServiceDefinition()
	srv.Service = do.Service
	srv.Operations = do.Operations
	loaders.ServiceFinalizeLoad(srv)
	do.Service = srv.Service
	do.Operations = srv.Operations
	do.Operations.Remove = true

	linkDappToChain(do, dapp)

	// make data container and import do.Path to do.NewName (if exists)
	doData := definitions.NowDo()
	doData.Name = do.Service.Name
	doData.Operations = do.Operations
	if do.NewName != "" {
		doData.Path = do.NewName
	}

	loca := path.Join(common.DataContainersPath, doData.Name)
	logger.Debugf("Creating Dapp Data Cont =>\t%s:%s\n", do.Path, loca)
	common.Copy(do.Path, loca)
	data.ImportData(doData)
	do.Operations.DataContainerName = util.DataContainersName(doData.Name, doData.Operations.ContainerNumber)

	logger.Debugf("DApp Action Built.\n")

	return nil
}
开发者ID:jumanjiman,项目名称:eris-cli,代码行数:80,代码来源:operate.go


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