MCPcopy Index your code
hub / github.com/devspace-sh/devspace / download

Function download

pkg/devspace/hook/download.go:59–81  ·  view source on GitHub ↗
(ctx context.Context, client kubectl.Client, pod *k8sv1.Pod, container string, localPath string, containerPath string, log logpkg.Logger)

Source from the content-addressed store, hash-verified

57}
58
59func download(ctx context.Context, client kubectl.Client, pod *k8sv1.Pod, container string, localPath string, containerPath string, log logpkg.Logger) error {
60 prefix := getPrefix(containerPath)
61 prefix = path.Clean(prefix)
62 // remove extraneous path shortcuts - these could occur if a path contained extra "../"
63 // and attempted to navigate beyond "/" in a remote filesystem
64 prefix = stripPathShortcuts(prefix)
65
66 // do the actual copy
67 reader, writer := io.Pipe()
68 errorChan := make(chan error)
69 go func() {
70 defer writer.Close()
71 errorChan <- downloadFromPod(ctx, client, pod, container, containerPath, writer)
72 }()
73 go func() {
74 defer reader.Close()
75 errorChan <- untarAll(reader, localPath, prefix, log)
76 }()
77 err := <-errorChan
78 // wait for the second goroutine to finish
79 <-errorChan
80 return err
81}
82
83func downloadFromPod(ctx context.Context, client kubectl.Client, pod *k8sv1.Pod, container, containerPath string, writer io.Writer) error {
84 stderr := &bytes.Buffer{}

Callers 1

ExecuteRemotelyMethod · 0.85

Calls 5

getPrefixFunction · 0.85
stripPathShortcutsFunction · 0.85
downloadFromPodFunction · 0.85
untarAllFunction · 0.70
CloseMethod · 0.65

Tested by

no test coverage detected