github.com/engineyard/workflow-cli@v2.21.6+incompatible/settings/utils.go (about)

     1  package settings
     2  
     3  import (
     4  	"os"
     5  	"path/filepath"
     6  	"regexp"
     7  )
     8  
     9  var filepathRegex = regexp.MustCompile(`^.*[/\\].+\.json$`)
    10  
    11  func locateSettingsFile(cf string) string {
    12  	if cf == "" {
    13  		if v, ok := os.LookupEnv("DEIS_PROFILE"); ok {
    14  			cf = v
    15  		} else {
    16  			cf = "client"
    17  		}
    18  	}
    19  
    20  	// if path appears to be a filepath (contains a separator and ends in .json) don't alter the path
    21  	if filepathRegex.MatchString(cf) {
    22  		return cf
    23  	}
    24  
    25  	return filepath.Join(FindHome(), ".deis", cf+".json")
    26  }