Skip to content

Commit 940bd16

Browse files
committed
Drop 'snapshot' subcommand in favor of simplicity
1 parent cc8b494 commit 940bd16

3 files changed

Lines changed: 26 additions & 35 deletions

File tree

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func NewRootCmd(cfg *env.Env, tel *telemetry.Client, logger log.Logger) *cobra.C
7272
newUpdateCmd(cfg),
7373
newDocsCmd(),
7474
newAWSCmd(cfg),
75-
newSnapshotCmd(cfg),
75+
newSnapshotSaveCmd(cfg),
7676
)
7777

7878
return root

cmd/snapshot.go

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,17 @@ import (
1515
"github.com/spf13/cobra"
1616
)
1717

18-
func newSnapshotCmd(cfg *env.Env) *cobra.Command {
19-
cmd := &cobra.Command{
20-
Use: "snapshot",
21-
Short: "Manage emulator snapshots",
22-
}
23-
cmd.AddCommand(newSnapshotSaveCmd(cfg))
24-
return cmd
25-
}
26-
2718
func newSnapshotSaveCmd(cfg *env.Env) *cobra.Command {
2819
return &cobra.Command{
2920
Use: "save [destination]",
30-
Short: "Save a snapshot of the emulator state",
31-
Long: `Save a snapshot of the running emulator's state to a local file.
21+
Short: "Save emulator state to a file",
22+
Long: `Save the running emulator's state to a local file.
3223
3324
The destination must be a file path. Use a path prefix to save locally:
3425
35-
lstk snapshot save # saves to ./ls-state-export
36-
lstk snapshot save ./my-snapshot # saves to ./my-snapshot
37-
lstk snapshot save /tmp/my-state # saves to /tmp/my-state
26+
lstk save # saves to ./ls-state-export
27+
lstk save ./my-snapshot # saves to ./my-snapshot
28+
lstk save /tmp/my-state # saves to /tmp/my-state
3829
3930
Cloud destinations are not yet supported.`,
4031
Args: cobra.MaximumNArgs(1),
@@ -62,7 +53,7 @@ Cloud destinations are not yet supported.`,
6253
return c.Type != config.EmulatorAWS
6354
})
6455
if !hasAWS && hasOther {
65-
return fmt.Errorf("snapshot is only supported for the AWS emulator")
56+
return fmt.Errorf("save is only supported for the AWS emulator")
6657
}
6758

6859
rt, err := runtime.NewDockerRuntime(cfg.DockerHost)

