Skip to content

Replace container name in command output#63

Open
gtsiolis wants to merge 1 commit intomainfrom
george/replace-container-name
Open

Replace container name in command output#63
gtsiolis wants to merge 1 commit intomainfrom
george/replace-container-name

Conversation

@gtsiolis
Copy link
Member

@gtsiolis gtsiolis commented Mar 3, 2026

See DES-152 for more context.

BEFORE AFTER
Screenshot 2026-03-04 at 00 28 43 Screenshot 2026-03-04 at 00 27 52

@gtsiolis gtsiolis self-assigned this Mar 3, 2026
@coderabbitai
Copy link

coderabbitai bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

Standardizes user-facing messages and status output to consistently reference "LocalStack" instead of dynamic container names across start/stop flows and plain text status formatting; tests updated to match the new messages.

Changes

Cohort / File(s) Summary
Container Start
internal/container/start.go
Replaced per-container names with the static "LocalStack" label in start progress, readiness checks, and error messages.
Container Stop
internal/container/stop.go
Unified stop progress and error messages to reference "LocalStack" while preserving use of container name for the actual stop call.
Output Formatting
internal/output/plain_format.go
Replaced dynamic container-name substitutions in ContainerStatusEvent messages with fixed "LocalStack" phrasing for pulling/starting/waiting/ready and default cases.
Tests
internal/output/plain_format_test.go, internal/output/plain_sink_test.go
Updated test fixtures and expected strings to reflect "LocalStack" branding and adjusted container image identifiers in test inputs.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • silv-io
  • carole-lavillonniere
  • anisaoshafi
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: replacing container names with 'LocalStack' in command output messages across multiple files.
Description check ✅ Passed The description provides relevant context via a ticket reference (DES-152) and includes before-and-after visual comparisons showing the exact changes in terminal output.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch george/replace-container-name

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
internal/container/stop.go (1)

12-27: 🛠️ Refactor suggestion | 🟠 Major

Route stop progress through output.Sink, not onProgress callbacks.

This path still emits user-visible progress via raw callback strings, which breaks parity with the typed output event pipeline used in internal/ workflows.

Proposed direction
 package container

 import (
 	"context"
 	"fmt"

 	"github.com/containerd/errdefs"
 	"github.com/localstack/lstk/internal/config"
+	"github.com/localstack/lstk/internal/output"
 	"github.com/localstack/lstk/internal/runtime"
 )

