diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2020-12-23 04:47:54 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-23 04:47:54 -0500 |
commit | 06a6fd9f224adb8510e42691c261716ea2896ade (patch) | |
tree | 5a698612cbac29d6858b7815f181796872572e59 | |
parent | b41fa90a4c86df7fc8f14e814925dc5a330ddcf5 (diff) | |
parent | d61887037df6b7a4449b49145cdfd7941ab2d874 (diff) | |
download | podman-06a6fd9f224adb8510e42691c261716ea2896ade.tar.gz podman-06a6fd9f224adb8510e42691c261716ea2896ade.tar.bz2 podman-06a6fd9f224adb8510e42691c261716ea2896ade.zip |
Merge pull request #8810 from hshiina/logfile
Fix podman build --logfile
-rw-r--r-- | cmd/podman/images/build.go | 3 | ||||
-rw-r--r-- | test/system/070-build.bats | 17 |
2 files changed, 19 insertions, 1 deletions
diff --git a/cmd/podman/images/build.go b/cmd/podman/images/build.go index fbea1e3d8..3aca104e3 100644 --- a/cmd/podman/images/build.go +++ b/cmd/podman/images/build.go @@ -221,7 +221,8 @@ func build(cmd *cobra.Command, args []string) error { var logfile *os.File if cmd.Flag("logfile").Changed { - logfile, err := os.OpenFile(buildOpts.Logfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600) + var err error + logfile, err = os.OpenFile(buildOpts.Logfile, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0600) if err != nil { return err } diff --git a/test/system/070-build.bats b/test/system/070-build.bats index 8e9a2d613..048cf535d 100644 --- a/test/system/070-build.bats +++ b/test/system/070-build.bats @@ -424,6 +424,23 @@ EOF run_podman rmi -a --force } +@test "podman build --logfile test" { + tmpdir=$PODMAN_TMPDIR/build-test + mkdir -p $tmpdir + tmpbuilddir=$tmpdir/build + mkdir -p $tmpbuilddir + dockerfile=$tmpbuilddir/Dockerfile + cat >$dockerfile <<EOF +FROM $IMAGE +EOF + + run_podman build -t build_test --format=docker --logfile=$tmpdir/logfile $tmpbuilddir + run cat $tmpdir/logfile + is "$output" ".*STEP 2: COMMIT" "COMMIT seen in log" + + run_podman rmi -f build_test +} + function teardown() { # A timeout or other error in 'build' can leave behind stale images # that podman can't even see and which will cascade into subsequent |