这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/appendices/0.26.0-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
## Changes

- The `scheduler` plugin now controls the scheduler in use for deploys. Apps will have their `DOKKU_SCHEDULER` environment variables migrated to the scheduler plugin, after which that value will be removed from said app. Please see the [scheduler documentation](/docs/deployment/schedulers/scheduler-management.md) for more information.

- The `deploy-source` metadata from `apps:report` is now no longer computed on the fly, but hydrated at deploy time via the `deploy-source-set` trigger. This value may be empty until your next deploy.
- Additionally, the `deploy-source` trigger has now been removed.
26 changes: 15 additions & 11 deletions docs/deployment/application-management.md
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,20 @@ dokku apps:report

```
=====> node-js-app app information
App dir: /home/dokku/node-js-app
App deploy source: git
App locked: false
App dir: /home/dokku/node-js-app
App deploy source: git
App deploy source metadata: cd7b8afccb202f222e7dc7b427553e71ba5ddafd
App locked: false
=====> python-sample app information
App dir: /home/dokku/python-sample
App dir: /home/dokku/python-sample
App deploy source:
App locked: false
App deploy source metadata:
App locked: false
=====> ruby-sample app information
App dir: /home/dokku/ruby-sample
App deploy source: git
App locked: false
App dir: /home/dokku/ruby-sample
App deploy source: git
App deploy source metadata: c60921ea2799ca108276414b95ea197f16798d51
App locked: false
```

You can run the command for a specific app also.
Expand All @@ -264,9 +267,10 @@ dokku apps:report node-js-app

```
=====> node-js-app app information
App dir: /home/dokku/node-js-app
App deploy source: git
App locked: false
App dir: /home/dokku/node-js-app
App deploy source: git
App deploy source metadata: cd7b8afccb202f222e7dc7b427553e71ba5ddafd
App locked: false
```

You can pass flags which will output only the value of the specific information you want. For example:
Expand Down
27 changes: 0 additions & 27 deletions docs/development/plugin-triggers.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,33 +446,6 @@ APP="$1" IMAGE_TAG="$2" PROC_TYPE="$3"
# TODO
```

### `deploy-source`

- Description: Used for reporting what the current detected deployment source is. The first detected source should always win.
- Invoked by: `dokku apps:report`
- Arguments: `$APP`
- Example:

```shell
#!/usr/bin/env bash
# Checks if the app should be deployed via git

set -eo pipefail; [[ $DOKKU_TRACE ]] && set -x

APP="$1"
STDIN=$(cat)

# bail if another source is detected
if [[ -n "$STDIN" ]]; then
echo "$STDIN"
return
fi

