MCPcopy Index your code
hub / github.com/docker/cli / runImport

Function runImport

cli/command/context/import.go:31–55  ·  view source on GitHub ↗

runImport imports a Docker context.

(dockerCLI command.Cli, name string, source string)

Source from the content-addressed store, hash-verified

29
30// runImport imports a Docker context.
31func runImport(dockerCLI command.Cli, name string, source string) error {
32 if err := checkContextNameForCreation(dockerCLI.ContextStore(), name); err != nil {
33 return err
34 }
35
36 var reader io.Reader
37 if source == "-" {
38 reader = dockerCLI.In()
39 } else {
40 f, err := os.Open(source)
41 if err != nil {
42 return err
43 }
44 defer f.Close()
45 reader = f
46 }
47
48 if err := store.Import(name, dockerCLI.ContextStore(), reader); err != nil {
49 return err
50 }
51
52 _, _ = fmt.Fprintln(dockerCLI.Out(), name)
53 _, _ = fmt.Fprintf(dockerCLI.Err(), "Successfully imported context %q\n", name)
54 return nil
55}

Callers 3

TestExportImportWithFileFunction · 0.70
TestExportImportPipeFunction · 0.70
newImportCommandFunction · 0.70

Calls 6

ContextStoreMethod · 0.65
InMethod · 0.65
OutMethod · 0.65
ErrMethod · 0.65
CloseMethod · 0.45

Tested by 2

TestExportImportWithFileFunction · 0.56
TestExportImportPipeFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…