Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/container/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,12 @@ func startContainers(ctx context.Context, rt runtime.Runtime, sink output.Sink,
output.EmitStatus(sink, "starting", c.Name, "")
containerID, err := rt.Start(ctx, c)
if err != nil {
return fmt.Errorf("failed to start %s: %w", c.Name, err)
return fmt.Errorf("failed to start LocalStack: %w", err)
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: This code loops over all containers specified in the config. I know that we only support one container for launch, but the moment we want to support more the output will be confusing.
If someone adds a Snowflake or Azure container, all status messages will still say "LocalStack".
We could also use ProductName() which would read "localstack-pro" instead of "localstack-aws".
I am fine with ignoring this problem for now, just wanted to make you aware of it 🙂

}

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

Expand All @@ -144,7 +144,7 @@ func selectContainersToStart(ctx context.Context, rt runtime.Runtime, sink outpu
return nil, fmt.Errorf("failed to check container status: %w", err)
}
if running {
output.EmitInfo(sink, fmt.Sprintf("%s is already running", c.Name))
output.EmitInfo(sink, "LocalStack is already running")
continue
}
if err := ports.CheckAvailable(c.Port); err != nil {
Expand Down
11 changes: 5 additions & 6 deletions internal/container/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@ func Stop(ctx context.Context, rt runtime.Runtime, onProgress func(string)) erro
}

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

return nil
Expand Down
14 changes: 7 additions & 7 deletions internal/output/plain_format.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ func FormatEventLine(event any) (string, bool) {
func formatStatusLine(e ContainerStatusEvent) string {
switch e.Phase {
case "pulling":
return fmt.Sprintf("Pulling %s...", e.Container)
return "Preparing LocalStack..."
case "starting":
return fmt.Sprintf("Starting %s...", e.Container)
return "Starting LocalStack..."
case "waiting":
return fmt.Sprintf("Waiting for %s to be ready...", e.Container)
return "Waiting for LocalStack to be ready..."
case "ready":
if e.Detail != "" {
return fmt.Sprintf("%s ready (%s)", e.Container, e.Detail)
return fmt.Sprintf("LocalStack ready (%s)", e.Detail)
}
return fmt.Sprintf("%s ready", e.Container)
return "LocalStack ready"
default:
if e.Detail != "" {
return fmt.Sprintf("%s: %s (%s)", e.Container, e.Phase, e.Detail)
return fmt.Sprintf("LocalStack: %s (%s)", e.Phase, e.Detail)
}
return fmt.Sprintf("%s: %s", e.Container, e.Phase)
return fmt.Sprintf("LocalStack: %s", e.Phase)
}
}

Expand Down
8 changes: 4 additions & 4 deletions internal/output/plain_format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ func TestFormatEventLine(t *testing.T) {
},
{
name: "status pulling",
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack:latest"},
want: "Pulling localstack/localstack:latest...",
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack-pro:latest"},
want: "Preparing LocalStack...",
wantOK: true,
},
{
name: "status ready with detail",
event: ContainerStatusEvent{Phase: "ready", Container: "localstack", Detail: "abc123"},
want: "localstack ready (abc123)",
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
want: "LocalStack ready (abc123)",
wantOK: true,
},
{
Expand Down
28 changes: 14 additions & 14 deletions internal/output/plain_sink_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,38 +43,38 @@ func TestPlainSink_EmitsStatusEvent(t *testing.T) {
}{
{
name: "pulling phase",
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack:latest"},
expected: "Pulling localstack/localstack:latest...\n",
event: ContainerStatusEvent{Phase: "pulling", Container: "localstack/localstack-pro:latest"},
expected: "Preparing LocalStack...\n",
},
{
name: "starting phase",
event: ContainerStatusEvent{Phase: "starting", Container: "localstack"},
expected: "Starting localstack...\n",
event: ContainerStatusEvent{Phase: "starting", Container: "localstack-aws"},
expected: "Starting LocalStack...\n",
},
{
name: "waiting phase",
event: ContainerStatusEvent{Phase: "waiting", Container: "localstack"},
expected: "Waiting for localstack to be ready...\n",
event: ContainerStatusEvent{Phase: "waiting", Container: "localstack-aws"},
expected: "Waiting for LocalStack to be ready...\n",
},
{
name: "ready phase with detail",
event: ContainerStatusEvent{Phase: "ready", Container: "localstack", Detail: "abc123"},
expected: "localstack ready (abc123)\n",
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws", Detail: "abc123"},
expected: "LocalStack ready (abc123)\n",
},
{
name: "ready phase without detail",
event: ContainerStatusEvent{Phase: "ready", Container: "localstack"},
expected: "localstack ready\n",
event: ContainerStatusEvent{Phase: "ready", Container: "localstack-aws"},
expected: "LocalStack ready\n",
},
{
name: "unknown phase with detail",
event: ContainerStatusEvent{Phase: "custom", Container: "localstack", Detail: "info"},
expected: "localstack: custom (info)\n",
event: ContainerStatusEvent{Phase: "custom", Container: "localstack-aws", Detail: "info"},
expected: "LocalStack: custom (info)\n",
},
{
name: "unknown phase without detail",
event: ContainerStatusEvent{Phase: "custom", Container: "localstack"},
expected: "localstack: custom\n",
event: ContainerStatusEvent{Phase: "custom", Container: "localstack-aws"},
expected: "LocalStack: custom\n",
},
}

Expand Down