mirror of
https://github.com/dokku/dokku.git
synced 2026-02-24 04:00:36 +01:00
[config] restore dokku config functionality and fix docs
This commit is contained in:
@@ -5,10 +5,11 @@ Typically an application will require some configuration to run properly. Dokku
|
||||
The `config` plugin provides the following commands to manage your variables:
|
||||
|
||||
```
|
||||
config (<app>|--global) Display all global or app-specific config vars
|
||||
config:get (<app>|--global) KEY Display a global or app-specific config value
|
||||
config:set (<app>|--global) KEY1=VALUE1 [KEY2=VALUE2 ...] Set one or more config vars
|
||||
config:unset (<app>|--global) KEY1 [KEY2 ...] Unset one or more config vars
|
||||
config (<app>|--global) Display all global or app-specific config vars
|
||||
config:get (<app>|--global) KEY Display a global or app-specific config value
|
||||
config:set (<app>|--global) KEY1=VALUE1 [KEY2=VALUE2 ...] Set one or more config vars
|
||||
config:unset (<app>|--global) KEY1 [KEY2 ...] Unset one or more config vars
|
||||
config:export [--format=FORMAT] [--merged] (<app>|--global) Export all global or app-specific configuration
|
||||
```
|
||||
|
||||
The variables are available both at run time and during the application build/compilation step for buildpack-based deploys. For security reasons - and as per [docker recommendations](https://github.com/docker/docker/issues/13490) - Dockerfile-based deploys have variables available *only* during runtime, as noted in [this issue](https://github.com/dokku/dokku/issues/1860).
|
||||
@@ -50,13 +51,14 @@ dokku config:export node-js-app
|
||||
# export COMPILE_ASSETS='1'
|
||||
|
||||
# source in all the node-js-app app environment variables
|
||||
eval $(dokku config node-js-app --export)
|
||||
eval $(dokku config:export node-js-app)
|
||||
```
|
||||
|
||||
You can also output the variables in a single-line for usage in command-line utilities with the `--shell` flag:
|
||||
You can control the format of the exported variables with the `--format` flag.
|
||||
`--format=shell` will output the variables in a single-line for usage in command-line utilities:
|
||||
|
||||
```shell
|
||||
dokku config:export node-js-app --format shell
|
||||
dokku config:export --format shell node-js-app
|
||||
|
||||
# outputs variables in the form:
|
||||
#
|
||||
|
||||
@@ -7,6 +7,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/dokku/dokku/plugins/common"
|
||||
"github.com/dokku/dokku/plugins/config/src/configenv"
|
||||
|
||||
"github.com/dokku/dokku/plugins/config"
|
||||
columnize "github.com/ryanuber/columnize"
|
||||
)
|
||||
@@ -36,13 +39,32 @@ func main() {
|
||||
cmd := flag.Arg(0)
|
||||
switch cmd {
|
||||
case "config", "config:show":
|
||||
target := flag.Arg(1)
|
||||
env := config.GetConfig(target, false)
|
||||
fmt.Print(config.PrettyPrintEnvEntries("", env.Map()))
|
||||
args := flag.NewFlagSet("config:show", flag.ExitOnError)
|
||||
global := args.Bool("global", false, "--global: use the global environment")
|
||||
shell := args.Bool("shell", false, "--shell: in a single-line for usage in command-line utilities [deprecated]")
|
||||
export := args.Bool("export", false, "--export: print the env as eval-compatible exports [deprecated]")
|
||||
args.Parse(os.Args[2:])
|
||||
appName, _ := config.GetCommonArgs(*global, args.Args())
|
||||
env := config.GetConfig(appName, false)
|
||||
|
||||
if *shell && *export {
|
||||
common.LogFail("Only one of --shell and --export can be given")
|
||||
}
|
||||
if *shell {
|
||||
fmt.Print(env.Export(configenv.Shell))
|
||||
} else if *export {
|
||||
fmt.Println(env.Export(configenv.Exports))
|
||||
} else {
|
||||
contextName := "global"
|
||||
if appName != "" {
|
||||
contextName = appName
|
||||
}
|
||||
common.LogInfo2(contextName + " config vars")
|
||||
fmt.Println(config.PrettyPrintEnvEntries("", env.Map()))
|
||||
}
|
||||
case "config:help":
|
||||
usage()
|
||||
case "help":
|
||||
fmt.Print(helpContent)
|
||||
usage()
|
||||
default:
|
||||
dokkuNotImplementExitCode, err := strconv.Atoi(os.Getenv("DOKKU_NOT_IMPLEMENTED_EXIT"))
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user