示例#1
0
//------- helpers --------
func checkIPFSnotRunning() {
	//os.Setenv("ERIS_IPFS_HOST", "http://0.0.0.0") //conflicts with docker-machine
	do := def.NowDo()
	do.Known = false
	do.Existing = false
	do.Running = true
	do.Quiet = true
	log.Debug("Finding the running services")
	if err := list.ListAll(do, "services"); err != nil {
		IfExit(err)
	}
	res := strings.Split(do.Result, "\n")
	for _, r := range res {
		if r == "ipfs" {
			IfExit(fmt.Errorf("IPFS service is running.\nPlease stop it with.\neris services stop -rx ipfs\n"))
		}
	}
	// make sure ipfs container does not exist
	do = def.NowDo()
	do.Known = false
	do.Existing = true
	do.Running = false
	do.Quiet = true
	log.Debug("Finding the existing services")
	if err := list.ListAll(do, "services"); err != nil {
		IfExit(err)
	}
	res = strings.Split(do.Result, "\n")
	for _, r := range res {
		if r == "ipfs" {
			IfExit(fmt.Errorf("IPFS service exists.\nPlease remove it with\neris services rm ipfs\n"))
		}
	}
}
示例#2
0
func ListAllTheThings() {
	//do.All for known/existing/running
	do.All = true

	typs := []string{"chains", "services"}
	for _, typ := range typs {
		if err := list.ListAll(do, typ); err != nil {
			return
		}
	}
	if err := list.ListDatas(do); err != nil {
		return
	}
	if err := list.ListActions(do); err != nil {
		return
	}
}
示例#3
0
func TestListAllChainsKnown(t *testing.T) {
	if err := mockChainDefinitionFile("test-chain-list2"); err != nil {
		t.Fatalf("can't create a fake service definition: %v", err)
	}

	do := def.NowDo()
	do.Known = true
	do.Existing = false
	do.Running = false
	do.Quiet = true
	if err := list.ListAll(do, "chains"); err != nil {
		t.Fatalf("expected list to succeed, got %v", err)
	}

	if !strings.Contains(do.Result, "test-chain-list2") {
		t.Fatalf("expected the chain to be found")
	}
}
示例#4
0
func TestKnownServices(t *testing.T) {
	do := def.NowDo()
	do.Known = true
	do.Existing = false
	do.Running = false
	do.Quiet = true
	if err := list.ListAll(do, "services"); err != nil {
		t.Fatalf("expected list to succeed, got %v", err)
	}

	// Join with ".toml" to avoid an extra for...range.
	definitions := strings.Split(strings.Join(strings.Split(do.Result, "\n"), ".toml ")+".toml", " ")

	sort.Strings(definitions)
	sort.Strings(ver.SERVICE_DEFINITIONS)

	if len(definitions) != len(ver.SERVICE_DEFINITIONS) {
		t.Errorf("expected %v, got %v service definitions", len(ver.SERVICE_DEFINITIONS), len(definitions))
	}

	if reflect.DeepEqual(definitions, ver.SERVICE_DEFINITIONS) != true {
		t.Fatalf("did not find all expected service definitions %v, got %v", ver.SERVICE_DEFINITIONS, definitions)
	}
}
示例#5
0
func ListAllServices(cmd *cobra.Command, args []string) {
	//if no flags are set, list all the things
	//otherwise, allow only a single flag
	if !(do.Known || do.Running || do.Existing) {
		do.All = true
	} else {
		flargs := []bool{do.Known, do.Running, do.Existing}
		flags := []string{}

		for _, f := range flargs {
			if f == true {
				flags = append(flags, "true")
			}
		}
		IfExit(FlagCheck(1, "eq", cmd, flags))
	}

	if err := list.ListAll(do, "services"); err != nil {
		return
	}
	if !do.All { //do.All will output a pretty table on its own
		fmt.Println(do.Result)
	}
}