Copy copies the specified folder to the container
(ctx context.Context, pod *k8sv1.Pod, container, containerPath, localPath string, exclude []string)
| 34 | |
| 35 | // Copy copies the specified folder to the container |
| 36 | func (client *client) Copy(ctx context.Context, pod *k8sv1.Pod, container, containerPath, localPath string, exclude []string) error { |
| 37 | // do the actual copy |
| 38 | reader, writer := io.Pipe() |
| 39 | errorChan := make(chan error) |
| 40 | go func() { |
| 41 | defer reader.Close() |
| 42 | errorChan <- client.CopyFromReader(ctx, pod, container, containerPath, reader) |
| 43 | }() |
| 44 | go func() { |
| 45 | defer writer.Close() |
| 46 | errorChan <- writeTar(writer, localPath, exclude) |
| 47 | }() |
| 48 | err := <-errorChan |
| 49 | // wait for the second goroutine to finish |
| 50 | <-errorChan |
| 51 | return err |
| 52 | } |
| 53 | |
| 54 | func writeTar(writer io.Writer, localPath string, exclude []string) error { |
| 55 | absolute, err := filepath.Abs(localPath) |
nothing calls this directly
no test coverage detected