-func Stop(ctx context.Context, rt runtime.Runtime, onProgress func(string)) error {
+func Stop(ctx context.Context, rt runtime.Runtime, sink output.Sink) error {
 	cfg, err := config.Get()
 	if err != nil {
 		return fmt.Errorf("failed to get config: %w", err)
 	}

 	for _, c := range cfg.Containers {
-		onProgress("Stopping LocalStack...")
+		output.EmitInfo(sink, "Stopping LocalStack...")
 		if err := rt.Stop(ctx, c.Name()); err != nil {
 			if errdefs.IsNotFound(err) {
 				return fmt.Errorf("LocalStack is not running")
 			}
 			return fmt.Errorf("failed to stop LocalStack: %w", err)
 		}
-		onProgress("LocalStack stopped")
+		output.EmitInfo(sink, "LocalStack stopped")
 	}

As per coding guidelines internal/**/*.go: “Any feature/workflow package that produces user-visible progress should accept an output.Sink dependency and emit events through internal/output.”

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/container/stop.go` around lines 12 - 27, The Stop function currently
uses an onProgress callback to emit raw strings; change its signature to accept
an output.Sink (instead of onProgress) and emit typed progress events via the
internal/output API (e.g., create and write a progress event for "Stopping
LocalStack..." and "LocalStack stopped") when iterating cfg.Containers and
calling rt.Stop(ctx, c.Name()). Update all references to Stop to pass an
output.Sink, remove onProgress usage, and ensure error branches still return the
same errors while emitting any final/failure events via the sink.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@internal/container/stop.go`:
- Around line 12-27: The Stop function currently uses an onProgress callback to
emit raw strings; change its signature to accept an output.Sink (instead of
onProgress) and emit typed progress events via the internal/output API (e.g.,
create and write a progress event for "Stopping LocalStack..." and "LocalStack
stopped") when iterating cfg.Containers and calling rt.Stop(ctx, c.Name()).
Update all references to Stop to pass an output.Sink, remove onProgress usage,
and ensure error branches still return the same errors while emitting any
final/failure events via the sink.

ℹ️ Review info

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3ac17a7 and 719deba.

📒 Files selected for processing (5)
  • internal/container/start.go
  • internal/container/stop.go
  • internal/output/plain_format.go
  • internal/output/plain_format_test.go
  • internal/output/plain_sink_test.go

@gtsiolis gtsiolis force-pushed the george/replace-container-name branch from 719deba to 6eb594e Compare March 3, 2026 22:28
@gtsiolis gtsiolis requested a review from anisaoshafi as a code owner March 3, 2026 22:28
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/output/plain_format_test.go (1)

51-60: Add table cases for all newly customized status branches.

The updated expectations are correct, but only two of the modified formatStatusLine branches are asserted here. Please add cases for starting, waiting, ready (without detail), and default fallback paths to lock in the full behavior change.

Suggested test additions
 		{
 			name:   "status pulling",
 			event:  ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack-pro:latest"},
 			want:   "Preparing LocalStack...",
 			wantOK: true,
 		},
+		{
+			name:   "status starting",
+			event:  ContainerStatusEvent{Phase: "starting", Container: "localstack-aws"},
+			want:   "Starting LocalStack...",
+			wantOK: true,
+		},
+		{
+			name:   "status waiting",
+			event:  ContainerStatusEvent{Phase: "waiting", Container: "localstack-aws"},
+			want:   "Waiting for LocalStack to be ready...",
+			wantOK: true,
+		},
 		{
 			name:   "status ready with detail",
 			event:  ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
 			want:   "LocalStack ready (abc123)",
 			wantOK: true,
 		},
+		{
+			name:   "status ready without detail",
+			event:  ContainerStatusEvent{Phase: "ready", Container: "localstack-aws"},
+			want:   "LocalStack ready",
+			wantOK: true,
+		},
+		{
+			name:   "status default with detail",
+			event:  ContainerStatusEvent{Phase: "restarting", Container: "localstack-aws", Detail: "attempt 1"},
+			want:   "LocalStack: restarting (attempt 1)",
+			wantOK: true,
+		},
+		{
+			name:   "status default without detail",
+			event:  ContainerStatusEvent{Phase: "restarting", Container: "localstack-aws"},
+			want:   "LocalStack: restarting",
+			wantOK: true,
+		},
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@internal/output/plain_format_test.go` around lines 51 - 60, The tests only
cover two branches of formatStatusLine; add table-driven cases asserting the
other new branches by adding entries to the test cases slice that construct
ContainerStatusEvent values for Phase "starting", "waiting", "ready" with no
Detail, and a generic unknown phase to exercise the default fallback, and set
the expected want strings and wantOK booleans to match the new formatStatusLine
behavior so all branches are asserted in the same Test function that iterates
over the cases.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@internal/output/plain_format_test.go`:
- Around line 51-60: The tests only cover two branches of formatStatusLine; add
table-driven cases asserting the other new branches by adding entries to the
test cases slice that construct ContainerStatusEvent values for Phase
"starting", "waiting", "ready" with no Detail, and a generic unknown phase to
exercise the default fallback, and set the expected want strings and wantOK
booleans to match the new formatStatusLine behavior so all branches are asserted
in the same Test function that iterates over the cases.

ℹ️ Review info

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 719deba and 6eb594e.

📒 Files selected for processing (5)
  • internal/container/start.go
  • internal/container/stop.go
  • internal/output/plain_format.go
  • internal/output/plain_format_test.go
  • internal/output/plain_sink_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • internal/output/plain_sink_test.go
  • internal/container/start.go
  • internal/container/stop.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant