Skip to content

Commit

Permalink
Merge pull request #22120 from garthy/dont_stage_tarfile
Browse files Browse the repository at this point in the history
Dont save remote build context in temp file but stream and extract
  • Loading branch information
openshift-merge-bot[bot] authored Mar 22, 2024
2 parents aaa6dc3 + b2d0b92 commit 4f76c7a
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions pkg/api/handlers/compat/images_build.go
Original file line number Diff line number Diff line change
Expand Up @@ -900,26 +900,12 @@ func parseLibPodIsolation(isolation string) (buildah.Isolation, 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")
err = os.Mkdir(buildDir, 0o700)
err := os.Mkdir(buildDir, 0o700)
if err != nil {
return "", err
}

_, _ = tarBall.Seek(0, 0)
err = archive.Untar(tarBall, buildDir, nil)
err = archive.Untar(r.Body, buildDir, nil)
return buildDir, err
}

0 comments on commit 4f76c7a

Please sign in to comment.