diff --git a/cmd/status.go b/cmd/status.go index 893df4938..af6eb11a5 100644 --- a/cmd/status.go +++ b/cmd/status.go @@ -21,8 +21,8 @@ import ( func newStatusCmd(cfg *env.Env) *cobra.Command { cmd := &cobra.Command{ Use: "status", - Short: "Show emulator status and deployed resources", - Long: "Show the status of a running emulator and its deployed resources", + Short: "Show emulator status", + Long: "Show the status of a running emulator. Use --resources to also list its deployed resources.", PreRunE: initConfigDeferCreate(nil), Annotations: map[string]string{jsonSupportedAnnotation: "true"}, RunE: func(cmd *cobra.Command, args []string) error { @@ -39,9 +39,12 @@ func newStatusCmd(cfg *env.Env) *cobra.Command { return err } + includeResources, err := cmd.Flags().GetBool("resources") + if err != nil { + return err + } + if cfg.JSON { - noResources, _ := cmd.Flags().GetBool("no-resources") - includeResources := !noResources if target != nil { return container.StatusExternalJSON(cmd.Context(), target, clients, sink, includeResources) } @@ -59,9 +62,9 @@ func newStatusCmd(cfg *env.Env) *cobra.Command { if target != nil { if isInteractiveMode(cfg) { - return ui.RunStatusExternal(cmd.Context(), target, clients) + return ui.RunStatusExternal(cmd.Context(), target, clients, includeResources) } - return container.StatusExternal(cmd.Context(), target, clients, output.NewPlainSink(os.Stdout)) + return container.StatusExternal(cmd.Context(), target, clients, output.NewPlainSink(os.Stdout), includeResources) } rt, err := runtime.NewDockerRuntime(cfg.DockerHost) @@ -74,11 +77,15 @@ func newStatusCmd(cfg *env.Env) *cobra.Command { } if isInteractiveMode(cfg) { - return ui.RunStatus(cmd.Context(), rt, appCfg.Containers, cfg.LocalStackHost, clients) + return ui.RunStatus(cmd.Context(), rt, appCfg.Containers, cfg.LocalStackHost, clients, includeResources) } - return container.Status(cmd.Context(), rt, appCfg.Containers, cfg.LocalStackHost, clients, output.NewPlainSink(os.Stdout)) + return container.Status(cmd.Context(), rt, appCfg.Containers, cfg.LocalStackHost, clients, output.NewPlainSink(os.Stdout), includeResources) }, } - cmd.Flags().Bool("no-resources", false, "Exclude deployed resource details (--json only)") + cmd.Flags().Bool("resources", false, "Include deployed resources (AWS only)") + // Excluding resources is the default; the flag stays for callers that pass it, such as the VS Code extension. + cmd.Flags().Bool("no-resources", false, "Exclude deployed resources") + cmd.Flags().Lookup("no-resources").Hidden = true + cmd.MarkFlagsMutuallyExclusive("resources", "no-resources") return cmd } diff --git a/docs/structured-output.md b/docs/structured-output.md index cafd8d5e8..98a3ad0a1 100644 --- a/docs/structured-output.md +++ b/docs/structured-output.md @@ -292,7 +292,7 @@ Codes: `NETWORK_ERROR` (GitHub API unreachable), `UPDATE_EXTERNALLY_MANAGED` (th ``` Codes: `RUNTIME_UNAVAILABLE`, `AUTH_REQUIRED`, `LICENSE_INVALID` (bad/expired/rejected token), `LICENSE_NOT_COVERED` (valid token, plan doesn't include the requested emulator), `IMAGE_PULL_FAILED`, `EMULATOR_START_FAILED` (crash or timeout waiting for health), `EMULATOR_WRONG_TYPE` (a different emulator type is already running on the configured port), `PORT_CONFLICT`, `CONFIG_INVALID` (more than one `[[containers]]` block enabled). -**`lstk status`** — one entry per configured emulator. Stops at the first not-running emulator and returns `EMULATOR_NOT_RUNNING`, same as plain text and same as `stop`/`reset`. Deployed resources (AWS only) are included by default, matching plain text; `--no-resources` drops `resourceSummary`/`resources` for a faster response, useful for a caller that polls this command repeatedly (e.g. `lstk start`'s readiness check). +**`lstk status`** — one entry per configured emulator. Stops at the first not-running emulator and returns `EMULATOR_NOT_RUNNING`, same as plain text and same as `stop`/`reset`. Deployed resources (AWS only) are left out by default, matching plain text, and are not fetched at all, which keeps the command fast for a caller that polls it. `--resources` adds `resourceSummary`/`resources` (shown below). `--no-resources` is still accepted for callers that pass it, and is the same as the default. ```json { "schemaVersion": 1, diff --git a/internal/container/status.go b/internal/container/status.go index 0e6b73133..3327db9bd 100644 --- a/internal/container/status.go +++ b/internal/container/status.go @@ -15,7 +15,7 @@ import ( const statusTimeout = 10 * time.Second -func Status(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, localStackHost string, clients map[config.EmulatorType]emulator.Client, sink output.Sink) error { +func Status(ctx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, localStackHost string, clients map[config.EmulatorType]emulator.Client, sink output.Sink, includeResources bool) error { if err := rt.IsHealthy(ctx); err != nil { rt.EmitUnhealthyError(sink, err) return output.NewSilentError(fmt.Errorf("runtime not healthy: %w", err)) @@ -66,7 +66,9 @@ func Status(ctx context.Context, rt runtime.Runtime, containers []config.Contain } var fetchErr error - rows, fetchErr = client.FetchResources(ctx, baseURL) + if includeResources { + rows, fetchErr = client.FetchResources(ctx, baseURL) + } sink.Emit(output.SpinnerStop()) if fetchErr != nil { return fetchErr @@ -82,7 +84,7 @@ func Status(ctx context.Context, rt runtime.Runtime, containers []config.Contain Persistence: c.Type == config.EmulatorAWS && isPersistenceEnabled(ctx, rt, name), }) - if c.Type == config.EmulatorAWS { + if includeResources && c.Type == config.EmulatorAWS { emitResources(sink, rows) } } @@ -92,14 +94,14 @@ func Status(ctx context.Context, rt runtime.Runtime, containers []config.Contain // StatusExternal renders status for an externally-managed endpoint // (--endpoint-url/LSTK_ENDPOINT_URL/AWS_ENDPOINT_URL): reachability, detected -// type, reported version, and — for an AWS-typed target — deployed resources, -// without the Docker-derived facts (container name, uptime, persistence, bound +// type, reported version, and — for an AWS-typed target, when requested — +// deployed resources, without the Docker-derived facts (container name, uptime, persistence, bound // port) that don't exist for an emulator lstk didn't start. Deployed resources // are not Docker-derived (they're an ordinary emulator API call via // FetchResources, identical to Status above), so there's no reason to omit // them here. It emits the same events in the same order as Status, so both // paths render identically through whichever sink the caller picked. -func StatusExternal(ctx context.Context, target *endpoint.Target, clients map[config.EmulatorType]emulator.Client, sink output.Sink) error { +func StatusExternal(ctx context.Context, target *endpoint.Target, clients map[config.EmulatorType]emulator.Client, sink output.Sink, includeResources bool) error { var version string var rows []emulator.Resource if client, ok := clients[target.Type]; ok { @@ -111,7 +113,9 @@ func StatusExternal(ctx context.Context, target *endpoint.Target, clients map[co } var fetchErr error - rows, fetchErr = client.FetchResources(ctx, target.URL) + if includeResources { + rows, fetchErr = client.FetchResources(ctx, target.URL) + } sink.Emit(output.SpinnerStop()) if fetchErr != nil { return fetchErr @@ -124,7 +128,7 @@ func StatusExternal(ctx context.Context, target *endpoint.Target, clients map[co Host: target.URL, }) - if target.Type == config.EmulatorAWS { + if includeResources && target.Type == config.EmulatorAWS { emitResources(sink, rows) } diff --git a/internal/container/status_test.go b/internal/container/status_test.go index 7d0694d6f..9c85fe29d 100644 --- a/internal/container/status_test.go +++ b/internal/container/status_test.go @@ -23,7 +23,7 @@ func TestStatus_IsRunningError(t *testing.T) { containers := []config.ContainerConfig{{Type: config.EmulatorAWS}} sink := output.NewPlainSink(io.Discard) - err := Status(context.Background(), mockRT, containers, "", nil, sink) + err := Status(context.Background(), mockRT, containers, "", nil, sink, true) require.Error(t, err) assert.Contains(t, err.Error(), "docker unavailable") @@ -42,7 +42,7 @@ func TestStatus_MultipleContainers_StopsAtFirstNotRunning(t *testing.T) { } sink := output.NewPlainSink(io.Discard) - err := Status(context.Background(), mockRT, containers, "", nil, sink) + err := Status(context.Background(), mockRT, containers, "", nil, sink, true) require.Error(t, err) assert.True(t, output.IsSilent(err)) diff --git a/internal/container/tips/tips.go b/internal/container/tips/tips.go index 083ccd336..906ab2e60 100644 --- a/internal/container/tips/tips.go +++ b/internal/container/tips/tips.go @@ -100,7 +100,7 @@ func rotatingTips(t config.EmulatorType) []Tip { case config.EmulatorAWS: texts = []string{ "> Tip: View emulator logs: lstk logs --follow", - "> Tip: View deployed resources: lstk status", + "> Tip: View deployed resources: lstk status --resources", } case config.EmulatorSnowflake: texts = []string{ diff --git a/internal/ui/run_status.go b/internal/ui/run_status.go index 86bac8870..b7551b9e0 100644 --- a/internal/ui/run_status.go +++ b/internal/ui/run_status.go @@ -18,13 +18,13 @@ import ( // (--endpoint-url and friends). Targeting an emulator lstk didn't start // changes which facts are available, not how they're rendered, so the // interactive path stays the TUI here too. -func RunStatusExternal(parentCtx context.Context, target *endpoint.Target, clients map[config.EmulatorType]emulator.Client) error { +func RunStatusExternal(parentCtx context.Context, target *endpoint.Target, clients map[config.EmulatorType]emulator.Client, includeResources bool) error { return runWithTUI(parentCtx, withoutHeader(), func(ctx context.Context, sink output.Sink) error { - return container.StatusExternal(ctx, target, clients, sink) + return container.StatusExternal(ctx, target, clients, sink, includeResources) }) } -func RunStatus(parentCtx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, localStackHost string, clients map[config.EmulatorType]emulator.Client) error { +func RunStatus(parentCtx context.Context, rt runtime.Runtime, containers []config.ContainerConfig, localStackHost string, clients map[config.EmulatorType]emulator.Client, includeResources bool) error { ctx, cancel := context.WithCancel(parentCtx) defer cancel() @@ -33,7 +33,7 @@ func RunStatus(parentCtx context.Context, rt runtime.Runtime, containers []confi runErrCh := make(chan error, 1) go func() { - err := container.Status(ctx, rt, containers, localStackHost, clients, output.NewTUISink(programSender{p: p})) + err := container.Status(ctx, rt, containers, localStackHost, clients, output.NewTUISink(programSender{p: p}), includeResources) if err != nil && !errors.Is(err, context.Canceled) { p.Send(runErrMsg{err: err}) } else { diff --git a/openspec/specs/external-endpoint/spec.md b/openspec/specs/external-endpoint/spec.md index 8193987c2..ff1fdbd84 100644 --- a/openspec/specs/external-endpoint/spec.md +++ b/openspec/specs/external-endpoint/spec.md @@ -111,7 +111,7 @@ When an endpoint URL is resolved for `aws`, `az`, `terraform`/`tf`, `cdk`, `sam` ### Requirement: status reports reduced detail for externally-managed endpoints -When `lstk status` resolves an endpoint URL instead of a Docker-managed container, it SHALL report reachability, the detected emulator type and version reported by the endpoint's own health payload, and — for an AWS-typed target — deployed resources exactly as it does for a Docker-managed emulator: deployed resources are reported via the emulator's own `/_localstack/resources` API, not derived from Docker, so there is no reason to omit them. It SHALL NOT report Docker-derived facts (container uptime, image, bound port) that don't exist for an emulator lstk didn't start. +When `lstk status` resolves an endpoint URL instead of a Docker-managed container, it SHALL report reachability, the detected emulator type and version reported by the endpoint's own health payload, and — for an AWS-typed target, when `--resources` is passed — deployed resources exactly as it does for a Docker-managed emulator: deployed resources are reported via the emulator's own `/_localstack/resources` API, not derived from Docker, so there is no reason to omit them. It SHALL NOT report Docker-derived facts (container uptime, image, bound port) that don't exist for an emulator lstk didn't start. Targeting an external endpoint changes which facts are available, not how they are rendered: `status` SHALL select its output mode the same way as the Docker-managed path — the interactive TUI on a terminal, the plain sink otherwise — so styling and spacing are identical between the two paths. @@ -122,7 +122,7 @@ Targeting an external endpoint changes which facts are available, not how they a #### Scenario: Status for an externally-managed AWS endpoint reports deployed resources -- **WHEN** a user runs `lstk status --endpoint-url http://localhost:4566` against a reachable AWS-typed emulator with deployed resources +- **WHEN** a user runs `lstk status --resources --endpoint-url http://localhost:4566` against a reachable AWS-typed emulator with deployed resources - **THEN** the output includes the resource summary and table, the same as it would for a Docker-managed AWS emulator #### Scenario: Status for an externally-managed endpoint renders through the TUI on a terminal diff --git a/test/integration/__snapshots__/endpoint_url_https_test.snap b/test/integration/__snapshots__/endpoint_url_https_test.snap index 9978a6d70..57f1e0627 100644 --- a/test/integration/__snapshots__/endpoint_url_https_test.snap +++ b/test/integration/__snapshots__/endpoint_url_https_test.snap @@ -6,7 +6,6 @@ Fetching LocalStack status... ✔︎ LocalStack AWS Emulator is running • Endpoint: https://127.0.0.1: • Version: -> Note: No resources deployed --- [TestStatusEndpointURLHTTPSSchemeMismatchSuggestsHTTP_1] diff --git a/test/integration/__snapshots__/endpoint_url_test.snap b/test/integration/__snapshots__/endpoint_url_test.snap index 3b398f046..9f297614d 100644 --- a/test/integration/__snapshots__/endpoint_url_test.snap +++ b/test/integration/__snapshots__/endpoint_url_test.snap @@ -55,7 +55,6 @@ Fetching LocalStack status... ✔︎ LocalStack AWS Emulator is running • Endpoint: http://127.0.0.1: • Version: -> Note: No resources deployed --- [TestStatusEndpointURLShowsResources_1] diff --git a/test/integration/__snapshots__/extension_test.snap b/test/integration/__snapshots__/extension_test.snap index 7fc60b22c..680274686 100644 --- a/test/integration/__snapshots__/extension_test.snap +++ b/test/integration/__snapshots__/extension_test.snap @@ -21,7 +21,7 @@ Commands: setup Set up emulator CLI integration snapshot Manage emulator snapshots start Start emulator - status Show emulator status and deployed resources + status Show emulator status stop Stop emulator update Update lstk to the latest version volume Manage emulator volume @@ -83,7 +83,7 @@ Commands: setup Set up emulator CLI integration snapshot Manage emulator snapshots start Start emulator - status Show emulator status and deployed resources + status Show emulator status stop Stop emulator update Update lstk to the latest version volume Manage emulator volume @@ -134,7 +134,7 @@ Commands: setup Set up emulator CLI integration snapshot Manage emulator snapshots start Start emulator - status Show emulator status and deployed resources + status Show emulator status stop Stop emulator update Update lstk to the latest version volume Manage emulator volume diff --git a/test/integration/endpoint_url_test.go b/test/integration/endpoint_url_test.go index aa4ca40ce..155fc04bd 100644 --- a/test/integration/endpoint_url_test.go +++ b/test/integration/endpoint_url_test.go @@ -285,7 +285,7 @@ func TestStatusEndpointURLShowsResources(t *testing.T) { e := env.With(env.DisableEvents, "1").WithHome(t.TempDir()) e = append(e, unreachableDockerHost) - stdout, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status") + stdout, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status", "--resources") require.NoError(t, err, "stderr: %s", stderr) snap.Match(t, sanitizeOutput(stdout)) } @@ -316,7 +316,7 @@ func TestStatusEndpointURLInteractiveRendersTUI(t *testing.T) { defer srv.Close() e := append(env.Environ(testEnvWithHome(t.TempDir(), "")).With(env.DisableEvents, "1"), unreachableDockerHost) - p := startLstkInPTY(t, testContext(t), e, "--endpoint-url", srv.URL, "status") + p := startLstkInPTY(t, testContext(t), e, "--endpoint-url", srv.URL, "status", "--resources") _, err := p.wait() require.NoError(t, err) diff --git a/test/integration/status_test.go b/test/integration/status_test.go index a8400bed9..4c2e363c3 100644 --- a/test/integration/status_test.go +++ b/test/integration/status_test.go @@ -10,6 +10,7 @@ import ( "net/http/httptest" "os" "path/filepath" + "sync/atomic" "testing" "github.com/aws/aws-sdk-go-v2/aws" @@ -67,7 +68,7 @@ func TestStatusCommandShowsResourcesWhenRunning(t *testing.T) { require.NoError(t, err, "failed to create SQS queue") analyticsSrv, events := mockAnalyticsServer(t) - stdout, stderr, err := runLstk(t, ctx, "", env.With(env.AnalyticsEndpoint, analyticsSrv.URL), "status") + stdout, stderr, err := runLstk(t, ctx, "", env.With(env.AnalyticsEndpoint, analyticsSrv.URL), "status", "--resources") require.NoError(t, err, "lstk status failed: %s", stderr) requireExitCode(t, 0, err) // Not a snapshot: this test needs a real auth token and a live emulator, @@ -229,7 +230,7 @@ func TestStatusCommandShowsNoResourcesWhenEmpty(t *testing.T) { })) defer server.Close() - stdout, stderr, err := runLstk(t, ctx, "", env.With(env.LocalStackHost, lsHost(server)), "status") + stdout, stderr, err := runLstk(t, ctx, "", env.With(env.LocalStackHost, lsHost(server)), "status", "--resources") require.NoError(t, err, "lstk status failed: %s", stderr) requireExitCode(t, 0, err) assert.Contains(t, stdout, "No resources deployed") @@ -287,8 +288,7 @@ func TestStatusCommandJSONRunning(t *testing.T) { assert.Equal(t, containerName, e.Name) assert.Equal(t, "4.14.1", e.Version) assert.NotEmpty(t, e.Host) - require.NotNil(t, e.ResourceSummary, "resources should be included by default") - assert.Equal(t, 0, e.ResourceSummary.Resources) + assert.Nil(t, e.ResourceSummary, "resources should be excluded by default") } func TestStatusCommandJSONNotRunning(t *testing.T) { @@ -395,8 +395,8 @@ func TestStatusCommandJSONExternalEndpointResources(t *testing.T) { e := env.With(env.DisableEvents, "1").WithHome(t.TempDir()) e = append(e, unreachableDockerHost) - stdout, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status", "--json") - require.NoError(t, err, "lstk status --json --endpoint-url failed: %s", stderr) + stdout, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status", "--json", "--resources") + require.NoError(t, err, "lstk status --json --resources --endpoint-url failed: %s", stderr) requireExitCode(t, 0, err) envelope := decodeEnvelope(t, stdout) @@ -418,6 +418,114 @@ func TestStatusCommandJSONExternalEndpointResources(t *testing.T) { assert.Equal(t, "my-test-bucket", data.Emulators[0].Resources[0].Name) } +func TestStatusHidesResourcesByDefault(t *testing.T) { + t.Parallel() + srv, resourceRequests := resourcesServer(t) + e := append(env.With(env.DisableEvents, "1").WithHome(t.TempDir()), unreachableDockerHost) + + stdout, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status") + require.NoError(t, err, "stderr: %s", stderr) + + assert.Contains(t, stdout, "is running") + assert.NotContains(t, stdout, "my-test-bucket") + assert.NotContains(t, stdout, "No resources deployed") + assert.Zero(t, resourceRequests.Load(), "status should only fetch resources with --resources") +} + +func TestStatusHidesResourcesByDefaultInTUI(t *testing.T) { + t.Parallel() + srv, resourceRequests := resourcesServer(t) + e := append(env.Environ(testEnvWithHome(t.TempDir(), "")).With(env.DisableEvents, "1"), unreachableDockerHost) + + out, err := runLstkInPTY(t, testContext(t), e, "--endpoint-url", srv.URL, "status") + require.NoError(t, err) + + assert.Contains(t, out, "is running") + assert.NotContains(t, out, "my-test-bucket") + assert.Zero(t, resourceRequests.Load(), "status should only fetch resources with --resources") +} + +func TestStatusCommandJSONHidesResourcesByDefault(t *testing.T) { + t.Parallel() + srv, resourceRequests := resourcesServer(t) + e := append(env.With(env.DisableEvents, "1").WithHome(t.TempDir()), unreachableDockerHost) + + stdout, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status", "--json") + require.NoError(t, err, "stderr: %s", stderr) + + var data struct { + Emulators []map[string]json.RawMessage `json:"emulators"` + } + require.NoError(t, json.Unmarshal(decodeEnvelope(t, stdout).Data, &data)) + require.Len(t, data.Emulators, 1) + assert.NotContains(t, data.Emulators[0], "resourceSummary") + assert.NotContains(t, data.Emulators[0], "resources") + assert.Zero(t, resourceRequests.Load(), "status --json should only fetch resources with --resources") +} + +func TestStatusRejectsResourcesWithNoResources(t *testing.T) { + t.Parallel() + srv, resourceRequests := resourcesServer(t) + e := append(env.With(env.DisableEvents, "1").WithHome(t.TempDir()), unreachableDockerHost) + + _, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status", "--resources", "--no-resources") + requireExitCode(t, 1, err) + assert.Contains(t, stderr, "[resources no-resources]") + assert.Zero(t, resourceRequests.Load()) +} + +// --no-resources is the default now; it stays accepted because callers such as +// the VS Code extension pass it. +func TestStatusNoResourcesFlagHidesResources(t *testing.T) { + t.Parallel() + srv, resourceRequests := resourcesServer(t) + e := append(env.With(env.DisableEvents, "1").WithHome(t.TempDir()), unreachableDockerHost) + + stdout, stderr, err := runLstk(t, testContext(t), t.TempDir(), e, "--endpoint-url", srv.URL, "status", "--no-resources") + require.NoError(t, err, "stderr: %s", stderr) + + assert.Contains(t, stdout, "is running") + assert.NotContains(t, stdout, "my-test-bucket") + assert.NotContains(t, stdout, "No resources deployed") + assert.Zero(t, resourceRequests.Load(), "--no-resources should not fetch resources") +} + +func TestStatusNoResourcesFlagHidesResourcesInTUI(t *testing.T) { + t.Parallel() + srv, resourceRequests := resourcesServer(t) + e := append(env.Environ(testEnvWithHome(t.TempDir(), "")).With(env.DisableEvents, "1"), unreachableDockerHost) + + out, err := runLstkInPTY(t, testContext(t), e, "--endpoint-url", srv.URL, "status", "--no-resources") + require.NoError(t, err) + + assert.Contains(t, out, "is running") + assert.NotContains(t, out, "my-test-bucket") + assert.NotContains(t, out, "No resources deployed") + assert.Zero(t, resourceRequests.Load(), "--no-resources should not fetch resources") +} + +// resourcesServer is a mock AWS emulator with one deployed bucket. The counter +// records how many times lstk asked it for resources. +func resourcesServer(t *testing.T) (*httptest.Server, *atomic.Int32) { + t.Helper() + var resourceRequests atomic.Int32 + srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case "/_localstack/health": + w.Header().Set("Content-Type", "application/json") + _, _ = fmt.Fprintln(w, `{"version": "3.0.2", "services": {"s3": "available"}}`) + case "/_localstack/resources": + resourceRequests.Add(1) + w.Header().Set("Content-Type", "application/x-ndjson") + _, _ = fmt.Fprintln(w, `{"AWS::S3::Bucket": [{"region_name": "us-east-1", "account_id": "000000000000", "id": "my-test-bucket"}]}`) + default: + w.WriteHeader(http.StatusNotFound) + } + })) + t.Cleanup(srv.Close) + return srv, &resourceRequests +} + func fetchSnowflakeVersion(t *testing.T, hostPort string) string { t.Helper() resp, err := http.Get(fmt.Sprintf("http://localhost:%s/_localstack/health", hostPort))