Skip to content

Commit 719deba

Browse files
committed
Replace container name in command output
1 parent 3ac17a7 commit 719deba

File tree

5 files changed

+33
-34
lines changed

5 files changed

+33
-34
lines changed

internal/container/start.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,12 @@ func startContainers(ctx context.Context, rt runtime.Runtime, sink output.Sink,
122122
output.EmitStatus(sink, "starting", c.Name, "")
123123
containerID, err := rt.Start(ctx, c)
124124
if err != nil {
125-
return fmt.Errorf("failed to start %s: %w", c.Name, err)
125+
return fmt.Errorf("failed to start LocalStack: %w", err)
126126
}
127127

128128
output.EmitStatus(sink, "waiting", c.Name, "")
129129
healthURL := fmt.Sprintf("http://localhost:%s%s", c.Port, c.HealthPath)
130-
if err := awaitStartup(ctx, rt, sink, containerID, c.Name, healthURL); err != nil {
130+
if err := awaitStartup(ctx, rt, sink, containerID, "LocalStack", healthURL); err != nil {
131131
return err
132132
}
133133

@@ -144,7 +144,7 @@ func selectContainersToStart(ctx context.Context, rt runtime.Runtime, sink outpu
144144
return nil, fmt.Errorf("failed to check container status: %w", err)
145145
}
146146
if running {
147-
output.EmitInfo(sink, fmt.Sprintf("%s is already running", c.Name))
147+
output.EmitInfo(sink, "LocalStack is already running")
148148
continue
149149
}
150150
if err := ports.CheckAvailable(c.Port); err != nil {

internal/container/stop.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@ func Stop(ctx context.Context, rt runtime.Runtime, onProgress func(string)) erro
1616
}
1717

1818
for _, c := range cfg.Containers {
19-
name := c.Name()
20-
onProgress(fmt.Sprintf("Stopping %s...", name))
21-
if err := rt.Stop(ctx, name); err != nil {
19+
onProgress("Stopping LocalStack...")
20+
if err := rt.Stop(ctx, c.Name()); err != nil {
2221
if errdefs.IsNotFound(err) {
23-
return fmt.Errorf("%s is not running", name)
22+
return fmt.Errorf("LocalStack is not running")
2423
}
25-
return fmt.Errorf("failed to stop %s: %w", name, err)
24+
return fmt.Errorf("failed to stop LocalStack: %w", err)
2625
}
27-
onProgress(fmt.Sprintf("%s stopped", name))
26+
onProgress("LocalStack stopped")
2827
}
2928

3029
return nil

internal/output/plain_format.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ func FormatEventLine(event any) (string, bool) {
3333
func formatStatusLine(e ContainerStatusEvent) string {
3434
switch e.Phase {
3535
case "pulling":
36-
return fmt.Sprintf("Pulling %s...", e.Container)
36+
return "Pulling container..."
3737
case "starting":
38-
return fmt.Sprintf("Starting %s...", e.Container)
38+
return "Starting LocalStack..."
3939
case "waiting":
40-
return fmt.Sprintf("Waiting for %s to be ready...", e.Container)
40+
return "Waiting for LocalStack to be ready..."
4141
case "ready":
4242
if e.Detail != "" {
43-
return fmt.Sprintf("%s ready (%s)", e.Container, e.Detail)
43+
return fmt.Sprintf("LocalStack ready (%s)", e.Detail)
4444
}
45-
return fmt.Sprintf("%s ready", e.Container)
45+
return "LocalStack ready"
4646
default:
4747
if e.Detail != "" {
48-
return fmt.Sprintf("%s: %s (%s)", e.Container, e.Phase, e.Detail)
48+
return fmt.Sprintf("LocalStack: %s (%s)", e.Phase, e.Detail)
4949
}
50-
return fmt.Sprintf("%s: %s", e.Container, e.Phase)
50+
return fmt.Sprintf("LocalStack: %s", e.Phase)
5151
}
5252
}
5353

internal/output/plain_format_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ func TestFormatEventLine(t *testing.T) {
3737
},
3838
{
3939
name: "status pulling",
40-
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack:latest"},
41-
want: "Pulling localstack/localstack:latest...",
40+
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack-pro:latest"},
41+
want: "Pulling container...",
4242
wantOK: true,
4343
},
4444
{
4545
name: "status ready with detail",
46-
event: ContainerStatusEvent{Phase: "ready", Container: "localstack", Detail: "abc123"},
47-
want: "localstack ready (abc123)",
46+
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
47+
want: "LocalStack ready (abc123)",
4848
wantOK: true,
4949
},
5050
{

internal/output/plain_sink_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,38 @@ func TestPlainSink_EmitsStatusEvent(t *testing.T) {
4343
}{
4444
{
4545
name: "pulling phase",
46-
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack:latest"},
47-
expected: "Pulling localstack/localstack:latest...\n",
46+
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack-pro:latest"},
47+
expected: "Pulling container...\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)