本文整理匯總了Golang中github.com/eris-ltd/eris-cli/util.AutoMagic函數的典型用法代碼示例。如果您正苦於以下問題:Golang AutoMagic函數的具體用法?Golang AutoMagic怎麽用?Golang AutoMagic使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AutoMagic函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LoadChainDefinition
// viper read config file, marshal to definition struct,
// load service, validate name and data container
func LoadChainDefinition(chainName string, newCont bool, cNum ...int) (*definitions.Chain, error) {
if len(cNum) == 0 {
cNum = append(cNum, 0)
}
if cNum[0] == 0 {
cNum[0] = util.AutoMagic(0, "chain", newCont)
logger.Debugf("Loading Chain Definition =>\t%s:%d (autoassigned)\n", chainName, cNum[0])
} else {
logger.Debugf("Loading Chain Definition =>\t%s:%d\n", chainName, cNum[0])
}
chain := definitions.BlankChain()
chain.Name = chainName
chain.Operations.ContainerNumber = cNum[0]
setChainDefaults(chain)
chainConf, err := loadChainDefinition(chainName)
if err != nil {
return nil, err
}
// marshal chain and always reset the operational requirements
// this will make sure to sync with docker so that if changes
// have occured in the interim they are caught.
if err = MarshalChainDefinition(chainConf, chain); err != nil {
return nil, err
}
checkChainNames(chain)
logger.Debugf("Chain Loader. ContNumber =>\t%d\n", chain.Operations.ContainerNumber)
logger.Debugf("\twith Environment =>\t%v\n", chain.Service.Environment)
return chain, nil
}
示例2: TestStartService
func TestStartService(t *testing.T) {
do := def.NowDo()
do.Args = []string{servName}
do.Operations.ContainerNumber = util.AutoMagic(0, "service", true)
logger.Debugf("Starting service (via tests) =>\t%s:%d\n", servName, do.Operations.ContainerNumber)
e := StartService(do)
if e != nil {
logger.Infof("Error starting service =>\t%v\n", e)
t.Fail()
}
testExistAndRun(t, servName, 1, true, true)
testNumbersExistAndRun(t, servName, 1, 1)
}
示例3: LoadChainDefinition
// viper read config file, marshal to definition struct,
// load service, validate name and data container
func LoadChainDefinition(chainName string, newCont bool, cNum ...int) (*definitions.Chain, error) {
if len(cNum) == 0 {
cNum = append(cNum, 0)
}
if cNum[0] == 0 {
cNum[0] = util.AutoMagic(0, definitions.TypeChain, newCont)
log.WithField("=>", fmt.Sprintf("%s:%d", chainName, cNum[0])).Debug("Loading chain definition (autoassigned)")
} else {
log.WithField("=>", fmt.Sprintf("%s:%d", chainName, cNum[0])).Debug("Loading chain definition")
}
chain := definitions.BlankChain()
chain.Name = chainName
chain.Operations.ContainerNumber = cNum[0]
chain.Operations.ContainerType = definitions.TypeChain
chain.Operations.Labels = util.Labels(chain.Name, chain.Operations)
if err := setChainDefaults(chain); err != nil {
return nil, err
}
chainConf, err := config.LoadViperConfig(filepath.Join(ChainsPath), chainName, "chain")
if err != nil {
return nil, err
}
// marshal chain and always reset the operational requirements
// this will make sure to sync with docker so that if changes
// have occured in the interim they are caught.
if err = MarshalChainDefinition(chainConf, chain); err != nil {
return nil, err
}
// Docker 1.6 (which eris doesn't support) had different linking mechanism.
if ver, _ := util.DockerClientVersion(); ver >= version.DVER_MIN {
if chain.Dependencies != nil {
addDependencyVolumesAndLinks(chain.Dependencies, chain.Service, chain.Operations)
}
}
checkChainNames(chain)
log.WithFields(log.Fields{
"container number": chain.Operations.ContainerNumber,
"environment": chain.Service.Environment,
"entrypoint": chain.Service.EntryPoint,
"cmd": chain.Service.Command,
}).Debug("Chain definition loaded")
return chain, nil
}
示例4: MockServiceDefinition
func MockServiceDefinition(servName string, newCont bool, cNum ...int) *definitions.ServiceDefinition {
srv := definitions.BlankServiceDefinition()
srv.Name = servName
if len(cNum) == 0 {
srv.Operations.ContainerNumber = util.AutoMagic(cNum[0], "service", newCont)
logger.Debugf("Mocking Service Definition =>\t%s:%d (autoassigned)\n", servName, cNum[0])
} else {
srv.Operations.ContainerNumber = cNum[0]
logger.Debugf("Mocking Service Definition =>\t%s:%d\n", servName, cNum[0])
}
ServiceFinalizeLoad(srv)
return srv
}
示例5: MockChainDefinition
func MockChainDefinition(chainName, chainID string, newCont bool, cNum ...int) *definitions.Chain {
chn := definitions.BlankChain()
chn.Name = chainName
chn.ChainID = chainID
chn.Service.AutoData = true
if len(cNum) == 0 {
chn.Operations.ContainerNumber = util.AutoMagic(cNum[0], "chain", newCont)
logger.Debugf("Mocking Chain Definition =>\t%s:%d (autoassigned)\n", chainName, cNum[0])
} else {
chn.Operations.ContainerNumber = cNum[0]
logger.Debugf("Mocking Chain Definition =>\t%s:%d\n", chainName, cNum[0])
}
checkChainNames(chn)
return chn
}
示例6: MockServiceDefinition
func MockServiceDefinition(servName string, newCont bool, cNum ...int) *definitions.ServiceDefinition {
srv := definitions.BlankServiceDefinition()
srv.Name = servName
if len(cNum) == 0 {
srv.Operations.ContainerNumber = util.AutoMagic(cNum[0], definitions.TypeService, newCont)
log.WithField("=>", fmt.Sprintf("%s:%d", servName, cNum[0])).Debug("Mocking service definition (autoassigned)")
} else {
srv.Operations.ContainerNumber = cNum[0]
log.WithField("=>", fmt.Sprintf("%s:%d", servName, cNum[0])).Debug("Mocking service definition")
}
srv.Operations.ContainerType = definitions.TypeService
srv.Operations.Labels = util.Labels(servName, srv.Operations)
ServiceFinalizeLoad(srv)
return srv
}
示例7: LoadChainDefinition
// viper read config file, marshal to definition struct,
// load service, validate name and data container
func LoadChainDefinition(chainName string, newCont bool, cNum ...int) (*definitions.Chain, error) {
if len(cNum) == 0 {
cNum = append(cNum, 0)
}
if cNum[0] == 0 {
cNum[0] = util.AutoMagic(0, "chain", newCont)
logger.Debugf("Loading Chain Definition =>\t%s:%d (autoassigned)\n", chainName, cNum[0])
} else {
logger.Debugf("Loading Chain Definition =>\t%s:%d\n", chainName, cNum[0])
}
chain := definitions.BlankChain()
chain.Name = chainName
chain.Operations.ContainerNumber = cNum[0]
if err := setChainDefaults(chain); err != nil {
return nil, err
}
chainConf, err := config.LoadViperConfig(path.Join(BlockchainsPath), chainName, "chain")
if err != nil {
return nil, err
}
// marshal chain and always reset the operational requirements
// this will make sure to sync with docker so that if changes
// have occured in the interim they are caught.
if err = MarshalChainDefinition(chainConf, chain); err != nil {
return nil, err
}
// Docker 1.6 (which eris doesn't support) had different linking mechanism.
if ver, _ := util.DockerClientVersion(); ver >= 1.7 {
if chain.Dependencies != nil {
addDependencyVolumesAndLinks(chain.Dependencies, chain.Service, chain.Operations)
}
}
checkChainNames(chain)
logger.Debugf("Chain Loader. ContNumber =>\t%d\n", chain.Operations.ContainerNumber)
logger.Debugf("\twith Environment =>\t%v\n", chain.Service.Environment)
logger.Debugf("\tBooting =>\t\t%v:%v\n", chain.Service.EntryPoint, chain.Service.Command)
return chain, nil
}
示例8: MockChainDefinition
func MockChainDefinition(chainName, chainID string, newCont bool, cNum ...int) *definitions.Chain {
chn := definitions.BlankChain()
chn.Name = chainName
chn.ChainID = chainID
chn.Service.AutoData = true
if len(cNum) == 0 {
chn.Operations.ContainerNumber = util.AutoMagic(cNum[0], definitions.TypeChain, newCont)
log.WithField("=>", fmt.Sprintf("%s:%d", chainName, cNum[0])).Debug("Mocking chain definition (autoassigned)")
} else {
chn.Operations.ContainerNumber = cNum[0]
log.WithField("=>", fmt.Sprintf("%s:%d", chainName, cNum[0])).Debug("Mocking chain definition")
}
chn.Operations.ContainerType = definitions.TypeChain
chn.Operations.Labels = util.Labels(chainName, chn.Operations)
checkChainNames(chn)
return chn
}
示例9: LoadServiceDefinition
func LoadServiceDefinition(servName string, newCont bool, cNum ...int) (*definitions.ServiceDefinition, error) {
if len(cNum) == 0 {
cNum = append(cNum, 0)
}
if cNum[0] == 0 {
cNum[0] = util.AutoMagic(0, definitions.TypeService, newCont)
logger.Debugf("Loading Service Definition =>\t%s:%d (autoassigned)\n", servName, cNum[0])
} else {
logger.Debugf("Loading Service Definition =>\t%s:%d\n", servName, cNum[0])
}
srv := definitions.BlankServiceDefinition()
srv.Operations.ContainerType = definitions.TypeService
srv.Operations.ContainerNumber = cNum[0]
srv.Operations.Labels = util.Labels(servName, srv.Operations)
serviceConf, err := loadServiceDefinition(servName)
if err != nil {
return nil, err
}
if err = MarshalServiceDefinition(serviceConf, srv); err != nil {
return nil, err
}
if srv.Service == nil {
return nil, fmt.Errorf("No service given.")
}
if err = checkImage(srv.Service); err != nil {
return nil, err
}
// Docker 1.6 (which eris doesn't support) had different linking mechanism.
if ver, _ := util.DockerClientVersion(); ver >= version.DVER_MIN {
addDependencyVolumesAndLinks(srv.Dependencies, srv.Service, srv.Operations)
}
ServiceFinalizeLoad(srv)
return srv, nil
}
示例10: LoadServiceDefinition
func LoadServiceDefinition(servName string, newCont bool, cNum ...int) (*definitions.ServiceDefinition, error) {
if len(cNum) == 0 {
cNum = append(cNum, 0)
}
if cNum[0] == 0 {
cNum[0] = util.AutoMagic(0, "service", newCont)
logger.Debugf("Loading Service Definition =>\t%s:%d (autoassigned)\n", servName, cNum[0])
} else {
logger.Debugf("Loading Service Definition =>\t%s:%d\n", servName, cNum[0])
}
srv := definitions.BlankServiceDefinition()
srv.Operations.ContainerNumber = cNum[0]
serviceConf, err := loadServiceDefinition(servName)
if err != nil {
return nil, err
}
if err = MarshalServiceDefinition(serviceConf, srv); err != nil {
return nil, err
}
if srv.Service == nil {
return nil, fmt.Errorf("No service given.")
}
if err = checkImage(srv.Service); err != nil {
return nil, err
}
if os.Getenv("TEST_IN_CIRCLE") != "true" { // this really should be docker version < 1.7...?
addDependencyVolumesAndLinks(srv)
}
ServiceFinalizeLoad(srv)
return srv, nil
}