Skip to content

Commit a6aca54

Browse files
committed
feat(port-forward): add postgres ssl tip
1 parent 50bf088 commit a6aca54

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

internal/actions/portforward/portforward.go

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import (
1414
"time"
1515

1616
"github.com/charmbracelet/lipgloss"
17+
"github.com/charmbracelet/lipgloss/list"
1718
"github.com/clevyr/kubedb/internal/config/conftypes"
19+
"github.com/clevyr/kubedb/internal/database/postgres"
1820
"github.com/clevyr/kubedb/internal/log"
1921
"github.com/clevyr/kubedb/internal/tui"
2022
"golang.org/x/time/rate"
@@ -127,6 +129,21 @@ func (a PortForward) printTable() {
127129

128130
headerStyle := tui.HeaderStyle(nil)
129131
italicStyle := tui.TextStyle(nil).Italic(true)
132+
133+
tips := list.New(
134+
tui.TextStyle(nil).Render("To connect from a Docker container, set the hostname to ") +
135+
italicStyle.Render("host.docker.internal"),
136+
).Enumerator(func(list.Items, int) string {
137+
return " •"
138+
})
139+
140+
if _, ok := a.Dialect.(postgres.Postgres); ok {
141+
tips.Item(
142+
tui.TextStyle(nil).Render("Postgres causes reconnects when SSL is enabled. Disable SSL by adding ") +
143+
italicStyle.Render("sslmode=disable") + " to your connection string",
144+
)
145+
}
146+
130147
data := lipgloss.JoinVertical(lipgloss.Left,
131148
lipgloss.JoinVertical(lipgloss.Center,
132149
headerStyle.Render("Database Instance"),
@@ -138,9 +155,8 @@ func (a PortForward) printTable() {
138155
params.Render(),
139156
),
140157
"",
141-
headerStyle.Render("Tip:")+
142-
tui.TextStyle(nil).Render(" If you're connecting from a Docker container, set the hostname to ")+
143-
italicStyle.Render("host.docker.internal"),
158+
headerStyle.Render("Tips:"),
159+
tips.String(),
144160
)
145161

146162
baseStyle := lipgloss.NewStyle().

0 commit comments

Comments
 (0)