From e4438baa652a05834ef58bd59b4252a084a6dc52 Mon Sep 17 00:00:00 2001 From: Rob Watson Date: Tue, 1 Apr 2025 16:39:44 +0200 Subject: [PATCH] feat: require ingress for egress --- internal/app/app.go | 5 +++++ internal/app/integration_test.go | 4 ++-- internal/terminal/terminal.go | 13 ++++++++++++- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/internal/app/app.go b/internal/app/app.go index c91f1ed..e4f13a9 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -140,6 +140,11 @@ func Run(ctx context.Context, params RunParams) error { continue } case terminal.CommandStartDestination: + if !state.Source.Live { + ui.ShowSourceNotLiveModal() + continue + } + mp.StartDestination(c.URL) case terminal.CommandStopDestination: mp.StopDestination(c.URL) diff --git a/internal/app/integration_test.go b/internal/app/integration_test.go index 35bfe20..228f97c 100644 --- a/internal/app/integration_test.go +++ b/internal/app/integration_test.go @@ -91,7 +91,7 @@ func TestIntegration(t *testing.T) { contents := getContents() require.True(t, len(contents) > 2, "expected at least 3 lines of output") - assert.Contains(t, contents[2], "Status ready", "expected mediaserver status to be ready") + assert.Contains(t, contents[2], "Status waiting", "expected mediaserver status to be waiting") }, 2*time.Minute, time.Second, @@ -281,7 +281,7 @@ func TestIntegrationDestinationValidations(t *testing.T) { contents := getContents() require.True(t, len(contents) > 2, "expected at least 3 lines of output") - assert.Contains(t, contents[2], "Status ready", "expected mediaserver status to be ready") + assert.Contains(t, contents[2], "Status waiting", "expected mediaserver status to be waiting") }, 2*time.Minute, time.Second, diff --git a/internal/terminal/terminal.go b/internal/terminal/terminal.go index 569afb1..3941419 100644 --- a/internal/terminal/terminal.go +++ b/internal/terminal/terminal.go @@ -297,6 +297,17 @@ func (ui *UI) run(ctx context.Context) { } } +func (ui *UI) ShowSourceNotLiveModal() { + ui.app.QueueUpdateDraw(func() { + ui.showModal( + pageNameModalStartupCheck, + fmt.Sprintf("Source is not live.\nStart streaming to the source URL then try again:\n\n%s", ui.sourceViews.url.GetText(true)), + []string{"Ok"}, + nil, + ) + }) +} + // ShowStartupCheckModal shows a modal dialog to the user, asking if they want // to kill a running instance of Octoplex. // @@ -571,7 +582,7 @@ func (ui *UI) redrawFromState(state domain.AppState) { ui.sourceViews.status.SetText("[black:green]receiving" + durStr) } else if state.Source.Container.Status == domain.ContainerStatusRunning && state.Source.Container.HealthState == "healthy" { - ui.sourceViews.status.SetText("[black:yellow]ready") + ui.sourceViews.status.SetText("[black:yellow]waiting") } else { ui.sourceViews.status.SetText("[white:red]not ready") }