Skip to content

Commit

Permalink
Add file mode to File
Browse files Browse the repository at this point in the history
  • Loading branch information
johanbrandhorst committed Dec 2, 2019
1 parent de1b8b1 commit bbcc212
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
8 changes: 6 additions & 2 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package podrick

import "io"
import (
"io"
"os"
)

// ContainerConfig is used by runtimes to start
// containers.
Expand All @@ -26,9 +29,10 @@ type Ulimit struct {
}

// File describes a file in a container.
// All fields are mandatory
// All fields are mandatory.
type File struct {
Content io.Reader
Path string
Size int
Mode os.FileMode
}
2 changes: 1 addition & 1 deletion runtimes/docker/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func uploadFiles(ctx context.Context, client *docker.Client, cID string, files .
}
err = archive.WriteHeader(&tar.Header{
Name: f.Path,
Mode: 0644,
Mode: int64(f.Mode),
Size: int64(f.Size),
})
if err != nil {
Expand Down
5 changes: 5 additions & 0 deletions runtimes/podman/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,10 @@ func uploadFile(ctx context.Context, mountDir string, file podrick.File) (err er
return fmt.Errorf("failed to copy file contents: %w", err)
}

err = os.Chmod(dest, file.Mode)
if err != nil {
return fmt.Errorf("failed to set file permissions: %w", err)
}

return nil
}

0 comments on commit bbcc212

Please sign in to comment.