• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang definitions.Contracts类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: setAppType

func setAppType(app *definitions.Contracts, name, command, typ string) error {
	var t string

	log.WithFields(log.Fields{
		"task": command,
		"type": typ,
		"app":  name,
	}).Debug("Setting app type")

	if typ != "" {
		t = typ
	} else {
		switch command {
		case "test":
			t = app.TestType
		case "deploy":
			t = app.DeployType
		}
	}

	switch t {
	case "embark":
		app.AppType = definitions.EmbarkApp()
	case "sunit":
		app.AppType = definitions.SUnitApp()
	case "manual":
		app.AppType = definitions.GulpApp()
	default:
		app.AppType = definitions.EPMApp()
	}

	log.WithField("app type", app.AppType.Name).Debug()

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


示例2: setDappType

func setDappType(dapp *definitions.Contracts, name, command, typ string) error {
	var t string

	logger.Debugf("Setting Dapp Type. Task =>\t%s\n", command)
	logger.Debugf("\tType =>\t\t%s\n", typ)
	logger.Debugf("\tChainName =>\t\t%s\n", name)

	if typ != "" {
		t = typ
	} else {
		switch command {
		case "test":
			t = dapp.TestType
		case "deploy":
			t = dapp.DeployType
		}
	}

	switch t {
	case "embark":
		dapp.DappType = definitions.EmbarkDapp()
	case "pyepm":
		dapp.DappType = definitions.PyEpmDapp()
	case "sunit":
		dapp.DappType = definitions.SUnitDapp()
	case "manual":
		dapp.DappType = definitions.GulpDapp()
	default:
		return fmt.Errorf("Unregistered DappType.\nUnfortunately our marmots cannot deal with that.\nPlease ensure that the dapp type is set in the package.json.")
	}

	logger.Debugf("\tDapp Type =>\t\t%s\n", dapp.DappType.Name)

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


示例3: setAppType

func setAppType(app *definitions.Contracts, name, command, typ string) error {
	var t string

	logger.Debugf("Setting App Type. Task =>\t%s\n", command)
	logger.Debugf("\tChainType =>\t\t%s\n", typ)
	logger.Debugf("\tChainName =>\t\t%s\n", name)

	if typ != "" {
		t = typ
	} else {
		switch command {
		case "test":
			t = app.TestType
		case "deploy":
			t = app.DeployType
		}
	}

	switch t {
	case "embark":
		app.AppType = definitions.EmbarkApp()
	case "sunit":
		app.AppType = definitions.SUnitApp()
	case "manual":
		app.AppType = definitions.GulpApp()
	default:
		app.AppType = definitions.EPMApp()
	}

	logger.Debugf("\tApp Type =>\t\t%s\n", app.AppType.Name)

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


示例4: checkAppAndChain

func checkAppAndChain(app *definitions.Contracts, name string) error {
	var chain string

	// name is pulled in from the do struct. need to work with both
	// it (as an override) and the app.ChainName
	switch name {
	case "":
		if app.ChainName == "" {
			return nil
		} else {
			chain = app.ChainName
		}
	case "t", "tmp", "temp":
		return nil
	default:
		chain = name
	}

	if strings.Contains(app.Name, " ") {
		app.Name = strings.Replace(app.Name, " ", "_", -1)
	}

	// this is hacky.... at best.
	if len(app.AppType.ChainTypes) == 1 && app.AppType.ChainTypes[0] == "eth" {
		if r := regexp.MustCompile("eth"); r.MatchString(chain) {
			return nil
		} else {
			return fmt.Errorf("The marmots detected a disturbance in the force.\n\nYou asked them to run the App Type: (%s).\nBut the chainName (%s) doesn't contain the name (%s).\nPlease rename the chain or service to contain the name (%s)", app.AppType.Name, chain, "eth", "eth")
		}
	}

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


示例5: BootServicesAndChain

func BootServicesAndChain(do *definitions.Do, dapp *definitions.Contracts) error {
	var err error
	var srvs []*definitions.ServiceDefinition

	// launch the services
	for _, s := range do.ServicesSlice {
		t, err := services.BuildServicesGroup(s, do.Operations.ContainerNumber, srvs...)
		if err != nil {
			return err
		}
		srvs = append(srvs, t...)
	}

	// TODO: refactor this logic, should only need to call services.StartGroup(srvs)
	if len(srvs) >= 1 {
		wg, ch := new(sync.WaitGroup), make(chan error, 1)
		services.StartGroup(ch, wg, srvs)
		go func() {
			wg.Wait()
			ch <- nil
		}()
		if err := <-ch; err != nil {
			return err
		}
	}

	// boot the chain
	switch do.ChainName {
	case "":
		if dapp.ChainName == "" {
			logger.Infof("No chain was given, booting a throwaway chain.\n")
			err = bootThrowAwayChain(dapp.Name, do)
		} else {
			logger.Infof("Booting chain =>\t\t%s\n", dapp.ChainName)
			err = bootChain(dapp.ChainName, do)
		}
	case "t", "tmp", "temp":
		logger.Infof("No chain was given, booting a throwaway chain.\n")
		err = bootThrowAwayChain(dapp.Name, do)
	default:
		logger.Infof("Booting chain =>\t\t%s\n", do.ChainName)
		err = bootChain(do.ChainName, do)
	}

	dapp.ChainName = do.Chain.Name
	if err != nil {
		return err
	}

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


示例6: BootServicesAndChain

func BootServicesAndChain(do *definitions.Do, app *definitions.Contracts) error {
	var err error
	var srvs []*definitions.ServiceDefinition

	// launch the services
	for _, s := range do.ServicesSlice {
		t, err := services.BuildServicesGroup(s, do.Operations.ContainerNumber, srvs...)
		if err != nil {
			return err
		}
		srvs = append(srvs, t...)
	}

	if len(srvs) >= 1 {
		if err := services.StartGroup(srvs); err != nil {
			return err
		}
	}

	// boot the chain
	switch do.ChainName {
	case "":
		if app.ChainName == "" {
			// TODO [csk]: first check if there is a chain checked out. if not, then use throwAway
			log.Info("No chain was given, booting a throwaway chain")
			err = bootThrowAwayChain(app.Name, do)
		} else {
			log.WithField("=>", app.ChainName).Info("Booting chain")
			err = bootChain(app.ChainName, do)
		}
	case "t", "tmp", "temp":
		log.Info("No chain was given, booting a throwaway chain")
		err = bootThrowAwayChain(app.Name, do)
	default:
		log.WithField("=>", do.ChainName).Info("Booting chain")
		err = bootChain(do.ChainName, do)
	}

	app.ChainName = do.Chain.Name
	if err != nil {
		return err
	}

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


示例7: BootServicesAndChain

func BootServicesAndChain(do *definitions.Do, dapp *definitions.Contracts) error {
	var err error
	var srvs []*definitions.ServiceDefinition

	// launch the services
	for _, s := range do.ServicesSlice {
		t, err := services.BuildServicesGroup(s, do.Operations.ContainerNumber, srvs...)
		if err != nil {
			return err
		}
		srvs = append(srvs, t...)
	}

	if len(srvs) >= 1 {
		if err := services.StartGroup(srvs); err != nil {
			return err
		}
	}

	// boot the chain
	switch do.ChainName {
	case "":
		if dapp.ChainName == "" {
			logger.Infof("No chain was given, booting a throwaway chain.\n")
			err = bootThrowAwayChain(dapp.Name, do)
		} else {
			logger.Infof("Booting chain =>\t\t%s\n", dapp.ChainName)
			err = bootChain(dapp.ChainName, do)
		}
	case "t", "tmp", "temp":
		logger.Infof("No chain was given, booting a throwaway chain.\n")
		err = bootThrowAwayChain(dapp.Name, do)
	default:
		logger.Infof("Booting chain =>\t\t%s\n", do.ChainName)
		err = bootChain(do.ChainName, do)
	}

	dapp.ChainName = do.Chain.Name
	if err != nil {
		return err
	}

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


示例8: 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


示例9: 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.Contracts类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang definitions.Do类代码示例发布时间:2022-05-23
下一篇:
Golang definitions.Chain类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap