Skip to content

Commit 80f56db

Browse files
committed
Replace container name in command output
1 parent 02fadd2 commit 80f56db

File tree

5 files changed

+33
-33
lines changed

5 files changed

+33
-33
lines changed

internal/container/start.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ func startContainers(ctx context.Context, rt runtime.Runtime, sink output.Sink,
185185
output.EmitStatus(sink, "starting", c.Name, "")
186186
containerID, err := rt.Start(ctx, c)
187187
if err != nil {
188-
return fmt.Errorf("failed to start %s: %w", c.Name, err)
188+
return fmt.Errorf("failed to start LocalStack: %w", err)
189189
}
190190

191191
output.EmitStatus(sink, "waiting", c.Name, "")
192192
healthURL := fmt.Sprintf("http://localhost:%s%s", c.Port, c.HealthPath)
193-
if err := awaitStartup(ctx, rt, sink, containerID, c.Name, healthURL); err != nil {
193+
if err := awaitStartup(ctx, rt, sink, containerID, "LocalStack", healthURL); err != nil {
194194
return err
195195
}
196196

@@ -207,7 +207,7 @@ func selectContainersToStart(ctx context.Context, rt runtime.Runtime, sink outpu
207207
return nil, fmt.Errorf("failed to check container status: %w", err)
208208
}
209209
if running {
210-
output.EmitInfo(sink, fmt.Sprintf("%s is already running", c.Name))
210+
output.EmitInfo(sink, "LocalStack is already running")
211211
continue
212212
}
213213
if err := ports.CheckAvailable(c.Port); err != nil {

internal/container/stop.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ func Stop(ctx context.Context, rt runtime.Runtime, sink output.Sink) error {
2222
return fmt.Errorf("checking %s running: %w", name, err)
2323
}
2424
if !running {
25-
return fmt.Errorf("%s is not running", name)
25+
return fmt.Errorf("LocalStack is not running")
2626
}
27-
output.EmitSpinnerStart(sink, fmt.Sprintf("Stopping %s", name))
27+
output.EmitSpinnerStart(sink, "Stopping LocalStack...")
2828
if err := rt.Stop(ctx, name); err != nil {
2929
output.EmitSpinnerStop(sink)
30-
return fmt.Errorf("failed to stop %s: %w", name, err)
30+
return fmt.Errorf("failed to stop LocalStack: %w", err)
3131
}
3232
output.EmitSpinnerStop(sink)
33-
output.EmitSuccess(sink, fmt.Sprintf("%s stopped", name))
33+
output.EmitSuccess(sink, "LocalStack stopped")
3434
}
3535

3636
return nil

internal/output/plain_format.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ func FormatEventLine(event any) (string, bool) {
3535
func formatStatusLine(e ContainerStatusEvent) (string, bool) {
3636
switch e.Phase {
3737
case "pulling":
38-
return "", false
38+
return "Preparing LocalStack...", true
3939
case "starting":
40-
return fmt.Sprintf("Starting %s...", e.Container), true
40+
return "Starting LocalStack...", true
4141
case "waiting":
42-
return fmt.Sprintf("Waiting for %s to be ready...", e.Container), true
42+
return "Waiting for LocalStack to be ready...", true
4343
case "ready":
4444
if e.Detail != "" {
45-
return fmt.Sprintf("%s ready (%s)", e.Container, e.Detail), true
45+
return fmt.Sprintf("LocalStack ready (%s)", e.Detail), true
4646
}
47-
return fmt.Sprintf("%s ready", e.Container), true
47+
return "LocalStack ready", true
4848
default:
4949
if e.Detail != "" {
50-
return fmt.Sprintf("%s: %s (%s)", e.Container, e.Phase, e.Detail), true
50+
return fmt.Sprintf("LocalStack: %s (%s)", e.Phase, e.Detail), true
5151
}
52-
return fmt.Sprintf("%s: %s", e.Container, e.Phase), true
52+
return fmt.Sprintf("LocalStack: %s", e.Phase), true
5353
}
5454
}
5555

internal/output/plain_format_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@ func TestFormatEventLine(t *testing.T) {
4848
wantOK: true,
4949
},
5050
{
51-
name: "status pulling suppressed",
51+
name: "status pulling",
5252
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack:latest"},
53-
want: "",
54-
wantOK: false,
53+
want: "Preparing LocalStack...",
54+
wantOK: true,
5555
},
5656
{
5757
name: "status ready with detail",
58-
event: ContainerStatusEvent{Phase: "ready", Container: "localstack", Detail: "abc123"},
59-
want: "localstack ready (abc123)",
58+
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
59+
want: "LocalStack ready (abc123)",
6060
wantOK: true,
6161
},
6262
{

internal/output/plain_sink_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -42,39 +42,39 @@ func TestPlainSink_EmitsStatusEvent(t *testing.T) {
4242
expected string
4343
}{
4444
{
45-
name: "pulling phase suppressed",
45+
name: "pulling phase",
4646
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack:latest"},
47-
expected: "",
47+
expected: "Preparing LocalStack...\n",
4848
},
4949
{
5050
name: "starting phase",
51-
event: ContainerStatusEvent{Phase: "starting", Container: "localstack"},
52-
expected: "Starting localstack...\n",
51+
event: ContainerStatusEvent{Phase: "starting", Container: "localstack-aws"},
52+
expected: "Starting LocalStack...\n",
5353
},
5454
{
5555
name: "waiting phase",
56-
event: ContainerStatusEvent{Phase: "waiting", Container: "localstack"},
57-
expected: "Waiting for localstack to be ready...\n",
56+
event: ContainerStatusEvent{Phase: "waiting", Container: "localstack-aws"},
57+
expected: "Waiting for LocalStack to be ready...\n",
5858
},
5959
{
6060
name: "ready phase with detail",
61-
event: ContainerStatusEvent{Phase: "ready", Container: "localstack", Detail: "abc123"},
62-
expected: "localstack ready (abc123)\n",
61+
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
62+
expected: "LocalStack ready (abc123)\n",
6363
},
6464
{
6565
name: "ready phase without detail",
66-
event: ContainerStatusEvent{Phase: "ready", Container: "localstack"},
67-
expected: "localstack ready\n",
66+
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws"},
67+
expected: "LocalStack ready\n",
6868
},
6969
{
7070
name: "unknown phase with detail",
71-
event: ContainerStatusEvent{Phase: "custom", Container: "localstack", Detail: "info"},
72-
expected: "localstack: custom (info)\n",
71+
event: ContainerStatusEvent{Phase: "custom", Container: "localstack-aws", Detail: "info"},
72+
expected: "LocalStack: custom (info)\n",
7373
},
7474
{
7575
name: "unknown phase without detail",
76-
event: ContainerStatusEvent{Phase: "custom", Container: "localstack"},
77-
expected: "localstack: custom\n",
76+
event: ContainerStatusEvent{Phase: "custom", Container: "localstack-aws"},
77+
expected: "LocalStack: custom\n",
7878
},
7979
}
8080

0 commit comments

Comments
 (0)