if [[ -d "$DOKKU_ROOT/$APP/refs" ]]; then
echo "git"
fi
```

### `deployed-app-image-repo`

- Description: Used to manage the full repo of the image being deployed. Useful for deploying from an external registry where the repository name is not `dokku/$APP`
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion plugins/apps/Makefile
Original file line number Diff line number Diff line change
@@ -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/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

Expand Down
15 changes: 15 additions & 0 deletions plugins/apps/apps.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package apps

var (
// DefaultProperties is a map of all valid network properties with corresponding default property values
DefaultProperties = map[string]string{
"deploy-source": "",
"deploy-source-metadata": "",
}

// GlobalProperties is a map of all valid global network properties
GlobalProperties = map[string]bool{
"deploy-source": true,
"deploy-source-metadata": true,
}
)
24 changes: 11 additions & 13 deletions plugins/apps/report.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package apps

import (
"strings"

"github.com/dokku/dokku/plugins/common"
)

Expand All @@ -13,9 +11,10 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
}

flags := map[string]common.ReportFunc{
"--app-dir": reportDir,
"--app-deploy-source": reportDeploySource,
"--app-locked": reportLocked,
"--app-deploy-source": reportDeploySource,
"--app-deploy-source-metadata": reportDeploySourceMetadata,
"--app-dir": reportDir,
"--app-locked": reportLocked,
}

flagKeys := []string{}
Expand All @@ -29,17 +28,16 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
return common.ReportSingleApp("app", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
}

func reportDir(appName string) string {
return common.AppRoot(appName)
func reportDeploySource(appName string) string {
return common.PropertyGet("apps", appName, "deploy-source")
}

func reportDeploySource(appName string) string {
deploySource := ""
if b, err := common.PlugnTriggerSetup("deploy-source", []string{appName}...).SetInput("").Output(); err != nil {
deploySource = strings.TrimSpace(string(b[:]))
}
func reportDeploySourceMetadata(appName string) string {
return common.PropertyGet("apps", appName, "deploy-source-metadata")
}

return deploySource
func reportDir(appName string) string {
return common.AppRoot(appName)
}

func reportLocked(appName string) string {
Expand Down
15 changes: 15 additions & 0 deletions plugins/apps/src/triggers/triggers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,21 @@ func main() {
case "app-maybe-create":
appName := flag.Arg(0)
err = apps.TriggerAppMaybeCreate(appName)
case "deploy-source-set":
appName := flag.Arg(0)
sourceType := flag.Arg(0)
sourceMetadata := flag.Arg(0)
err = apps.TriggerDeploySourceSet(appName, sourceType, sourceMetadata)
case "install":
err = apps.TriggerInstall()
case "post-app-clone-setup":
oldAppName := flag.Arg(0)
newAppName := flag.Arg(1)
err = apps.TriggerPostAppCloneSetup(oldAppName, newAppName)
case "post-app-rename-setup":
oldAppName := flag.Arg(0)
newAppName := flag.Arg(1)
err = apps.TriggerPostAppRenameSetup(oldAppName, newAppName)
case "post-delete":
appName := flag.Arg(0)
err = apps.TriggerPostDelete(appName)
Expand Down
48 changes: 47 additions & 1 deletion plugins/apps/triggers.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package apps

import (
"fmt"

"github.com/dokku/dokku/plugins/common"
)

Expand All @@ -24,15 +26,59 @@ func TriggerAppMaybeCreate(appName string) error {
return maybeCreateApp(appName)
}

// TriggerDeploySourceSet sets the current deploy source
func TriggerDeploySourceSet(appName string, sourceType string, sourceMetadata string) error {
if err := common.PropertyWrite("apps", appName, "deploy-source", sourceType); err != nil {
return err
}

return common.PropertyWrite("apps", appName, "deploy-source-metadata", sourceMetadata)
}

// TriggerInstall runs the install step for the apps plugin
func TriggerInstall() error {
if err := common.PropertySetup("apps"); err != nil {
return fmt.Errorf("Unable to install the apps plugin: %s", err.Error())
}

return nil
}

// TriggerPostAppCloneSetup creates new apps files
func TriggerPostAppCloneSetup(oldAppName string, newAppName string) error {
err := common.PropertyClone("apps", oldAppName, newAppName)
if err != nil {
return err
}

return nil
}

// TriggerPostAppRenameSetup renames apps files
func TriggerPostAppRenameSetup(oldAppName string, newAppName string) error {
if err := common.PropertyClone("apps", oldAppName, newAppName); err != nil {
return err
}

if err := common.PropertyDestroy("apps", oldAppName); err != nil {
return err
}

return nil
}

// TriggerPostDelete is the apps post-delete plugin trigger
func TriggerPostDelete(appName string) error {
imageRepo := common.GetAppImageRepo(appName)
if err := common.PropertyDestroy("apps", appName); err != nil {
common.LogWarn(err.Error())
}

imagesByAppLabel, err := listImagesByAppLabel(appName)
if err != nil {
common.LogWarn(err.Error())
}

imageRepo := common.GetAppImageRepo(appName)
imagesByRepo, err := listImagesByImageRepo(imageRepo)
if err != nil {
common.LogWarn(err.Error())
Expand Down
23 changes: 0 additions & 23 deletions plugins/git/deploy-source

This file was deleted.

3 changes: 3 additions & 0 deletions plugins/git/functions
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,17 @@ cmd-git-hook() {
if [[ $refname == "refs/heads/${DOKKU_DEPLOY_BRANCH}" ]]; then
# broken out into plugin so we might support other methods to receive an app
git_receive_app "$APP" "$newrev"
plugn trigger deploy-source-set "$APP" "git-push" "$newrev"
else
if [[ $(find "$PLUGIN_PATH"/enabled/*/receive-branch 2>/dev/null | wc -l) != 1 ]]; then
# shellcheck disable=SC2086
plugn trigger receive-branch $APP $newrev $refname
plugn trigger deploy-source-set "$APP" "git-push" "$newrev"
elif [[ -z "$(fn-git-deploy-branch "$APP" "")" ]]; then
echo $'\e[1G\e[K'"-----> Set ${refname/refs\/heads\//} to DOKKU_DEPLOY_BRANCH."
fn-plugin-property-write "git" "$app" "deploy-branch" "${refname/refs\/heads\//}"
git_receive_app "$APP" "$newrev"
plugn trigger deploy-source-set "$APP" "git-push" "$newrev"
else
echo $'\e[1G\e[K'"-----> WARNING: deploy did not complete, you must push to ${DOKKU_DEPLOY_BRANCH}."
echo $'\e[1G\e[K'"-----> for example, try 'git push <dokku> ${refname/refs\/heads\//}:${DOKKU_DEPLOY_BRANCH}'"
Expand Down
3 changes: 3 additions & 0 deletions plugins/git/internal-functions
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ cmd-git-from-archive() {
fi

plugn trigger git-from-archive "$APP" "$ARCHIVE_URL" "$ARCHIVE_TYPE" "$USER_NAME" "$USER_EMAIL"
plugn trigger deploy-source-set "$APP" "$ARCHIVE_TYPE" "$ARCHIVE_URL"
}

cmd-git-auth() {
Expand Down Expand Up @@ -110,6 +111,7 @@ cmd-git-from-image() {
[[ -z "$DOCKER_IMAGE" ]] && dokku_log_fail "Please specify a docker image"

plugn trigger git-from-image "$APP" "$DOCKER_IMAGE" "$BUILD_DIR" "$USER_NAME" "$USER_EMAIL"
plugn trigger deploy-source-set "$APP" "docker-image" "$DOCKER_IMAGE"
}

cmd-git-sync() {
Expand Down Expand Up @@ -165,6 +167,7 @@ cmd-git-sync() {
else
plugn trigger receive-app "$APP"
fi
plugn trigger deploy-source-set "$APP" "git-sync" "${GIT_REMOTE}#${GIT_REF}"
fi
}

Expand Down