-
-
Notifications
You must be signed in to change notification settings - Fork 580
/
debug-router-nginx-config.go
58 lines (47 loc) · 1.66 KB
/
debug-router-nginx-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
51
52
53
54
55
56
57
58
package cmd
import (
"github.com/ddev/ddev/pkg/ddevapp"
"github.com/ddev/ddev/pkg/dockerutil"
"github.com/ddev/ddev/pkg/globalconfig"
"github.com/ddev/ddev/pkg/globalconfig/types"
"github.com/ddev/ddev/pkg/util"
"os"
"strings"
"github.com/ddev/ddev/pkg/output"
"github.com/spf13/cobra"
)
// TODO: This debug function should be removed by 2024-01-01 since the nginx-proxy router is deprecated
// and since it's easy enough to do this task manually.
// DebugRouterNginxConfigCmd implements the ddev debug router-config command
// This is only for the obsolete nginx-proxy router
var DebugRouterNginxConfigCmd = &cobra.Command{
Use: "nginx-proxy-router-nginx-config",
Short: "Obsolete: Prints the nginx config in the legacy `nginx-proxy` router",
Example: "ddev debug nginx-proxy-router-nginx-config",
Run: func(_ *cobra.Command, _ []string) {
app, err := ddevapp.GetActiveApp("")
if err != nil {
util.Failed("Failed to debug router-config : %v", err)
}
if ddevapp.IsRouterDisabled(app) {
util.Warning("Router is disabled by config")
os.Exit(0)
}
container, _ := ddevapp.FindDdevRouter()
if container == nil {
util.Failed("Router is not running")
return // extraneous - for lint to know we exited
}
// See containers/ddev-router/testtools/testgen.sh
stdout, _, err := dockerutil.Exec(container.ID, "cat /etc/nginx/conf.d/ddev.conf", "")
if err != nil {
util.Failed("Failed to run docker-gen command in ddev-router container: %v", err)
}
output.UserOut.Print(strings.TrimSpace(stdout))
},
}
func init() {
if globalconfig.DdevGlobalConfig.Router == types.RouterTypeNginxProxy {
DebugCmd.AddCommand(DebugRouterNginxConfigCmd)
}
}