test/integration/snapshot_save_test.go

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ func TestSnapshotSaveDefaultDestination(t *testing.T) {
5656

5757
stdout, stderr, err := runLstk(t, ctx, dir,
5858
env.With(env.LocalStackHost, lsHost(srv)),
59-
"--non-interactive", "snapshot", "save",
59+
"--non-interactive", "save",
6060
)
61-
require.NoError(t, err, "lstk snapshot save failed: %s", stderr)
61+
require.NoError(t, err, "lstk save failed: %s", stderr)
6262
assert.Contains(t, stdout, "Snapshot saved")
6363

6464
_, statErr := os.Stat(filepath.Join(dir, "ls-state-export"))
@@ -78,9 +78,9 @@ func TestSnapshotSaveCustomPath(t *testing.T) {
7878

7979
stdout, stderr, err := runLstk(t, ctx, dir,
8080
env.With(env.LocalStackHost, lsHost(srv)),
81-
"--non-interactive", "snapshot", "save", outPath,
81+
"--non-interactive", "save", outPath,
8282
)
83-
require.NoError(t, err, "lstk snapshot save failed: %s", stderr)
83+
require.NoError(t, err, "lstk save failed: %s", stderr)
8484
assert.Contains(t, stdout, "Snapshot saved")
8585
assert.Contains(t, stdout, outPath)
8686

@@ -105,9 +105,9 @@ func TestSnapshotSaveRelativePath(t *testing.T) {
105105

106106
stdout, stderr, err := runLstk(t, ctx, dir,
107107
env.With(env.LocalStackHost, lsHost(srv)),
108-
"--non-interactive", "snapshot", "save", "./my-state",
108+
"--non-interactive", "save", "./my-state",
109109
)
110-
require.NoError(t, err, "lstk snapshot save failed: %s", stderr)
110+
require.NoError(t, err, "lstk save failed: %s", stderr)
111111
assert.Contains(t, stdout, "Snapshot saved")
112112

113113
_, statErr := os.Stat(filepath.Join(dir, "my-state"))
@@ -128,9 +128,9 @@ func TestSnapshotSaveOverwritesExistingFile(t *testing.T) {
128128

129129
_, stderr, err := runLstk(t, ctx, dir,
130130
env.With(env.LocalStackHost, lsHost(srv)),
131-
"--non-interactive", "snapshot", "save", outPath,
131+
"--non-interactive", "save", outPath,
132132
)
133-
require.NoError(t, err, "lstk snapshot save should overwrite: %s", stderr)
133+
require.NoError(t, err, "lstk save should overwrite: %s", stderr)
134134

135135
data, err := os.ReadFile(outPath)
136136
require.NoError(t, err)
@@ -143,7 +143,7 @@ func TestSnapshotSaveBareNameRejected(t *testing.T) {
143143
ctx := testContext(t)
144144
dir := t.TempDir()
145145

146-
_, stderr, err := runLstk(t, ctx, dir, nil, "--non-interactive", "snapshot", "save", "my-pod")
146+
_, stderr, err := runLstk(t, ctx, dir, nil, "--non-interactive", "save", "my-pod")
147147
requireExitCode(t, 1, err)
148148
assert.Contains(t, stderr, "not yet supported")
149149
assert.Contains(t, stderr, "./my-snapshot")
@@ -155,7 +155,7 @@ func TestSnapshotSaveCloudURIRejected(t *testing.T) {
155155
ctx := testContext(t)
156156
dir := t.TempDir()
157157

158-
_, stderr, err := runLstk(t, ctx, dir, nil, "--non-interactive", "snapshot", "save", "cloud://my-pod")
158+
_, stderr, err := runLstk(t, ctx, dir, nil, "--non-interactive", "save", "cloud://my-pod")
159159
requireExitCode(t, 1, err)
160160
assert.Contains(t, stderr, "not yet supported")
161161
}
@@ -169,7 +169,7 @@ func TestSnapshotSaveLocalStackNotRunning(t *testing.T) {
169169
// Intentionally no startTestContainer: the emulator is not running.
170170

171171
_, stderr, err := runLstk(t, ctx, t.TempDir(), nil,
172-
"--non-interactive", "snapshot", "save",
172+
"--non-interactive", "save",
173173
)
174174
requireExitCode(t, 1, err)
175175
assert.Contains(t, stderr, "not running")
@@ -186,7 +186,7 @@ func TestSnapshotSaveInvalidParentDir(t *testing.T) {
186186

187187
_, stderr, err := runLstk(t, ctx, t.TempDir(),
188188
env.With(env.LocalStackHost, lsHost(srv)),
189-
"--non-interactive", "snapshot", "save", "/no/such/dir/state",
189+
"--non-interactive", "save", "/no/such/dir/state",
190190
)
191191
requireExitCode(t, 1, err)
192192
assert.NotEmpty(t, stderr)
@@ -204,10 +204,10 @@ func TestSnapshotSaveTelemetryEmitted(t *testing.T) {
204204
analyticsSrv, events := mockAnalyticsServer(t)
205205
_, stderr, err := runLstk(t, ctx, t.TempDir(),
206206
env.With(env.LocalStackHost, lsHost(srv)).With(env.AnalyticsEndpoint, analyticsSrv.URL),
207-
"--non-interactive", "snapshot", "save",
207+
"--non-interactive", "save",
208208
)
209-
require.NoError(t, err, "lstk snapshot save failed: %s", stderr)
210-
assertCommandTelemetry(t, events, "snapshot save", 0)
209+
require.NoError(t, err, "lstk save failed: %s", stderr)
210+
assertCommandTelemetry(t, events, "save", 0)
211211
}
212212

213213
func TestSnapshotSaveTelemetryOnFailure(t *testing.T) {
@@ -221,10 +221,10 @@ func TestSnapshotSaveTelemetryOnFailure(t *testing.T) {
221221
analyticsSrv, events := mockAnalyticsServer(t)
222222
_, _, err := runLstk(t, ctx, t.TempDir(),
223223
env.With(env.AnalyticsEndpoint, analyticsSrv.URL),
224-
"--non-interactive", "snapshot", "save",
224+
"--non-interactive", "save",
225225
)
226226
requireExitCode(t, 1, err)
227-
assertCommandTelemetry(t, events, "snapshot save", 1)
227+
assertCommandTelemetry(t, events, "save", 1)
228228
}
229229

230230
func TestSnapshotSaveInteractive(t *testing.T) {
@@ -239,8 +239,8 @@ func TestSnapshotSaveInteractive(t *testing.T) {
239239

240240
out, err := runLstkInPTY(t, ctx,
241241
env.With(env.LocalStackHost, lsHost(srv)),
242-
"snapshot", "save", filepath.Join(dir, "snap"),
242+
"save", filepath.Join(dir, "snap"),
243243
)
244-
require.NoError(t, err, "interactive lstk snapshot save failed")
244+
require.NoError(t, err, "interactive lstk save failed")
245245
assert.Contains(t, out, "Snapshot saved")
246246
}

0 commit comments

Comments
 (0)