| 707 | } |
| 708 | |
| 709 | func (cr *containerReference) CopyTarStream(ctx context.Context, destPath string, tarStream io.Reader) error { |
| 710 | if common.Dryrun(ctx) { |
| 711 | return nil |
| 712 | } |
| 713 | // Mkdir |
| 714 | buf := &bytes.Buffer{} |
| 715 | tw := tar.NewWriter(buf) |
| 716 | _ = tw.WriteHeader(&tar.Header{ |
| 717 | Name: destPath, |
| 718 | Mode: 0o777, |
| 719 | Typeflag: tar.TypeDir, |
| 720 | }) |
| 721 | tw.Close() |
| 722 | _, err := cr.cli.CopyToContainer(ctx, cr.id, client.CopyToContainerOptions{DestinationPath: "/", Content: buf}) |
| 723 | if err != nil { |
| 724 | return fmt.Errorf("failed to mkdir to copy content to container: %w", err) |
| 725 | } |
| 726 | // Copy Content |
| 727 | _, err = cr.cli.CopyToContainer(ctx, cr.id, client.CopyToContainerOptions{DestinationPath: destPath, Content: tarStream}) |
| 728 | if err != nil { |
| 729 | return fmt.Errorf("failed to copy content to container: %w", err) |
| 730 | } |
| 731 | // If this fails, then folders have wrong permissions on non root container |
| 732 | if cr.UID != 0 || cr.GID != 0 { |
| 733 | _ = cr.Exec([]string{"chown", "-R", fmt.Sprintf("%d:%d", cr.UID, cr.GID), destPath}, nil, "0", "")(ctx) |
| 734 | } |
| 735 | return nil |
| 736 | } |
| 737 | |
| 738 | func (cr *containerReference) copyDir(dstPath string, srcPath string, useGitIgnore bool) common.Executor { |
| 739 | return func(ctx context.Context) error { |