refactor: move app listing back to common
Without this, we'd need to duplicate some logic or make it more complex via a plugin trigger.
This commit is contained in:
@@ -1,13 +1,5 @@
|
||||
package apps
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
var (
|
||||
// DefaultProperties is a map of all valid network properties with corresponding default property values
|
||||
DefaultProperties = map[string]string{
|
||||
@@ -21,30 +13,3 @@ var (
|
||||
"deploy-source-metadata": true,
|
||||
}
|
||||
)
|
||||
|
||||
// DokkuApps returns a list of all local apps
|
||||
func DokkuApps() ([]string, error) {
|
||||
apps := []string{}
|
||||
dokkuRoot := common.MustGetEnv("DOKKU_ROOT")
|
||||
files, err := ioutil.ReadDir(dokkuRoot)
|
||||
if err != nil {
|
||||
return apps, fmt.Errorf("You haven't deployed any applications yet")
|
||||
}
|
||||
|
||||
for _, f := range files {
|
||||
appRoot := common.AppRoot(f.Name())
|
||||
if !common.DirectoryExists(appRoot) {
|
||||
continue
|
||||
}
|
||||
if strings.HasPrefix(f.Name(), ".") {
|
||||
continue
|
||||
}
|
||||
apps = append(apps, f.Name())
|
||||
}
|
||||
|
||||
if len(apps) == 0 {
|
||||
return apps, fmt.Errorf("You haven't deployed any applications yet")
|
||||
}
|
||||
|
||||
return filterApps(apps)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user