feat: scope docker-options to specific procfile processes
Adds a `--process` flag (repeatable) to docker-options:add/remove/clear/list and the new docker-options:list subcommand for querying a single process+phase pair. Process scoping is supported only for the deploy phase since build runs once per app and run covers ad-hoc commands and cron tasks where no Procfile process type is available. Storage moves from `$DOKKU_ROOT/$APP/DOCKER_OPTIONS_*` files to property lists under `/var/lib/dokku/config/docker-options/$APP/{processType}.{phase}`, with `_default_` as the sentinel for app-wide options. The install trigger migrates pre-existing DOCKER_OPTIONS_* files into property lists once and renames them to `.migrated`; a global marker makes re-runs strictly no-op. The legacy docker-args-{build,deploy,run} bash triggers are reimplemented in Go alongside a new docker-args-process-deploy trigger that surfaces per-process options to the scheduler. The :report command exposes one dynamic flag per configured `process.deploy` pair (e.g. `--docker-options-deploy.web`) and supports `--format json`. There is no `--global` flag; omitting `--process` keeps the historical default behaviour, since `--global` elsewhere in dokku means "across all apps". Closes #2441.
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
package dockeroptions
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// ReportSingleApp displays the docker options report for a single app
|
||||
// ReportSingleApp displays the docker options report for a single app.
|
||||
// Default-scope options are reported under fixed keys for each phase.
|
||||
// Process-scoped options surface as dynamic per-process keys, one per
|
||||
// configured process+phase combination.
|
||||
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
@@ -18,6 +22,18 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
"--docker-options-run": reportRunOptions,
|
||||
}
|
||||
|
||||
processTypes, err := ListProcessTypesWithOptions(appName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, processType := range processTypes {
|
||||
processType := processType
|
||||
flagName := fmt.Sprintf("--docker-options-deploy.%s", processType)
|
||||
flags[flagName] = func(app string) string {
|
||||
return joinProcessPhaseOptions(app, processType, "deploy")
|
||||
}
|
||||
}
|
||||
|
||||
flagKeys := []string{}
|
||||
for flagKey := range flags {
|
||||
flagKeys = append(flagKeys, flagKey)
|
||||
@@ -30,19 +46,19 @@ func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
}
|
||||
|
||||
func reportBuildOptions(appName string) string {
|
||||
return joinPhaseOptions(appName, "build")
|
||||
return joinProcessPhaseOptions(appName, DefaultProcessType, "build")
|
||||
}
|
||||
|
||||
func reportDeployOptions(appName string) string {
|
||||
return joinPhaseOptions(appName, "deploy")
|
||||
return joinProcessPhaseOptions(appName, DefaultProcessType, "deploy")
|
||||
}
|
||||
|
||||
func reportRunOptions(appName string) string {
|
||||
return joinPhaseOptions(appName, "run")
|
||||
return joinProcessPhaseOptions(appName, DefaultProcessType, "run")
|
||||
}
|
||||
|
||||
func joinPhaseOptions(appName string, phase string) string {
|
||||
options, err := GetDockerOptionsForPhase(appName, phase)
|
||||
func joinProcessPhaseOptions(appName, processType, phase string) string {
|
||||
options, err := GetDockerOptionsForProcessPhase(appName, processType, phase)
|
||||
if err != nil || len(options) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user