refactor: migrate docker-options subcommands to go
Ports the user-facing CLI subcommands and lifecycle triggers from bash to go, mirroring the layout used by the ports plugin. The on-disk format (`DOCKER_OPTIONS_BUILD/DEPLOY/RUN` files), the `docker-args-build/deploy/run` triggers, and every exported helper consumed by other plugins are unchanged. Reserves the `--process` and `--global` flags on add, remove, and clear so usage today exits with a not-yet-implemented error and the surface is locked in ahead of the process-scoping work tracked in #2441.
This commit is contained in:
50
plugins/docker-options/report.go
Normal file
50
plugins/docker-options/report.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package dockeroptions
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
)
|
||||
|
||||
// ReportSingleApp displays the docker options report for a single app
|
||||
func ReportSingleApp(appName string, format string, infoFlag string) error {
|
||||
if err := common.VerifyAppName(appName); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
flags := map[string]common.ReportFunc{
|
||||
"--docker-options-build": reportBuildOptions,
|
||||
"--docker-options-deploy": reportDeployOptions,
|
||||
"--docker-options-run": reportRunOptions,
|
||||
}
|
||||
|
||||
flagKeys := []string{}
|
||||
for flagKey := range flags {
|
||||
flagKeys = append(flagKeys, flagKey)
|
||||
}
|
||||
|
||||
trimPrefix := false
|
||||
uppercaseFirstCharacter := true
|
||||
infoFlags := common.CollectReport(appName, infoFlag, flags)
|
||||
return common.ReportSingleApp("docker options", appName, infoFlag, infoFlags, flagKeys, format, trimPrefix, uppercaseFirstCharacter)
|
||||
}
|
||||
|
||||
func reportBuildOptions(appName string) string {
|
||||
return joinPhaseOptions(appName, "build")
|
||||
}
|
||||
|
||||
func reportDeployOptions(appName string) string {
|
||||
return joinPhaseOptions(appName, "deploy")
|
||||
}
|
||||
|
||||
func reportRunOptions(appName string) string {
|
||||
return joinPhaseOptions(appName, "run")
|
||||
}
|
||||
|
||||
func joinPhaseOptions(appName string, phase string) string {
|
||||
options, err := GetDockerOptionsForPhase(appName, phase)
|
||||
if err != nil || len(options) == 0 {
|
||||
return ""
|
||||
}
|
||||
return strings.Join(options, " ")
|
||||
}
|
||||
Reference in New Issue
Block a user