예제 #1
0
파일: load.go 프로젝트: alexandrev/eris-cli
// marshal from viper to definitions struct
func marshalActionDefinition(actionConf *viper.Viper, action *def.Action) error {
	err := actionConf.Marshal(action)
	if err != nil {
		return fmt.Errorf("Tragic! The marmots could not read that action definition file:\n%v\n", err)
	}
	return nil
}
예제 #2
0
// marshal from viper to definitions struct
func MarshalChainDefinition(chainConf *viper.Viper, chain *definitions.Chain) error {
	chnTemp := definitions.BlankChain()
	// logger.Debugf("Loader.Chain: ChainID =>\t\t%v\n", chain.ChainID)
	// logger.Debugf("Loader.Chain. Conf =>\t\t%v\n", chainConf)
	err := chainConf.Marshal(chnTemp)
	if err != nil {
		return fmt.Errorf("The marmots coult not marshal from viper to chain def: %v", err)
	}
	// logger.Debugf("Loader.Chain.Marshal: ChanID =>\t%v\n", chnTemp.ChainID)

	mergeChainAndService(chain, chnTemp.Service)
	chain.ChainID = chnTemp.ChainID

	// toml bools don't really marshal well
	// data_container can be in the chain or
	// in the service layer. this is very
	// opinionated. we know.
	for _, s := range []string{"", "service."} {
		if chainConf.GetBool(s + "data_container") {
			logger.Debugln("Loader.Chain.Marshal: Data Containers Turned On.")
			chain.Service.AutoData = true
		}
	}

	return nil
}
예제 #3
0
func marshallGlobalConfig(globalConfig *viper.Viper, config *ErisConfig) error {
	err := globalConfig.Marshal(config)
	if err != nil {
		return err
	}

	return nil
}
예제 #4
0
func marshalContractPackage(contConf *viper.Viper) (*definitions.Contracts, error) {
	pkg := definitions.BlankPackage()
	err := contConf.Marshal(pkg)
	app := pkg.Contracts
	app.Name = pkg.Name

	if err != nil {
		// Viper's error messages are atrocious.
		return nil, fmt.Errorf("Sorry, the marmots could not figure that package.json out.\nPlease check your package.json is properly formatted.\n")
	}

	return app, nil
}
예제 #5
0
func MarshalServiceDefinition(serviceConf *viper.Viper, srv *definitions.ServiceDefinition) error {
	err := serviceConf.Marshal(srv)
	if err != nil {
		// Vipers error messages are atrocious.
		return fmt.Errorf("Sorry, the marmots could not figure that service definition out.\nPlease check for known services with [eris services known] and retry.\n")
	}

	// toml bools don't really marshal well
	if serviceConf.GetBool("service.data_container") {
		srv.Service.AutoData = true
	}

	return nil
}
예제 #6
0
func marshalContractPackage(contConf *viper.Viper) (*definitions.Contracts, error) {
	pkg := definitions.BlankPackage()
	err := contConf.Marshal(pkg)
	dapp := pkg.Contracts
	dapp.Name = pkg.Name

	logger.Debugf("Package marshalled, testType =>\t%s\n", dapp.TestType)
	logger.Debugf("\tdeployType =>\t\t%s\n", dapp.DeployType)
	logger.Debugf("\ttestTask =>\t\t%s\n", dapp.TestTask)
	logger.Debugf("\tdeployTask =>\t\t%s\n", dapp.DeployTask)

	if err != nil {
		// Viper's error messages are atrocious.
		return nil, fmt.Errorf("Sorry, the marmots could not figure that package.json out.\nPlease check your package.json is properly formatted.\n")
	}

	return dapp, nil
}
예제 #7
0
파일: chains.go 프로젝트: mxjxn/eris-cli
// marshal from viper to definitions struct
func MarshalChainDefinition(chainConf *viper.Viper, chain *definitions.Chain) error {
	log.Debug("Marshalling chain")
	chnTemp := definitions.BlankChain()
	err := chainConf.Marshal(chnTemp)
	if err != nil {
		return fmt.Errorf("The marmots coult not marshal from viper to chain def: %v", err)
	}

	util.Merge(chain.Service, chnTemp.Service)
	chain.ChainID = chnTemp.ChainID

	// toml bools don't really marshal well
	// data_container can be in the chain or
	// in the service layer. this is very
	// opinionated. we know.
	for _, s := range []string{"", "service."} {
		if chainConf.GetBool(s + "data_container") {
			chain.Service.AutoData = true
			log.WithField("autodata", chain.Service.AutoData).Debug()
		}
	}

	return nil
}