feat: add helper for fetching AppRoot in golang
This commit is contained in:
1 parent
cd21e90edf
commit
3f0c46d43d
4 files changed
+13
-10
No files matched your search
@@ -69,6 +69,12 @@ func (sc *ShellCmd) Output() ([]byte, error) {
|
|||||||
return sc.Command.Output()
|
return sc.Command.Output()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AppRoot returns the app root path
|
||||||
|
func AppRoot(appName string) string {
|
||||||
|
dokkuRoot := MustGetEnv("DOKKU_ROOT")
|
||||||
|
return fmt.Sprintf("%v/%v", dokkuRoot, appName)
|
||||||
|
}
|
||||||
|
|
||||||
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
// GetDeployingAppImageName returns deploying image identifier for a given app, tag tuple. validate if tag is presented
|
||||||
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (imageName string) {
|
func GetDeployingAppImageName(appName, imageTag, imageRepo string) (imageName string) {
|
||||||
if appName == "" {
|
if appName == "" {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func BuildConfig(appName string) {
|
|||||||
if !common.IsDeployed(appName) {
|
if !common.IsDeployed(appName) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
|
appRoot := common.AppRoot(appName)
|
||||||
scaleFile := strings.Join([]string{appRoot, "DOKKU_SCALE"}, "/")
|
scaleFile := strings.Join([]string{appRoot, "DOKKU_SCALE"}, "/")
|
||||||
if !common.FileExists(scaleFile) {
|
if !common.FileExists(scaleFile) {
|
||||||
return
|
return
|
||||||
@@ -166,8 +166,7 @@ func GetDefaultValue(property string) (value string) {
|
|||||||
|
|
||||||
// GetListeners returns a string array of app listeners
|
// GetListeners returns a string array of app listeners
|
||||||
func GetListeners(appName string) []string {
|
func GetListeners(appName string) []string {
|
||||||
dokkuRoot := common.MustGetEnv("DOKKU_ROOT")
|
appRoot := common.AppRoot(appName)
|
||||||
appRoot := strings.Join([]string{dokkuRoot, appName}, "/")
|
|
||||||
|
|
||||||
files, _ := filepath.Glob(appRoot + "/IP.web.*")
|
files, _ := filepath.Glob(appRoot + "/IP.web.*")
|
||||||
|
|
||||||
@@ -183,7 +182,7 @@ func GetListeners(appName string) []string {
|
|||||||
|
|
||||||
// HasNetworkConfig returns whether the network configuration for a given app exists
|
// HasNetworkConfig returns whether the network configuration for a given app exists
|
||||||
func HasNetworkConfig(appName string) bool {
|
func HasNetworkConfig(appName string) bool {
|
||||||
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
|
appRoot := common.AppRoot(appName)
|
||||||
ipfile := fmt.Sprintf("%v/IP.web.1", appRoot)
|
ipfile := fmt.Sprintf("%v/IP.web.1", appRoot)
|
||||||
portfile := fmt.Sprintf("%v/PORT.web.1", appRoot)
|
portfile := fmt.Sprintf("%v/PORT.web.1", appRoot)
|
||||||
|
|
||||||
@@ -192,8 +191,7 @@ func HasNetworkConfig(appName string) bool {
|
|||||||
|
|
||||||
// ClearNetworkConfig removes old IP and PORT files for a newly cloned app
|
// ClearNetworkConfig removes old IP and PORT files for a newly cloned app
|
||||||
func ClearNetworkConfig(appName string) bool {
|
func ClearNetworkConfig(appName string) bool {
|
||||||
dokkuRoot := common.MustGetEnv("DOKKU_ROOT")
|
appRoot := common.AppRoot(appName)
|
||||||
appRoot := strings.Join([]string{dokkuRoot, appName}, "/")
|
|
||||||
success := true
|
success := true
|
||||||
|
|
||||||
ipFiles, _ := filepath.Glob(appRoot + "/IP.*")
|
ipFiles, _ := filepath.Glob(appRoot + "/IP.*")
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ func TriggerNetworkWriteIpaddr(appName string, processType string, containerInde
|
|||||||
common.LogFail(err.Error())
|
common.LogFail(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
|
appRoot := common.AppRoot(appName)
|
||||||
filename := fmt.Sprintf("%v/IP.%v.%v", appRoot, processType, containerIndex)
|
filename := fmt.Sprintf("%v/IP.%v.%v", appRoot, processType, containerIndex)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -137,7 +137,7 @@ func TriggerNetworkWritePort(appName string, processType string, containerIndex
|
|||||||
common.LogFail(err.Error())
|
common.LogFail(err.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
|
appRoot := common.AppRoot(appName)
|
||||||
filename := fmt.Sprintf("%v/PORT.%v.%v", appRoot, processType, containerIndex)
|
filename := fmt.Sprintf("%v/PORT.%v.%v", appRoot, processType, containerIndex)
|
||||||
f, err := os.Create(filename)
|
f, err := os.Create(filename)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ package repo
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"strings"
|
|
||||||
|
|
||||||
"github.com/dokku/dokku/plugins/common"
|
"github.com/dokku/dokku/plugins/common"
|
||||||
)
|
)
|
||||||
@@ -17,7 +16,7 @@ func CommandGc(appName string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
appRoot := strings.Join([]string{common.MustGetEnv("DOKKU_ROOT"), appName}, "/")
|
appRoot := common.AppRoot(appName)
|
||||||
cmdEnv := map[string]string{
|
cmdEnv := map[string]string{
|
||||||
"GIT_DIR": appRoot,
|
"GIT_DIR": appRoot,
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user