(ctx context.Context, client kubectl.Client, pod *v1.Pod, container, containerPath string, reader io.Reader)
| 74 | } |
| 75 | |
| 76 | func uploadFromReader(ctx context.Context, client kubectl.Client, pod *v1.Pod, container, containerPath string, reader io.Reader) error { |
| 77 | cmd := []string{"tar", "xzp"} |
| 78 | destDir := path.Dir(containerPath) |
| 79 | if len(destDir) > 0 { |
| 80 | cmd = append(cmd, "-C", destDir) |
| 81 | } |
| 82 | |
| 83 | _, stderr, err := client.ExecBuffered(ctx, pod, container, cmd, reader) |
| 84 | if err != nil { |
| 85 | if stderr != nil { |
| 86 | return errors.Errorf("error executing tar: %s: %v", string(stderr), err) |
| 87 | } |
| 88 | |
| 89 | return errors.Wrap(err, "exec") |
| 90 | } |
| 91 | |
| 92 | return nil |
| 93 | } |
| 94 | |
| 95 | func makeTar(srcPath, destPath string, writer io.Writer) error { |
| 96 | gw := gzip.NewWriter(writer) |
no test coverage detected