path
This commit is contained in:
parent
3ac11468a1
commit
79b3c8d693
5 changed files with 6 additions and 30 deletions
|
|
@ -8,7 +8,6 @@ import (
|
|||
)
|
||||
|
||||
func loadConfig() (Config, error) {
|
||||
projectRoot := strings.TrimSpace(getenv("PROJECTS_ROOT", "$HOME/projects/$app"))
|
||||
cfg := Config{
|
||||
DatabaseURL: getenv("DATABASE_URL", "postgres://postgres:postgres@localhost:5432/box?sslmode=disable"),
|
||||
ListenAddr: getenv("LISTEN_ADDR", ":8080"),
|
||||
|
|
@ -21,7 +20,6 @@ func loadConfig() (Config, error) {
|
|||
ForgejoBaseURL: strings.TrimRight(getenv("FORGEJO_BASE_URL", ""), "/"),
|
||||
ForgejoToken: getenv("FORGEJO_TOKEN", ""),
|
||||
ForgejoOrg: getenv("FORGEJO_ORG", ""),
|
||||
ProjectRoot: projectRoot,
|
||||
CaddyAdminURL: strings.TrimRight(getenv("CADDY_ADMIN_URL", "http://localhost:2019"), "/"),
|
||||
CaddyServerID: getenv("CADDY_SERVER_ID", "srv0"),
|
||||
CaddyDomainSuffix: getenv("CADDY_DOMAIN_SUFFIX", ""),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ package app
|
|||
|
||||
import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func (a *App) projectDirFor(p Project) (string, error) {
|
||||
|
|
@ -10,20 +9,5 @@ func (a *App) projectDirFor(p Project) (string, error) {
|
|||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
tpl := strings.TrimSpace(a.cfg.ProjectRoot)
|
||||
if tpl == "" {
|
||||
tpl = "$HOME/projects/$app"
|
||||
}
|
||||
path := tpl
|
||||
path = strings.ReplaceAll(path, "${HOME}", homeDir)
|
||||
path = strings.ReplaceAll(path, "$HOME", homeDir)
|
||||
path = strings.ReplaceAll(path, "${app}", p.Slug)
|
||||
path = strings.ReplaceAll(path, "$app", p.Slug)
|
||||
if strings.HasPrefix(path, "~/") {
|
||||
path = filepath.Join(homeDir, strings.TrimPrefix(path, "~/"))
|
||||
}
|
||||
if !filepath.IsAbs(path) {
|
||||
path = filepath.Join(homeDir, path)
|
||||
}
|
||||
return filepath.Clean(path), nil
|
||||
return filepath.Clean(filepath.Join(homeDir, "projects", p.Slug)), nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ type Config struct {
|
|||
ForgejoBaseURL string
|
||||
ForgejoToken string
|
||||
ForgejoOrg string
|
||||
ProjectRoot string
|
||||
CaddyAdminURL string
|
||||
CaddyServerID string
|
||||
CaddyDomainSuffix string
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue