本文整理匯總了Golang中github.com/eris-ltd/eris-cli/definitions.Contracts.DappType方法的典型用法代碼示例。如果您正苦於以下問題:Golang Contracts.DappType方法的具體用法?Golang Contracts.DappType怎麽用?Golang Contracts.DappType使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/eris-ltd/eris-cli/definitions.Contracts
的用法示例。
在下文中一共展示了Contracts.DappType方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: 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
}
示例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
}