-
-
Notifications
You must be signed in to change notification settings - Fork 580
/
debug-compose-config.go
50 lines (40 loc) · 1.29 KB
/
debug-compose-config.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package cmd
import (
"strings"
"github.com/ddev/ddev/pkg/fileutil"
"github.com/ddev/ddev/pkg/ddevapp"
"github.com/ddev/ddev/pkg/output"
"github.com/ddev/ddev/pkg/util"
"github.com/spf13/cobra"
)
// DebugComposeConfigCmd implements the ddev debug compose-config command
var DebugComposeConfigCmd = &cobra.Command{
ValidArgsFunction: ddevapp.GetProjectNamesFunc("all", 1),
Use: "compose-config [project]",
Short: "Prints the docker-compose configuration of the current project",
Run: func(_ *cobra.Command, args []string) {
projectName := ""
if len(args) > 1 {
util.Failed("This command only takes one optional argument: project name")
}
if len(args) == 1 {
projectName = args[0]
}
app, err := ddevapp.GetActiveApp(projectName)
if err != nil {
util.Failed("Failed to get compose-config: %v", err)
}
app.DockerEnv()
if err = app.WriteDockerComposeYAML(); err != nil {
util.Failed("Failed to get compose-config: %v", err)
}
out, err := fileutil.ReadFileIntoString(app.DockerComposeFullRenderedYAMLPath())
if err != nil {
util.Failed("unable to read rendered file %s: %v", app.DockerComposeFullRenderedYAMLPath(), err)
}
output.UserOut.Print(strings.TrimSpace(out))
},
}
func init() {
DebugCmd.AddCommand(DebugComposeConfigCmd)
}