2021-02-11 06:41:11 -05:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
|
|
func export(appName string, global bool, merged bool, format string) error {
|
|
|
|
|
appName, err := getAppNameOrGlobal(appName, global)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
env := getEnvironment(appName, merged)
|
|
|
|
|
exportType := ExportFormatExports
|
|
|
|
|
suffix := "\n"
|
|
|
|
|
|
|
|
|
|
exportTypes := map[string]ExportFormat{
|
|
|
|
|
"docker-args": ExportFormatDockerArgs,
|
|
|
|
|
"docker-args-keys": ExportFormatDockerArgsKeys,
|
2022-01-15 08:34:02 -05:00
|
|
|
"envfile": ExportFormatEnvfile,
|
|
|
|
|
"exports": ExportFormatExports,
|
2021-02-11 06:41:11 -05:00
|
|
|
"json": ExportFormatJSON,
|
|
|
|
|
"json-list": ExportFormatJSONList,
|
2022-01-15 08:39:53 -05:00
|
|
|
"pack-keys": ExportFormatPackArgKeys,
|
2022-01-15 08:34:02 -05:00
|
|
|
"pretty": ExportFormatPretty,
|
|
|
|
|
"shell": ExportFormatShell,
|
2021-02-11 06:41:11 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exportType, ok := exportTypes[format]
|
|
|
|
|
if !ok {
|
|
|
|
|
return fmt.Errorf("Unknown export format: %v", format)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if exportType == ExportFormatShell {
|
|
|
|
|
suffix = " "
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
exported := env.Export(exportType)
|
|
|
|
|
fmt.Print(exported + suffix)
|
|
|
|
|
return nil
|
|
|
|
|
}
|