From 62a3eff5bba9c3e98af541c20e16b9afb919f82e Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Fri, 12 Nov 2021 15:54:08 -0500 Subject: [PATCH 1/7] refactor: move apps listing from common plugin to apps plugin This helps centralize app-related listing fetching. --- plugins/app-json/go.mod | 3 ++ plugins/app-json/subcommands.go | 3 +- plugins/apps/Makefile | 2 +- plugins/apps/apps.go | 35 +++++++++++++++++++ plugins/apps/src/triggers/triggers.go | 2 ++ plugins/apps/subcommands.go | 4 +-- plugins/apps/triggers.go | 10 ++++++ plugins/builder-dockerfile/internal-functions | 3 +- plugins/builder-pack/internal-functions | 3 +- plugins/builder/go.mod | 3 ++ plugins/builder/subcommands.go | 3 +- plugins/buildpacks/go.mod | 3 ++ plugins/buildpacks/subcommands.go | 3 +- plugins/certs/internal-functions | 3 +- plugins/checks/install | 10 ++---- plugins/checks/internal-functions | 3 +- plugins/common/functions | 7 ++-- plugins/cron/functions.go | 3 +- plugins/cron/go.mod | 3 ++ plugins/cron/subcommands.go | 3 +- plugins/docker-options/internal-functions | 3 +- plugins/domains/internal-functions | 3 +- plugins/git/install | 3 +- plugins/git/internal-functions | 3 +- plugins/logs/functions.go | 3 +- plugins/logs/go.mod | 5 ++- plugins/logs/subcommands.go | 3 +- plugins/network/go.mod | 3 ++ plugins/network/subcommands.go | 5 +-- plugins/network/triggers.go | 3 +- plugins/nginx-vhosts/command-functions | 3 +- plugins/proxy/go.mod | 3 ++ plugins/proxy/subcommands.go | 3 +- plugins/ps/go.mod | 3 ++ plugins/ps/subcommands.go | 6 ++-- plugins/ps/triggers.go | 3 +- plugins/registry/go.mod | 3 ++ plugins/registry/subcommands.go | 3 +- plugins/resource/go.mod | 3 ++ plugins/resource/subcommands.go | 3 +- .../scheduler-docker-local/internal-functions | 3 +- plugins/scheduler/go.mod | 3 ++ plugins/scheduler/subcommands.go | 3 +- plugins/scheduler/triggers.go | 3 +- plugins/storage/internal-functions | 3 +- 45 files changed, 136 insertions(+), 55 deletions(-) diff --git a/plugins/app-json/go.mod b/plugins/app-json/go.mod index 5de818c54..772c0a15c 100644 --- a/plugins/app-json/go.mod +++ b/plugins/app-json/go.mod @@ -3,10 +3,13 @@ module github.com/dokku/dokku/plugins/app-json go 1.16 require ( + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/spf13/pflag v1.0.5 golang.org/x/sync v0.0.0-20201207232520-09787c993a3a ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/app-json/subcommands.go b/plugins/app-json/subcommands.go index b2f396281..30ef7c3d4 100644 --- a/plugins/app-json/subcommands.go +++ b/plugins/app-json/subcommands.go @@ -1,13 +1,14 @@ package appjson import ( + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) // CommandReport displays a network report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/apps/Makefile b/plugins/apps/Makefile index 8a92e94b9..b24c25864 100644 --- a/plugins/apps/Makefile +++ b/plugins/apps/Makefile @@ -1,5 +1,5 @@ SUBCOMMANDS = subcommands/clone subcommands/create subcommands/destroy subcommands/exists subcommands/list subcommands/lock subcommands/locked subcommands/rename subcommands/report subcommands/unlock -TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report +TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-list triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report BUILD = commands subcommands triggers PLUGIN_NAME = apps diff --git a/plugins/apps/apps.go b/plugins/apps/apps.go index 3369609ca..ae4bf246e 100644 --- a/plugins/apps/apps.go +++ b/plugins/apps/apps.go @@ -1,5 +1,13 @@ 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{ @@ -13,3 +21,30 @@ 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 apps, nil +} diff --git a/plugins/apps/src/triggers/triggers.go b/plugins/apps/src/triggers/triggers.go index 9a0ce9d5c..9679ab9e4 100644 --- a/plugins/apps/src/triggers/triggers.go +++ b/plugins/apps/src/triggers/triggers.go @@ -27,6 +27,8 @@ func main() { case "app-exists": appName := flag.Arg(0) err = apps.TriggerAppExists(appName) + case "app-list": + err = apps.TriggerAppList() case "app-maybe-create": appName := flag.Arg(0) err = apps.TriggerAppMaybeCreate(appName) diff --git a/plugins/apps/subcommands.go b/plugins/apps/subcommands.go index bac59eb94..2911808de 100644 --- a/plugins/apps/subcommands.go +++ b/plugins/apps/subcommands.go @@ -85,7 +85,7 @@ func CommandExists(appName string) error { // CommandList lists all apps func CommandList() error { common.LogInfo2Quiet("My Apps") - apps, err := common.DokkuApps() + apps, err := DokkuApps() if err != nil { common.LogWarn(err.Error()) return nil @@ -177,7 +177,7 @@ func CommandRename(oldAppName string, newAppName string, skipDeploy bool) error // CommandReport displays an app report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := DokkuApps() if err != nil { return err } diff --git a/plugins/apps/triggers.go b/plugins/apps/triggers.go index b70076c64..0a1017946 100644 --- a/plugins/apps/triggers.go +++ b/plugins/apps/triggers.go @@ -21,6 +21,16 @@ func TriggerAppExists(appName string) error { return appExists(appName) } +// TriggerAppList outputs each app name to stdout on a newline +func TriggerAppList() error { + apps, _ := DokkuApps() + for _, app := range apps { + common.Log(app) + } + + return nil +} + // TriggerAppMaybeCreate is a trigger to allow gated app creation func TriggerAppMaybeCreate(appName string) error { return maybeCreateApp(appName) diff --git a/plugins/builder-dockerfile/internal-functions b/plugins/builder-dockerfile/internal-functions index 88503617b..219d7d3e9 100755 --- a/plugins/builder-dockerfile/internal-functions +++ b/plugins/builder-dockerfile/internal-functions @@ -9,7 +9,6 @@ cmd-builder-dockerfile-report() { declare cmd="builder-dockerfile:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -21,7 +20,7 @@ cmd-builder-dockerfile-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-builder-dockerfile-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/builder-pack/internal-functions b/plugins/builder-pack/internal-functions index 72c4b73f4..41d36353a 100755 --- a/plugins/builder-pack/internal-functions +++ b/plugins/builder-pack/internal-functions @@ -9,7 +9,6 @@ cmd-builder-pack-report() { declare cmd="builder-pack:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -21,7 +20,7 @@ cmd-builder-pack-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-builder-pack-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/builder/go.mod b/plugins/builder/go.mod index 93f3068ee..6153d3391 100644 --- a/plugins/builder/go.mod +++ b/plugins/builder/go.mod @@ -3,9 +3,12 @@ module github.com/dokku/dokku/plugins/builder go 1.16 require ( + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/otiai10/copy v1.6.0 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/builder/subcommands.go b/plugins/builder/subcommands.go index 9278f8493..513c8ebc5 100644 --- a/plugins/builder/subcommands.go +++ b/plugins/builder/subcommands.go @@ -1,13 +1,14 @@ package builder import ( + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) // CommandReport displays a builder report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/buildpacks/go.mod b/plugins/buildpacks/go.mod index cd66e8765..1be08af06 100644 --- a/plugins/buildpacks/go.mod +++ b/plugins/buildpacks/go.mod @@ -3,8 +3,11 @@ module github.com/dokku/dokku/plugins/buildpacks go 1.16 require ( + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/buildpacks/subcommands.go b/plugins/buildpacks/subcommands.go index 9a49ffabc..61ae6c704 100644 --- a/plugins/buildpacks/subcommands.go +++ b/plugins/buildpacks/subcommands.go @@ -4,6 +4,7 @@ import ( "errors" "fmt" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -106,7 +107,7 @@ func CommandRemove(appName string, buildpack string, index int) (err error) { // CommandReport displays a buildpacks report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/certs/internal-functions b/plugins/certs/internal-functions index 4a05d2a1b..923f3faa3 100755 --- a/plugins/certs/internal-functions +++ b/plugins/certs/internal-functions @@ -9,7 +9,6 @@ cmd-certs-report() { declare cmd="certs:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -21,7 +20,7 @@ cmd-certs-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-certs-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/checks/install b/plugins/checks/install index dcd789d3d..1497ca5d4 100755 --- a/plugins/checks/install +++ b/plugins/checks/install @@ -6,13 +6,10 @@ source "$PLUGIN_AVAILABLE_PATH/config/functions" migrate_checks_vars_0_5_0() { declare desc="migrates deprecated CHECKS config variables to simplified counter part introduced in 0.5.x" - local APPS="$(dokku_apps)" local GLOBAL_SKIP_ALL_CHECKS=$(config_get --global DOKKU_SKIP_ALL_CHECKS || true) local GLOBAL_SKIP_DEFAULT_CHECKS=$(config_get --global DOKKU_SKIP_DEFAULT_CHECKS || true) - local app - - for app in $APPS; do + for app in $(dokku_apps); do local APP_SKIP_ALL_CHECKS=$(config_get "$app" DOKKU_SKIP_ALL_CHECKS || true) local APP_SKIP_DEFAULT_CHECKS=$(config_get "$app" DOKKU_SKIP_DEFAULT_CHECKS || true) @@ -37,11 +34,8 @@ migrate_checks_vars_0_5_0() { migrate_checks_vars_0_6_0() { declare desc="migrates CHECKS config variables from 0.5.x to support fully-disabled zero-downtime checks" - local APPS="$(dokku_apps)" - local app - - for app in $APPS; do + for app in $(dokku_apps); do local APP_DOKKU_CHECKS_ENABLED=$(config_get "$app" DOKKU_CHECKS_ENABLED || true) if [[ $APP_DOKKU_CHECKS_ENABLED ]]; then dokku_log_info1 "Migrating zero downtime env variables to 0.6.x. The following variables will be migrated" diff --git a/plugins/checks/internal-functions b/plugins/checks/internal-functions index bf78f4c96..fe125bf08 100755 --- a/plugins/checks/internal-functions +++ b/plugins/checks/internal-functions @@ -9,7 +9,6 @@ cmd-checks-report() { declare cmd="checks:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -21,7 +20,7 @@ cmd-checks-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-checks-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/common/functions b/plugins/common/functions index b2bb8dd44..ce1460496 100755 --- a/plugins/common/functions +++ b/plugins/common/functions @@ -17,8 +17,11 @@ has_tty() { dokku_apps() { declare desc="prints list of all local apps" - local INSTALLED_APPS=$(find "$DOKKU_ROOT" -follow -maxdepth 1 -mindepth 1 -type d ! -name '.*' -printf "%f\n" 2>/dev/null | sort) || (dokku_log_fail "You haven't deployed any applications yet") - [[ $INSTALLED_APPS ]] && echo "$INSTALLED_APPS" + local INSTALLED_APPS="$(plugn trigger app-list)" + if [[ -z "$INSTALLED_APPS" ]]; then + dokku_log_fail "You haven't deployed any applications yet" + fi + echo "$INSTALLED_APPS" } dokku_version() { diff --git a/plugins/cron/functions.go b/plugins/cron/functions.go index ebdd7fb61..18cb1b1da 100644 --- a/plugins/cron/functions.go +++ b/plugins/cron/functions.go @@ -11,6 +11,7 @@ import ( "text/template" appjson "github.com/dokku/dokku/plugins/app-json" + apps "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" cronparser "github.com/robfig/cron/v3" @@ -99,7 +100,7 @@ func deleteCrontab() error { } func writeCronEntries() error { - apps, _ := common.DokkuApps() + apps, _ := apps.DokkuApps() commands := []templateCommand{} for _, appName := range apps { scheduler := common.GetAppScheduler(appName) diff --git a/plugins/cron/go.mod b/plugins/cron/go.mod index 3918dd95c..75b251103 100644 --- a/plugins/cron/go.mod +++ b/plugins/cron/go.mod @@ -4,12 +4,15 @@ go 1.16 require ( github.com/dokku/dokku/plugins/app-json v0.0.0-00010101000000-000000000000 + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/robfig/cron/v3 v3.0.1 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/app-json => ../app-json replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/cron/subcommands.go b/plugins/cron/subcommands.go index 88bca6231..6038e1564 100644 --- a/plugins/cron/subcommands.go +++ b/plugins/cron/subcommands.go @@ -3,6 +3,7 @@ package cron import ( "fmt" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/ryanuber/columnize" ) @@ -31,7 +32,7 @@ func CommandList(appName string) error { // CommandReport displays a cron report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/docker-options/internal-functions b/plugins/docker-options/internal-functions index 5bcddeee0..5634f4f28 100755 --- a/plugins/docker-options/internal-functions +++ b/plugins/docker-options/internal-functions @@ -9,7 +9,6 @@ cmd-docker-options-report() { declare cmd="docker-options:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -21,7 +20,7 @@ cmd-docker-options-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-docker-options-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/domains/internal-functions b/plugins/domains/internal-functions index 0fb6f07b2..adb6225c0 100755 --- a/plugins/domains/internal-functions +++ b/plugins/domains/internal-functions @@ -9,7 +9,6 @@ cmd-domains-report() { declare cmd="domains:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ "$APP" == "--global" ]]; then cmd-domains-report-single "$APP" "$INFO_FLAG" @@ -26,7 +25,7 @@ cmd-domains-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-domains-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/git/install b/plugins/git/install index 8e6cdbc1c..738e2f99b 100755 --- a/plugins/git/install +++ b/plugins/git/install @@ -18,7 +18,6 @@ trigger-git-install() { migrate_git_vars_0_12_0() { declare desc="migrates git config variables from 0.11.x" - local APPS="$(dokku_apps)" local DOKKU_DEPLOY_BRANCH app DOKKU_DEPLOY_BRANCH=$(config_get --global DOKKU_DEPLOY_BRANCH || true) @@ -27,7 +26,7 @@ migrate_git_vars_0_12_0() { DOKKU_QUIET_OUTPUT=1 config_unset --global DOKKU_DEPLOY_BRANCH || true fi - for app in $APPS; do + for app in $(dokku_apps); do DOKKU_DEPLOY_BRANCH=$(config_get "$app" DOKKU_DEPLOY_BRANCH || true) if [[ -n "$DOKKU_DEPLOY_BRANCH" ]]; then fn-plugin-property-write "git" "$app" "deploy-branch" "$DOKKU_DEPLOY_BRANCH" diff --git a/plugins/git/internal-functions b/plugins/git/internal-functions index 6d35ea2b1..68eeb098e 100755 --- a/plugins/git/internal-functions +++ b/plugins/git/internal-functions @@ -222,7 +222,6 @@ cmd-git-report() { declare cmd="git:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -234,7 +233,7 @@ cmd-git-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-git-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/logs/functions.go b/plugins/logs/functions.go index 50aa6a2ca..91d6eea99 100644 --- a/plugins/logs/functions.go +++ b/plugins/logs/functions.go @@ -10,6 +10,7 @@ import ( "strings" "time" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/joncalhoun/qson" ) @@ -156,7 +157,7 @@ func sinkValueToConfig(appName string, sinkValue string) (vectorSink, error) { } func writeVectorConfig() error { - apps, _ := common.DokkuApps() + apps, _ := apps.DokkuApps() data := vectorConfig{ Sources: map[string]vectorSource{}, Sinks: map[string]vectorSink{}, diff --git a/plugins/logs/go.mod b/plugins/logs/go.mod index 91e9cab4a..c13c79bcc 100644 --- a/plugins/logs/go.mod +++ b/plugins/logs/go.mod @@ -4,12 +4,15 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 - github.com/dokku/dokku/plugins/docker-options v0.0.0-20210208020425-f7beb3d95ddd + github.com/dokku/dokku/plugins/docker-options v0.0.0-00010101000000-000000000000 github.com/joncalhoun/qson v0.0.0-20200422171543-84433dcd3da0 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/docker-options => ../docker-options diff --git a/plugins/logs/subcommands.go b/plugins/logs/subcommands.go index 365a67892..277213fe7 100644 --- a/plugins/logs/subcommands.go +++ b/plugins/logs/subcommands.go @@ -7,6 +7,7 @@ import ( "strconv" "time" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -52,7 +53,7 @@ func CommandFailed(appName string, allApps bool) error { // CommandReport displays a logs report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/network/go.mod b/plugins/network/go.mod index a34058e0d..55767a26a 100644 --- a/plugins/network/go.mod +++ b/plugins/network/go.mod @@ -4,11 +4,14 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config diff --git a/plugins/network/subcommands.go b/plugins/network/subcommands.go index bf04f5784..f052281e8 100644 --- a/plugins/network/subcommands.go +++ b/plugins/network/subcommands.go @@ -7,6 +7,7 @@ import ( "os" "strings" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -107,7 +108,7 @@ func CommandList() error { // CommandRebuildall rebuilds network settings for all apps func CommandRebuildall() error { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } @@ -125,7 +126,7 @@ func CommandRebuildall() error { // CommandReport displays a network report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/network/triggers.go b/plugins/network/triggers.go index 2906c1428..71840ea9e 100644 --- a/plugins/network/triggers.go +++ b/plugins/network/triggers.go @@ -7,6 +7,7 @@ import ( "strings" "unicode/utf8" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" ) @@ -33,7 +34,7 @@ func TriggerInstall() error { return fmt.Errorf("Unable to install the network plugin: %s", err.Error()) } - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return nil } diff --git a/plugins/nginx-vhosts/command-functions b/plugins/nginx-vhosts/command-functions index 1d5872b41..71f0a9d61 100755 --- a/plugins/nginx-vhosts/command-functions +++ b/plugins/nginx-vhosts/command-functions @@ -11,7 +11,6 @@ cmd-nginx-report() { declare cmd="nginx:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -23,7 +22,7 @@ cmd-nginx-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-nginx-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/proxy/go.mod b/plugins/proxy/go.mod index a88c3cdc2..c4c1b4c52 100644 --- a/plugins/proxy/go.mod +++ b/plugins/proxy/go.mod @@ -3,12 +3,15 @@ module github.com/dokku/dokku/plugins/proxy go 1.16 require ( + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config diff --git a/plugins/proxy/subcommands.go b/plugins/proxy/subcommands.go index 1dcb66558..836c9cf53 100644 --- a/plugins/proxy/subcommands.go +++ b/plugins/proxy/subcommands.go @@ -4,6 +4,7 @@ import ( "errors" "strings" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" ) @@ -152,7 +153,7 @@ func CommandPortsSet(appName string, portMaps []string) error { // CommandReport displays a proxy report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/ps/go.mod b/plugins/ps/go.mod index cdb884ecd..82199a831 100644 --- a/plugins/ps/go.mod +++ b/plugins/ps/go.mod @@ -4,6 +4,7 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/docker-options v0.0.0-00010101000000-000000000000 @@ -13,6 +14,8 @@ require ( github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config diff --git a/plugins/ps/subcommands.go b/plugins/ps/subcommands.go index ed4ecaba0..16c2f5ff6 100644 --- a/plugins/ps/subcommands.go +++ b/plugins/ps/subcommands.go @@ -6,9 +6,9 @@ import ( "path/filepath" "strings" - dockeroptions "github.com/dokku/dokku/plugins/docker-options" - + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" + dockeroptions "github.com/dokku/dokku/plugins/docker-options" "github.com/gofrs/flock" ) @@ -38,7 +38,7 @@ func CommandRebuild(appName string, allApps bool, parallelCount int) error { // CommandReport displays a ps report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index 88c590ef0..fbd87868b 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -10,6 +10,7 @@ import ( "strings" sh "github.com/codeskyblue/go-sh" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" dockeroptions "github.com/dokku/dokku/plugins/docker-options" @@ -74,7 +75,7 @@ func TriggerInstall() error { return err } - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return nil } diff --git a/plugins/registry/go.mod b/plugins/registry/go.mod index d935e5bb9..732383d7b 100644 --- a/plugins/registry/go.mod +++ b/plugins/registry/go.mod @@ -4,8 +4,11 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/registry/subcommands.go b/plugins/registry/subcommands.go index beabc002a..ba27a1e0a 100644 --- a/plugins/registry/subcommands.go +++ b/plugins/registry/subcommands.go @@ -7,6 +7,7 @@ import ( "os" "strings" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -55,7 +56,7 @@ func CommandLogin(server string, username string, password string, passwordStdin // CommandReport displays a registry report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/resource/go.mod b/plugins/resource/go.mod index a5792de11..cd4df919a 100644 --- a/plugins/resource/go.mod +++ b/plugins/resource/go.mod @@ -3,8 +3,11 @@ module github.com/dokku/dokku/plugins/resource go 1.16 require ( + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/resource/subcommands.go b/plugins/resource/subcommands.go index f13217389..43402b572 100644 --- a/plugins/resource/subcommands.go +++ b/plugins/resource/subcommands.go @@ -1,6 +1,7 @@ package resource import ( + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -26,7 +27,7 @@ func CommandLimitClear(appName string, processType string) error { // CommandReport displays a resource report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/scheduler-docker-local/internal-functions b/plugins/scheduler-docker-local/internal-functions index 256532c12..8568bd764 100755 --- a/plugins/scheduler-docker-local/internal-functions +++ b/plugins/scheduler-docker-local/internal-functions @@ -10,7 +10,6 @@ cmd-scheduler-docker-local-report() { declare cmd="scheduler-docker-local:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -22,7 +21,7 @@ cmd-scheduler-docker-local-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-scheduler-docker-local-report-single "$app" "$INFO_FLAG" | tee || true done else diff --git a/plugins/scheduler/go.mod b/plugins/scheduler/go.mod index 54dc95487..73ca20ce0 100644 --- a/plugins/scheduler/go.mod +++ b/plugins/scheduler/go.mod @@ -3,11 +3,14 @@ module github.com/dokku/dokku/plugins/scheduler go 1.16 require ( + github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) +replace github.com/dokku/dokku/plugins/apps => ../apps + replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config diff --git a/plugins/scheduler/subcommands.go b/plugins/scheduler/subcommands.go index 98ed46e44..4cded4dcb 100644 --- a/plugins/scheduler/subcommands.go +++ b/plugins/scheduler/subcommands.go @@ -1,13 +1,14 @@ package scheduler import ( + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) // CommandReport displays a scheduler report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/scheduler/triggers.go b/plugins/scheduler/triggers.go index d5ae16b1d..f3ed30531 100644 --- a/plugins/scheduler/triggers.go +++ b/plugins/scheduler/triggers.go @@ -3,6 +3,7 @@ package scheduler import ( "fmt" + "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" ) @@ -31,7 +32,7 @@ func TriggerInstall() error { return fmt.Errorf("Unable to install the scheduler plugin: %s", err.Error()) } - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return nil } diff --git a/plugins/storage/internal-functions b/plugins/storage/internal-functions index 70be5e16f..7dedc62b5 100755 --- a/plugins/storage/internal-functions +++ b/plugins/storage/internal-functions @@ -66,7 +66,6 @@ cmd-storage-report() { declare cmd="storage:report" [[ "$1" == "$cmd" ]] && shift 1 declare APP="$1" INFO_FLAG="$2" - local INSTALLED_APPS=$(dokku_apps) if [[ -n "$APP" ]] && [[ "$APP" == --* ]]; then INFO_FLAG="$APP" @@ -78,7 +77,7 @@ cmd-storage-report() { fi if [[ -z "$APP" ]]; then - for app in $INSTALLED_APPS; do + for app in $(dokku_apps); do cmd-storage-report-single "$app" "$INFO_FLAG" | tee || true done else From 1a052969dcba3e65c1700c206c4d606df59156ec Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 27 Nov 2021 14:20:47 -0500 Subject: [PATCH 2/7] feat: app filtering to commands listing or iterating over apps This increases the time to list apps from .05s to .2s~.3s on the simplest check, but the increased time is worth it for actually verifyng access to an app (should that need arise). We'll also want to add the same to app existence checks. --- docs/development/plugin-triggers.md | 41 +++++++++++++++++++++++++++++ plugins/20_events/user-auth-app | 1 + plugins/apps/apps.go | 2 +- plugins/apps/functions.go | 37 ++++++++++++++++++++++++++ plugins/common/subprocess.go | 17 ++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) create mode 120000 plugins/20_events/user-auth-app diff --git a/docs/development/plugin-triggers.md b/docs/development/plugin-triggers.md index c89069338..9014822f7 100644 --- a/docs/development/plugin-triggers.md +++ b/docs/development/plugin-triggers.md @@ -2367,3 +2367,44 @@ shift 2 [[ "$SSH_NAME" == "default" && $1 == plugin:* ]] && exit 1 exit 0 ``` + +### `user-auth-app` + +This is a special plugin trigger that is executed when listing apps or checking if an app exists. All Dokku commands should check if an app exists at least once before interacting with them so as not to circumvent the check. + +Note that the trigger should exit `0`, and each non-empty line on stdout is captured as a valid app name. + +The `SSH_USER` is the original ssh user. If you are running remote commands, this user will typically be `dokku`, and as such should not be trusted when checking permissions. If you are connected via ssh as a different user who then invokes `dokku`, the value of this variable will be that user's name (`root`, `myuser`, etc.). + +The `SSH_NAME` is the `NAME` variable set via the `sshcommand acl-add` command. For reference, the following command can be run as the root user to specify a specific `NAME` for a given ssh key: + +```shell +sshcommand acl-add dokku NAME < $PATH_TO_SSH_KEY +``` + +Note that the `NAME` value is set at the first ssh key match. If an ssh key is set in the `/home/dokku/.ssh/authorized_keys` multiple times, the first match will decide the value. + +- Description: Allows you to deny access to a Dokku app by either ssh user or associated ssh-command NAME user. +- Invoked by: `dokku` +- Arguments: `$SSH_USER $SSH_NAME $DOKKU_COMMAND` +- Example: + +```shell +#!/usr/bin/env bash +# hide any apps with the prefix "admin" +# if the logged in user (SSH_USER) or SSH_NAME is not `root` + +main() { + declare SSH_USER="$1" SSH_NAME="$2" ARGS=("${@:3}") + + for arg in "${ARGS[@]}"; do + if [[ "$arg" == admin-* ]] && [[ "$SSH_USER" != "root" ]] && [[ "$SSH_NAME" != "root" ]]; then + continue + fi + + echo "${arg}" + done +} + +main "$@" +``` diff --git a/plugins/20_events/user-auth-app b/plugins/20_events/user-auth-app new file mode 120000 index 000000000..5178a749f --- /dev/null +++ b/plugins/20_events/user-auth-app @@ -0,0 +1 @@ +hook \ No newline at end of file diff --git a/plugins/apps/apps.go b/plugins/apps/apps.go index ae4bf246e..d125c3a6e 100644 --- a/plugins/apps/apps.go +++ b/plugins/apps/apps.go @@ -46,5 +46,5 @@ func DokkuApps() ([]string, error) { return apps, fmt.Errorf("You haven't deployed any applications yet") } - return apps, nil + return filterApps(apps) } diff --git a/plugins/apps/functions.go b/plugins/apps/functions.go index d19b8b370..7d1221a30 100644 --- a/plugins/apps/functions.go +++ b/plugins/apps/functions.go @@ -154,3 +154,40 @@ func maybeCreateApp(appName string) error { return createApp(appName) }) } + +func filterApps(apps []string) ([]string, error) { + if !common.PlugnTriggerExists("user-auth-app") { + return apps, nil + } + + sshUser := os.Getenv("SSH_USER") + if sshUser == "" { + sshUser = os.Getenv("USER") + } + + sshName := os.Getenv("SSH_NAME") + if sshName == "" { + sshName = "default" + } + + args := append([]string{sshUser, sshName}, apps...) + b, _ := common.PlugnTriggerOutput("user-auth-app", args...) + filteredApps := strings.Split(strings.TrimSpace(string(b[:])), "\n") + filteredApps = removeEmptyEntries(filteredApps) + + if len(filteredApps) == 0 { + return filteredApps, fmt.Errorf("You haven't deployed any applications yet") + } + + return filteredApps, nil +} + +func removeEmptyEntries(s []string) []string { + var r []string + for _, str := range s { + if str != "" { + r = append(r, str) + } + } + return r +} diff --git a/plugins/common/subprocess.go b/plugins/common/subprocess.go index 2f970474d..f90f7fc41 100644 --- a/plugins/common/subprocess.go +++ b/plugins/common/subprocess.go @@ -5,6 +5,7 @@ import ( "io/ioutil" "os" "os/exec" + "path/filepath" "strings" "github.com/codeskyblue/go-sh" @@ -128,3 +129,19 @@ func PlugnTriggerSetup(triggerName string, args ...string) *sh.Session { } return sh.Command("plugn", shellArgs...) } + +// PlugnTriggerExists returns whether a plugin trigger exists (ignoring the existence of any within the 20_events plugin) +func PlugnTriggerExists(triggerName string) bool { + pluginPath := MustGetEnv("PLUGIN_ENABLED_PATH") + glob := filepath.Join(pluginPath, "*", triggerName) + exists := false + files, _ := filepath.Glob(glob) + for _, file := range files { + plugin := strings.Trim(strings.TrimPrefix(strings.TrimSuffix(file, "/user-auth-app"), pluginPath), "/") + if plugin != "20_events" { + exists = true + break + } + } + return exists +} From 5eced46f226d35931ac74be3d8b44ec34304c67a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 25 Dec 2021 21:42:42 -0500 Subject: [PATCH 3/7] fix: allow check to work for any trigger --- plugins/common/subprocess.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/common/subprocess.go b/plugins/common/subprocess.go index f90f7fc41..d46b2b2d9 100644 --- a/plugins/common/subprocess.go +++ b/plugins/common/subprocess.go @@ -137,7 +137,7 @@ func PlugnTriggerExists(triggerName string) bool { exists := false files, _ := filepath.Glob(glob) for _, file := range files { - plugin := strings.Trim(strings.TrimPrefix(strings.TrimSuffix(file, "/user-auth-app"), pluginPath), "/") + plugin := strings.Trim(strings.TrimPrefix(strings.TrimSuffix(file, "/"+triggerName), pluginPath), "/") if plugin != "20_events" { exists = true break From 90eb5462f7eb71eea41fb0a8a030876b32a820e6 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 26 Feb 2022 02:41:21 -0500 Subject: [PATCH 4/7] chore: update two more calls to fetch all apps --- plugins/buildpacks/subcommands.go | 2 +- plugins/domains/install | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/plugins/buildpacks/subcommands.go b/plugins/buildpacks/subcommands.go index 61ae6c704..525e790ef 100644 --- a/plugins/buildpacks/subcommands.go +++ b/plugins/buildpacks/subcommands.go @@ -153,7 +153,7 @@ func CommandSetProperty(appName string, property string, value string) error { return common.PlugnTrigger("post-stack-set", []string{appName, value}...) } - apps, err := common.DokkuApps() + apps, err := apps.DokkuApps() if err != nil { return err } diff --git a/plugins/domains/install b/plugins/domains/install index 3a220e1a5..05e19a657 100755 --- a/plugins/domains/install +++ b/plugins/domains/install @@ -8,9 +8,8 @@ trigger-domains-install() { declare trigger="install" shopt -s nullglob - for app in $DOKKU_ROOT/*/CONTAINER; do - APP=$(basename "$(dirname "$app")") - domains_setup "$APP" + for app in $(dokku_apps); do + domains_setup "$app" done } From ac58b502c559515e20f08a90fdc0eb5d218dbe9a Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 26 Feb 2022 02:55:34 -0500 Subject: [PATCH 5/7] 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. --- plugins/app-json/subcommands.go | 3 +- plugins/apps/Makefile | 2 +- plugins/apps/apps.go | 35 -------------------- plugins/apps/functions.go | 37 --------------------- plugins/apps/src/triggers/triggers.go | 2 -- plugins/apps/subcommands.go | 4 +-- plugins/apps/triggers.go | 10 ------ plugins/builder/subcommands.go | 3 +- plugins/buildpacks/subcommands.go | 5 ++- plugins/common/Makefile | 2 +- plugins/common/common.go | 11 +++---- plugins/common/functions.go | 44 +++++++++++++++++++++++++ plugins/common/src/triggers/triggers.go | 2 ++ plugins/common/triggers.go | 10 ++++++ plugins/cron/functions.go | 3 +- plugins/cron/subcommands.go | 3 +- plugins/logs/functions.go | 3 +- plugins/logs/subcommands.go | 3 +- plugins/network/subcommands.go | 5 ++- plugins/network/triggers.go | 3 +- plugins/proxy/subcommands.go | 3 +- plugins/ps/subcommands.go | 3 +- plugins/ps/triggers.go | 3 +- plugins/registry/subcommands.go | 3 +- plugins/resource/subcommands.go | 3 +- plugins/scheduler/subcommands.go | 3 +- plugins/scheduler/triggers.go | 3 +- 27 files changed, 83 insertions(+), 128 deletions(-) create mode 100644 plugins/common/functions.go diff --git a/plugins/app-json/subcommands.go b/plugins/app-json/subcommands.go index 30ef7c3d4..b2f396281 100644 --- a/plugins/app-json/subcommands.go +++ b/plugins/app-json/subcommands.go @@ -1,14 +1,13 @@ package appjson import ( - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) // CommandReport displays a network report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/apps/Makefile b/plugins/apps/Makefile index b24c25864..8a92e94b9 100644 --- a/plugins/apps/Makefile +++ b/plugins/apps/Makefile @@ -1,5 +1,5 @@ SUBCOMMANDS = subcommands/clone subcommands/create subcommands/destroy subcommands/exists subcommands/list subcommands/lock subcommands/locked subcommands/rename subcommands/report subcommands/unlock -TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-list triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report +TRIGGERS = triggers/app-create triggers/app-destroy triggers/app-exists triggers/app-maybe-create triggers/deploy-source-set triggers/install triggers/post-app-clone-setup triggers/post-app-rename-setup triggers/post-delete triggers/report BUILD = commands subcommands triggers PLUGIN_NAME = apps diff --git a/plugins/apps/apps.go b/plugins/apps/apps.go index d125c3a6e..3369609ca 100644 --- a/plugins/apps/apps.go +++ b/plugins/apps/apps.go @@ -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) -} diff --git a/plugins/apps/functions.go b/plugins/apps/functions.go index 7d1221a30..d19b8b370 100644 --- a/plugins/apps/functions.go +++ b/plugins/apps/functions.go @@ -154,40 +154,3 @@ func maybeCreateApp(appName string) error { return createApp(appName) }) } - -func filterApps(apps []string) ([]string, error) { - if !common.PlugnTriggerExists("user-auth-app") { - return apps, nil - } - - sshUser := os.Getenv("SSH_USER") - if sshUser == "" { - sshUser = os.Getenv("USER") - } - - sshName := os.Getenv("SSH_NAME") - if sshName == "" { - sshName = "default" - } - - args := append([]string{sshUser, sshName}, apps...) - b, _ := common.PlugnTriggerOutput("user-auth-app", args...) - filteredApps := strings.Split(strings.TrimSpace(string(b[:])), "\n") - filteredApps = removeEmptyEntries(filteredApps) - - if len(filteredApps) == 0 { - return filteredApps, fmt.Errorf("You haven't deployed any applications yet") - } - - return filteredApps, nil -} - -func removeEmptyEntries(s []string) []string { - var r []string - for _, str := range s { - if str != "" { - r = append(r, str) - } - } - return r -} diff --git a/plugins/apps/src/triggers/triggers.go b/plugins/apps/src/triggers/triggers.go index 9679ab9e4..9a0ce9d5c 100644 --- a/plugins/apps/src/triggers/triggers.go +++ b/plugins/apps/src/triggers/triggers.go @@ -27,8 +27,6 @@ func main() { case "app-exists": appName := flag.Arg(0) err = apps.TriggerAppExists(appName) - case "app-list": - err = apps.TriggerAppList() case "app-maybe-create": appName := flag.Arg(0) err = apps.TriggerAppMaybeCreate(appName) diff --git a/plugins/apps/subcommands.go b/plugins/apps/subcommands.go index 2911808de..bac59eb94 100644 --- a/plugins/apps/subcommands.go +++ b/plugins/apps/subcommands.go @@ -85,7 +85,7 @@ func CommandExists(appName string) error { // CommandList lists all apps func CommandList() error { common.LogInfo2Quiet("My Apps") - apps, err := DokkuApps() + apps, err := common.DokkuApps() if err != nil { common.LogWarn(err.Error()) return nil @@ -177,7 +177,7 @@ func CommandRename(oldAppName string, newAppName string, skipDeploy bool) error // CommandReport displays an app report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/apps/triggers.go b/plugins/apps/triggers.go index 0a1017946..b70076c64 100644 --- a/plugins/apps/triggers.go +++ b/plugins/apps/triggers.go @@ -21,16 +21,6 @@ func TriggerAppExists(appName string) error { return appExists(appName) } -// TriggerAppList outputs each app name to stdout on a newline -func TriggerAppList() error { - apps, _ := DokkuApps() - for _, app := range apps { - common.Log(app) - } - - return nil -} - // TriggerAppMaybeCreate is a trigger to allow gated app creation func TriggerAppMaybeCreate(appName string) error { return maybeCreateApp(appName) diff --git a/plugins/builder/subcommands.go b/plugins/builder/subcommands.go index 513c8ebc5..9278f8493 100644 --- a/plugins/builder/subcommands.go +++ b/plugins/builder/subcommands.go @@ -1,14 +1,13 @@ package builder import ( - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) // CommandReport displays a builder report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/buildpacks/subcommands.go b/plugins/buildpacks/subcommands.go index 525e790ef..9a49ffabc 100644 --- a/plugins/buildpacks/subcommands.go +++ b/plugins/buildpacks/subcommands.go @@ -4,7 +4,6 @@ import ( "errors" "fmt" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -107,7 +106,7 @@ func CommandRemove(appName string, buildpack string, index int) (err error) { // CommandReport displays a buildpacks report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } @@ -153,7 +152,7 @@ func CommandSetProperty(appName string, property string, value string) error { return common.PlugnTrigger("post-stack-set", []string{appName, value}...) } - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/common/Makefile b/plugins/common/Makefile index e3823d2da..c0852a223 100644 --- a/plugins/common/Makefile +++ b/plugins/common/Makefile @@ -1,4 +1,4 @@ -TRIGGERS = triggers/core-post-deploy triggers/install triggers/post-delete +TRIGGERS = triggers/app-list triggers/core-post-deploy triggers/install triggers/post-delete BUILD = prop common triggers PLUGIN_NAME = common diff --git a/plugins/common/common.go b/plugins/common/common.go index bd6516ae5..c4c0cf506 100644 --- a/plugins/common/common.go +++ b/plugins/common/common.go @@ -244,12 +244,12 @@ func GetRunningImageTag(appName string, imageTag string) (string, error) { } // DokkuApps returns a list of all local apps -func DokkuApps() (apps []string, err error) { +func DokkuApps() ([]string, error) { + apps := []string{} dokkuRoot := MustGetEnv("DOKKU_ROOT") files, err := ioutil.ReadDir(dokkuRoot) if err != nil { - err = fmt.Errorf("You haven't deployed any applications yet") - return + return apps, fmt.Errorf("You haven't deployed any applications yet") } for _, f := range files { @@ -264,11 +264,10 @@ func DokkuApps() (apps []string, err error) { } if len(apps) == 0 { - err = fmt.Errorf("You haven't deployed any applications yet") - return + return apps, fmt.Errorf("You haven't deployed any applications yet") } - return + return filterApps(apps) } // GetAppImageName returns image identifier for a given app, tag tuple. validate if tag is presented diff --git a/plugins/common/functions.go b/plugins/common/functions.go new file mode 100644 index 000000000..ea475737b --- /dev/null +++ b/plugins/common/functions.go @@ -0,0 +1,44 @@ +package common + +import ( + "fmt" + "os" + "strings" +) + +func filterApps(apps []string) ([]string, error) { + if !PlugnTriggerExists("user-auth-app") { + return apps, nil + } + + sshUser := os.Getenv("SSH_USER") + if sshUser == "" { + sshUser = os.Getenv("USER") + } + + sshName := os.Getenv("SSH_NAME") + if sshName == "" { + sshName = "default" + } + + args := append([]string{sshUser, sshName}, apps...) + b, _ := PlugnTriggerOutput("user-auth-app", args...) + filteredApps := strings.Split(strings.TrimSpace(string(b[:])), "\n") + filteredApps = removeEmptyEntries(filteredApps) + + if len(filteredApps) == 0 { + return filteredApps, fmt.Errorf("You haven't deployed any applications yet") + } + + return filteredApps, nil +} + +func removeEmptyEntries(s []string) []string { + var r []string + for _, str := range s { + if str != "" { + r = append(r, str) + } + } + return r +} diff --git a/plugins/common/src/triggers/triggers.go b/plugins/common/src/triggers/triggers.go index cefabbe28..8ba0d3866 100644 --- a/plugins/common/src/triggers/triggers.go +++ b/plugins/common/src/triggers/triggers.go @@ -17,6 +17,8 @@ func main() { var err error switch trigger { + case "app-list": + err = common.TriggerAppList() case "core-post-deploy": appName := flag.Arg(0) err = common.TriggerCorePostDeploy(appName) diff --git a/plugins/common/triggers.go b/plugins/common/triggers.go index b20c655b3..9bb6ef840 100644 --- a/plugins/common/triggers.go +++ b/plugins/common/triggers.go @@ -5,6 +5,16 @@ import ( "os" ) +// TriggerAppList outputs each app name to stdout on a newline +func TriggerAppList() error { + apps, _ := DokkuApps() + for _, app := range apps { + Log(app) + } + + return nil +} + // TriggerCorePostDeploy associates the container with a specified network func TriggerCorePostDeploy(appName string) error { quiet := os.Getenv("DOKKU_QUIET_OUTPUT") diff --git a/plugins/cron/functions.go b/plugins/cron/functions.go index 18cb1b1da..ebdd7fb61 100644 --- a/plugins/cron/functions.go +++ b/plugins/cron/functions.go @@ -11,7 +11,6 @@ import ( "text/template" appjson "github.com/dokku/dokku/plugins/app-json" - apps "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" cronparser "github.com/robfig/cron/v3" @@ -100,7 +99,7 @@ func deleteCrontab() error { } func writeCronEntries() error { - apps, _ := apps.DokkuApps() + apps, _ := common.DokkuApps() commands := []templateCommand{} for _, appName := range apps { scheduler := common.GetAppScheduler(appName) diff --git a/plugins/cron/subcommands.go b/plugins/cron/subcommands.go index 6038e1564..88bca6231 100644 --- a/plugins/cron/subcommands.go +++ b/plugins/cron/subcommands.go @@ -3,7 +3,6 @@ package cron import ( "fmt" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/ryanuber/columnize" ) @@ -32,7 +31,7 @@ func CommandList(appName string) error { // CommandReport displays a cron report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/logs/functions.go b/plugins/logs/functions.go index 91d6eea99..50aa6a2ca 100644 --- a/plugins/logs/functions.go +++ b/plugins/logs/functions.go @@ -10,7 +10,6 @@ import ( "strings" "time" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/joncalhoun/qson" ) @@ -157,7 +156,7 @@ func sinkValueToConfig(appName string, sinkValue string) (vectorSink, error) { } func writeVectorConfig() error { - apps, _ := apps.DokkuApps() + apps, _ := common.DokkuApps() data := vectorConfig{ Sources: map[string]vectorSource{}, Sinks: map[string]vectorSink{}, diff --git a/plugins/logs/subcommands.go b/plugins/logs/subcommands.go index 277213fe7..365a67892 100644 --- a/plugins/logs/subcommands.go +++ b/plugins/logs/subcommands.go @@ -7,7 +7,6 @@ import ( "strconv" "time" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -53,7 +52,7 @@ func CommandFailed(appName string, allApps bool) error { // CommandReport displays a logs report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/network/subcommands.go b/plugins/network/subcommands.go index f052281e8..bf04f5784 100644 --- a/plugins/network/subcommands.go +++ b/plugins/network/subcommands.go @@ -7,7 +7,6 @@ import ( "os" "strings" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -108,7 +107,7 @@ func CommandList() error { // CommandRebuildall rebuilds network settings for all apps func CommandRebuildall() error { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } @@ -126,7 +125,7 @@ func CommandRebuildall() error { // CommandReport displays a network report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/network/triggers.go b/plugins/network/triggers.go index 71840ea9e..2906c1428 100644 --- a/plugins/network/triggers.go +++ b/plugins/network/triggers.go @@ -7,7 +7,6 @@ import ( "strings" "unicode/utf8" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" ) @@ -34,7 +33,7 @@ func TriggerInstall() error { return fmt.Errorf("Unable to install the network plugin: %s", err.Error()) } - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return nil } diff --git a/plugins/proxy/subcommands.go b/plugins/proxy/subcommands.go index 836c9cf53..1dcb66558 100644 --- a/plugins/proxy/subcommands.go +++ b/plugins/proxy/subcommands.go @@ -4,7 +4,6 @@ import ( "errors" "strings" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" ) @@ -153,7 +152,7 @@ func CommandPortsSet(appName string, portMaps []string) error { // CommandReport displays a proxy report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/ps/subcommands.go b/plugins/ps/subcommands.go index 16c2f5ff6..2d00b87b4 100644 --- a/plugins/ps/subcommands.go +++ b/plugins/ps/subcommands.go @@ -6,7 +6,6 @@ import ( "path/filepath" "strings" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" dockeroptions "github.com/dokku/dokku/plugins/docker-options" "github.com/gofrs/flock" @@ -38,7 +37,7 @@ func CommandRebuild(appName string, allApps bool, parallelCount int) error { // CommandReport displays a ps report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/ps/triggers.go b/plugins/ps/triggers.go index fbd87868b..88c590ef0 100644 --- a/plugins/ps/triggers.go +++ b/plugins/ps/triggers.go @@ -10,7 +10,6 @@ import ( "strings" sh "github.com/codeskyblue/go-sh" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" dockeroptions "github.com/dokku/dokku/plugins/docker-options" @@ -75,7 +74,7 @@ func TriggerInstall() error { return err } - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return nil } diff --git a/plugins/registry/subcommands.go b/plugins/registry/subcommands.go index ba27a1e0a..beabc002a 100644 --- a/plugins/registry/subcommands.go +++ b/plugins/registry/subcommands.go @@ -7,7 +7,6 @@ import ( "os" "strings" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -56,7 +55,7 @@ func CommandLogin(server string, username string, password string, passwordStdin // CommandReport displays a registry report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/resource/subcommands.go b/plugins/resource/subcommands.go index 43402b572..f13217389 100644 --- a/plugins/resource/subcommands.go +++ b/plugins/resource/subcommands.go @@ -1,7 +1,6 @@ package resource import ( - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) @@ -27,7 +26,7 @@ func CommandLimitClear(appName string, processType string) error { // CommandReport displays a resource report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/scheduler/subcommands.go b/plugins/scheduler/subcommands.go index 4cded4dcb..98ed46e44 100644 --- a/plugins/scheduler/subcommands.go +++ b/plugins/scheduler/subcommands.go @@ -1,14 +1,13 @@ package scheduler import ( - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" ) // CommandReport displays a scheduler report for one or more apps func CommandReport(appName string, format string, infoFlag string) error { if len(appName) == 0 { - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return err } diff --git a/plugins/scheduler/triggers.go b/plugins/scheduler/triggers.go index f3ed30531..d5ae16b1d 100644 --- a/plugins/scheduler/triggers.go +++ b/plugins/scheduler/triggers.go @@ -3,7 +3,6 @@ package scheduler import ( "fmt" - "github.com/dokku/dokku/plugins/apps" "github.com/dokku/dokku/plugins/common" "github.com/dokku/dokku/plugins/config" ) @@ -32,7 +31,7 @@ func TriggerInstall() error { return fmt.Errorf("Unable to install the scheduler plugin: %s", err.Error()) } - apps, err := apps.DokkuApps() + apps, err := common.DokkuApps() if err != nil { return nil } From d5a3527059e08032f820460ded56114e347b2fd1 Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 26 Feb 2022 03:19:03 -0500 Subject: [PATCH 6/7] test: set a dummy path for PLUGIN_ENABLED_PATH Ideally we could use this to mock out different plugin paths with test implementations of user-auth-app, but for now setting something that won't generally fail is good enough. --- plugins/common/common_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/plugins/common/common_test.go b/plugins/common/common_test.go index 4fb32ea84..3e31967e1 100644 --- a/plugins/common/common_test.go +++ b/plugins/common/common_test.go @@ -87,6 +87,7 @@ func TestCommonDokkuAppsError(t *testing.T) { func TestCommonDokkuApps(t *testing.T) { RegisterTestingT(t) + os.Setenv("PLUGIN_ENABLED_PATH", "/var/lib/dokku/plugins/enabled") Expect(setupTestApp()).To(Succeed()) apps, err := DokkuApps() Expect(err).NotTo(HaveOccurred()) From ea5431b088e0d206a46911b9687b59d828bc70de Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 26 Feb 2022 03:45:34 -0500 Subject: [PATCH 7/7] chore: cleanup go.mod files again --- plugins/app-json/go.mod | 3 --- plugins/builder/go.mod | 3 --- plugins/buildpacks/go.mod | 3 --- plugins/cron/go.mod | 3 --- plugins/logs/go.mod | 3 --- plugins/network/go.mod | 3 --- plugins/proxy/go.mod | 3 --- plugins/ps/go.mod | 3 --- plugins/registry/go.mod | 3 --- plugins/resource/go.mod | 3 --- plugins/scheduler/go.mod | 3 --- 11 files changed, 33 deletions(-) diff --git a/plugins/app-json/go.mod b/plugins/app-json/go.mod index 772c0a15c..5de818c54 100644 --- a/plugins/app-json/go.mod +++ b/plugins/app-json/go.mod @@ -3,13 +3,10 @@ module github.com/dokku/dokku/plugins/app-json go 1.16 require ( - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/spf13/pflag v1.0.5 golang.org/x/sync v0.0.0-20201207232520-09787c993a3a ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/builder/go.mod b/plugins/builder/go.mod index 6153d3391..93f3068ee 100644 --- a/plugins/builder/go.mod +++ b/plugins/builder/go.mod @@ -3,12 +3,9 @@ module github.com/dokku/dokku/plugins/builder go 1.16 require ( - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/otiai10/copy v1.6.0 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/buildpacks/go.mod b/plugins/buildpacks/go.mod index 1be08af06..cd66e8765 100644 --- a/plugins/buildpacks/go.mod +++ b/plugins/buildpacks/go.mod @@ -3,11 +3,8 @@ module github.com/dokku/dokku/plugins/buildpacks go 1.16 require ( - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/cron/go.mod b/plugins/cron/go.mod index 75b251103..3918dd95c 100644 --- a/plugins/cron/go.mod +++ b/plugins/cron/go.mod @@ -4,15 +4,12 @@ go 1.16 require ( github.com/dokku/dokku/plugins/app-json v0.0.0-00010101000000-000000000000 - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/robfig/cron/v3 v3.0.1 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/app-json => ../app-json replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/logs/go.mod b/plugins/logs/go.mod index c13c79bcc..0c64d4a28 100644 --- a/plugins/logs/go.mod +++ b/plugins/logs/go.mod @@ -4,15 +4,12 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/docker-options v0.0.0-00010101000000-000000000000 github.com/joncalhoun/qson v0.0.0-20200422171543-84433dcd3da0 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/docker-options => ../docker-options diff --git a/plugins/network/go.mod b/plugins/network/go.mod index 55767a26a..a34058e0d 100644 --- a/plugins/network/go.mod +++ b/plugins/network/go.mod @@ -4,14 +4,11 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config diff --git a/plugins/proxy/go.mod b/plugins/proxy/go.mod index c4c1b4c52..a88c3cdc2 100644 --- a/plugins/proxy/go.mod +++ b/plugins/proxy/go.mod @@ -3,15 +3,12 @@ module github.com/dokku/dokku/plugins/proxy go 1.16 require ( - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/ryanuber/columnize v1.1.2-0.20190319233515-9e6335e58db3 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config diff --git a/plugins/ps/go.mod b/plugins/ps/go.mod index 82199a831..cdb884ecd 100644 --- a/plugins/ps/go.mod +++ b/plugins/ps/go.mod @@ -4,7 +4,6 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/docker-options v0.0.0-00010101000000-000000000000 @@ -14,8 +13,6 @@ require ( github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config diff --git a/plugins/registry/go.mod b/plugins/registry/go.mod index 732383d7b..d935e5bb9 100644 --- a/plugins/registry/go.mod +++ b/plugins/registry/go.mod @@ -4,11 +4,8 @@ go 1.16 require ( github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/resource/go.mod b/plugins/resource/go.mod index cd4df919a..a5792de11 100644 --- a/plugins/resource/go.mod +++ b/plugins/resource/go.mod @@ -3,11 +3,8 @@ module github.com/dokku/dokku/plugins/resource go 1.16 require ( - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common diff --git a/plugins/scheduler/go.mod b/plugins/scheduler/go.mod index 73ca20ce0..54dc95487 100644 --- a/plugins/scheduler/go.mod +++ b/plugins/scheduler/go.mod @@ -3,14 +3,11 @@ module github.com/dokku/dokku/plugins/scheduler go 1.16 require ( - github.com/dokku/dokku/plugins/apps v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/common v0.0.0-00010101000000-000000000000 github.com/dokku/dokku/plugins/config v0.0.0-00010101000000-000000000000 github.com/spf13/pflag v1.0.5 ) -replace github.com/dokku/dokku/plugins/apps => ../apps - replace github.com/dokku/dokku/plugins/common => ../common replace github.com/dokku/dokku/plugins/config => ../config