Example #1
0
// check if given chain is known
func isKnownChain(name string) bool {
	known := util.GetGlobalLevelConfigFilesByType("chains", false)
	if len(known) != 0 {
		for _, srv := range known {
			if srv == name {
				return true
			}
		}
	}
	return false
}
//looks for definition files in ~/.eris/typ
func ListKnown(typ string) (result string, err error) {

	result = strings.Join(util.GetGlobalLevelConfigFilesByType(typ, false), "\n")

	if typ == "chains" {
		var chainsNew []string
		head, _ := util.GetHead()
		chns := util.GetGlobalLevelConfigFilesByType(typ, false)

		for _, c := range chns {
			switch c {
			case "default":
				continue
			case head:
				chainsNew = append(chainsNew, fmt.Sprintf("*%s", c))
			default:
				chainsNew = append(chainsNew, fmt.Sprintf("%s", c))
			}
		}
		result = strings.Join(chainsNew, "\n")
	}
	return result, nil
}
Example #3
0
func CatService(do *definitions.Do) error {
	configs := util.GetGlobalLevelConfigFilesByType("services", true)
	for _, c := range configs {
		cName := strings.Split(filepath.Base(c), ".")[0]
		if cName == do.Name {
			cat, err := ioutil.ReadFile(c)
			if err != nil {
				return err
			}
			do.Result = string(cat)
			logger.Println(string(cat))
			return nil
		}
	}
	return fmt.Errorf("Unknown service %s or invalid file extension", do.Name)
}
Example #4
0
func ListKnown(do *definitions.Do) error {
	head, _ := util.GetHead()
	chns := util.GetGlobalLevelConfigFilesByType("chains", false)
	var chainsNew []string
	for _, c := range chns {
		switch c {
		case "default":
			continue
		case head:
			chainsNew = append(chainsNew, fmt.Sprintf("*\t%s", c))
		default:
			chainsNew = append(chainsNew, fmt.Sprintf("\t%s", c))
		}
		// if c == head {
		// } else {
		// }
	}
	do.Result = strings.Join(chainsNew, "\n")
	return nil
}
Example #5
0
func ListKnown(do *definitions.Do) error {
	srvs := util.GetGlobalLevelConfigFilesByType("services", false)
	do.Result = strings.Join(srvs, "\n")
	return nil
}
Example #6
0
func ListKnown(do *definitions.Do) error {
	chns := util.GetGlobalLevelConfigFilesByType("chains", false)
	do.Result = strings.Join(chns, "\n")
	return nil
}