MCPcopy Create free account
hub / github.com/docker/cli / Import

Function Import

cli/context/store/store.go:354–369  ·  view source on GitHub ↗

Import imports an exported context into a store

(name string, s Writer, reader io.Reader)

Source from the content-addressed store, hash-verified

352
353// Import imports an exported context into a store
354func Import(name string, s Writer, reader io.Reader) error {
355 // Buffered reader will not advance the buffer, needed to determine content type
356 r := bufio.NewReader(reader)
357
358 importContentType, err := getImportContentType(r)
359 if err != nil {
360 return err
361 }
362 switch importContentType {
363 case zipType:
364 return importZip(name, s, r)
365 default:
366 // Assume it's a TAR (TAR does not have a "magic number")
367 return importTar(name, s, r)
368 }
369}
370
371func isValidFilePath(p string) error {
372 if p != metaFile && !strings.HasPrefix(p, "tls/") {

Callers 4

TestExportImportFunction · 0.85
TestImportTarInvalidFunction · 0.85
TestImportZipFunction · 0.85
TestImportZipInvalidFunction · 0.85

Calls 3

getImportContentTypeFunction · 0.85
importZipFunction · 0.85
importTarFunction · 0.85

Tested by 4

TestExportImportFunction · 0.68
TestImportTarInvalidFunction · 0.68
TestImportZipFunction · 0.68
TestImportZipInvalidFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…