github.com/bosssauce/ponzu@v0.11.1-0.20200102001432-9bc41b703131/system/cfg/env.go (about)

     1  package cfg
     2  
     3  import (
     4  	"log"
     5  	"os"
     6  	"path/filepath"
     7  )
     8  
     9  func getWd() string {
    10  	wd, err := os.Getwd()
    11  	if err != nil {
    12  		log.Fatalln("Couldn't find working directory", err)
    13  	}
    14  	return wd
    15  }
    16  
    17  func DataDir() string {
    18  	dataDir := os.Getenv("PONZU_DATA_DIR")
    19  	if dataDir == "" {
    20  		return getWd()
    21  	}
    22  	return dataDir
    23  }
    24  
    25  func TlsDir() string {
    26  	tlsDir := os.Getenv("PONZU_TLS_DIR")
    27  	if tlsDir == "" {
    28  		tlsDir = filepath.Join(getWd(), "cmd", "ponzu", "vendor", "github.com", "ponzu-cms", "ponzu", "system", "tls")
    29  	}
    30  	return tlsDir
    31  }
    32  
    33  func AdminStaticDir() string {
    34  	staticDir := os.Getenv("PONZU_ADMINSTATIC_DIR")
    35  	if staticDir == "" {
    36  
    37  		staticDir = filepath.Join(getWd(), "cmd", "ponzu", "vendor", "github.com", "ponzu-cms", "ponzu", "system", "admin", "static")
    38  	}
    39  	return staticDir
    40  }
    41  
    42  func UploadDir() string {
    43  	uploadDir := os.Getenv("PONZU_UPLOAD_DIR")
    44  	if uploadDir == "" {
    45  		uploadDir = filepath.Join(DataDir(),"uploads")
    46  	}
    47  	return uploadDir
    48  }
    49  
    50  func SearchDir() string {
    51  	searchDir := os.Getenv("PONZU_SEARCH_DIR")
    52  	if searchDir == "" {
    53  		searchDir = filepath.Join(DataDir(),"search")
    54  	}
    55  	return searchDir
    56  }