MCPcopy
hub / github.com/kubernetes/kubectl / initReadFrom

Method initReadFrom

pkg/cmd/cp/cp.go:381–407  ·  view source on GitHub ↗
(n uint64)

Source from the content-addressed store, hash-verified

379}
380
381func (t *TarPipe) initReadFrom(n uint64) {
382 t.reader, t.outStream = io.Pipe()
383 options := &exec.ExecOptions{
384 StreamOptions: exec.StreamOptions{
385 IOStreams: genericiooptions.IOStreams{
386 In: nil,
387 Out: t.outStream,
388 ErrOut: t.o.Out,
389 },
390
391 Namespace: t.src.PodNamespace,
392 PodName: t.src.PodName,
393 },
394
395 Command: []string{"tar", "cf", "-", t.src.File.String()},
396 Executor: t.o.Executor,
397 }
398 if t.o.MaxTries != 0 {
399 escapedPath := strings.ReplaceAll(t.src.File.String(), "'", `'\''`)
400 options.Command = []string{"sh", "-c", fmt.Sprintf("tar cf - '%s' | tail -c+%d", escapedPath, n)}
401 }
402
403 go func() {
404 defer t.outStream.Close()
405 cmdutil.CheckErr(t.o.execute(options))
406 }()
407}
408
409func (t *TarPipe) Read(p []byte) (n int, err error) {
410 n, err = t.reader.Read(p)

Callers 2

ReadMethod · 0.95
newTarPipeFunction · 0.80

Calls 3

CloseMethod · 0.80
executeMethod · 0.80
StringMethod · 0.65

Tested by

no test coverage detected