func locateOpsRoot()

in prepare.go [166:195]


func locateOpsRoot(cur string) (string, error) {
	cur, err := filepath.Abs(cur)
	if err != nil {
		return "", err
	}

	// search the root from here
	search := locateOpsRootSearch(cur)
	if search != "" {
		trace("found searching up:", search)
		return search, nil
	}

	// is there  olaris folder?
	olaris := joinpath(cur, "olaris")
	if exists(cur, "olaris") && exists(olaris, OPSFILE) && exists(olaris, OPSROOT) {
		trace("found sub olaris:", olaris)
		return olaris, nil
	}

	// is there an olaris folder in ~/.ops ?
	opsOlarisDir := fmt.Sprintf("~/.ops/%s/olaris", getOpsBranch())
	olaris, err = homedir.Expand(opsOlarisDir)
	if err == nil && exists(olaris, OPSFILE) && exists(olaris, OPSROOT) {
		trace("found sub", opsOlarisDir, ":", olaris)
		return olaris, nil
	}

	return "", fmt.Errorf("cannot find opsfiles, download them with ops -update")
}