Skip to content

Commit

Permalink
Merge pull request #617 from rgooch/master
Browse files Browse the repository at this point in the history
Write /var/log/unpacked-image in image-unpacker.
  • Loading branch information
rgooch committed Jun 22, 2019
2 parents 39ad883 + b0de317 commit 0a9b45c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions imageunpacker/unpacker/unpackImage.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package unpacker

import (
"bytes"
"errors"
"fmt"
"io"
Expand Down Expand Up @@ -138,6 +139,7 @@ func (stream *streamManagerState) unpack(imageName string,
stream.unpacker.logger)
_, _, err = sublib.Update(request, mountPoint, objectsDir, nil, nil, nil,
stream.unpacker.logger)
writeImageName(imageName, mountPoint)
streamInfo.status = unpackproto.StatusStreamMounted
stream.unpacker.logger.Printf("Update(%s) completed in %s\n",
imageName, format.Duration(time.Since(startTime)))
Expand Down Expand Up @@ -286,3 +288,14 @@ func readOne(objectsDir string, hashVal hash.Hash, length uint64,
}
return fsutil.CopyToFile(filename, filePerms, reader, length)
}

func writeImageName(imageName, mountPoint string) {
dirname := filepath.Join(mountPoint, "var", "log")
if err := os.MkdirAll(dirname, fsutil.DirPerms); err != nil {
return
}
buffer := &bytes.Buffer{}
fmt.Fprintln(buffer, imageName)
fsutil.CopyToFile(filepath.Join(dirname, "unpacked-image"),
fsutil.PublicFilePerms, buffer, 0)
}

0 comments on commit 0a9b45c

Please sign in to comment.