mirror of https://github.com/containers/podman.git
Dont save remote context in temp file but stream and extract
Signed-off-by: Garth Bushell <garth@garthy.com>
This commit is contained in:
parent
fcdff471da
commit
b2d0b92db2
|
@ -891,26 +891,12 @@ func parseLibPodIsolation(isolation string) (buildah.Isolation, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractTarFile(anchorDir string, r *http.Request) (string, error) {
|
func extractTarFile(anchorDir string, r *http.Request) (string, error) {
|
||||||
path := filepath.Join(anchorDir, "tarBall")
|
|
||||||
tarBall, err := os.OpenFile(path, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0o600)
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
defer tarBall.Close()
|
|
||||||
|
|
||||||
// Content-Length not used as too many existing API clients didn't honor it
|
|
||||||
_, err = io.Copy(tarBall, r.Body)
|
|
||||||
if err != nil {
|
|
||||||
return "", fmt.Errorf("failed Request: Unable to copy tar file from request body %s", r.RequestURI)
|
|
||||||
}
|
|
||||||
|
|
||||||
buildDir := filepath.Join(anchorDir, "build")
|
buildDir := filepath.Join(anchorDir, "build")
|
||||||
err = os.Mkdir(buildDir, 0o700)
|
err := os.Mkdir(buildDir, 0o700)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, _ = tarBall.Seek(0, 0)
|
err = archive.Untar(r.Body, buildDir, nil)
|
||||||
err = archive.Untar(tarBall, buildDir, nil)
|
|
||||||
return buildDir, err
|
return buildDir, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue