MCPcopy
hub / github.com/basecamp/once / run

Method run

internal/command/restore.go:30–50  ·  view source on GitHub ↗

Private

(ctx context.Context, ns *docker.Namespace, cmd *cobra.Command, args []string)

Source from the content-addressed store, hash-verified

28// Private
29
30func (r *restoreCommand) run(ctx context.Context, ns *docker.Namespace, cmd *cobra.Command, args []string) error {
31 filename := args[0]
32
33 file, err := os.Open(filename)
34 if err != nil {
35 return fmt.Errorf("opening backup file: %w", err)
36 }
37 defer file.Close()
38
39 if err := ns.Setup(ctx); err != nil {
40 return fmt.Errorf("setting up namespace: %w", err)
41 }
42
43 app, err := ns.Restore(ctx, file)
44 if err != nil {
45 return fmt.Errorf("restoring application: %w", err)
46 }
47
48 fmt.Printf("Restored %s from %s\n", app.Settings.Name, filename)
49 return nil
50}

Callers

nothing calls this directly

Calls 3

SetupMethod · 0.80
CloseMethod · 0.45
RestoreMethod · 0.45

Tested by

no test coverage detected