本文整理汇总了Golang中github.com/openshift/source-to-image/pkg/tar.Tar.ExtractTarStreamWithLogging方法的典型用法代码示例。如果您正苦于以下问题:Golang Tar.ExtractTarStreamWithLogging方法的具体用法?Golang Tar.ExtractTarStreamWithLogging怎么用?Golang Tar.ExtractTarStreamWithLogging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/openshift/source-to-image/pkg/tar.Tar
的用法示例。
在下文中一共展示了Tar.ExtractTarStreamWithLogging方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: copyImageSource
func copyImageSource(dockerClient DockerClient, containerID, sourceDir, destDir string, tarHelper tar.Tar) error {
// Setup destination directory
fi, err := os.Stat(destDir)
if err != nil {
if !os.IsNotExist(err) {
return err
}
glog.V(4).Infof("Creating image destination directory: %s", destDir)
err := os.MkdirAll(destDir, 0644)
if err != nil {
return err
}
} else {
if !fi.IsDir() {
return fmt.Errorf("destination %s must be a directory", destDir)
}
}
tempFile, err := ioutil.TempFile("", "imgsrc")
if err != nil {
return err
}
glog.V(4).Infof("Downloading source from path %s in container %s to temporary archive %s", sourceDir, containerID, tempFile.Name())
err = dockerClient.DownloadFromContainer(containerID, docker.DownloadFromContainerOptions{
OutputStream: tempFile,
Path: sourceDir,
})
if err != nil {
tempFile.Close()
return err
}
if err := tempFile.Close(); err != nil {
return err
}
// Extract the created tar file to the destination directory
file, err := os.Open(tempFile.Name())
if err != nil {
return err
}
defer file.Close()
glog.V(4).Infof("Extracting temporary tar %s to directory %s", tempFile.Name(), destDir)
var tarOutput io.Writer
if glog.Is(4) {
tarOutput = os.Stdout
}
return tarHelper.ExtractTarStreamWithLogging(destDir, file, tarOutput)
}
示例2: untarLocal
func untarLocal(tar tar.Tar, destinationDir string, r io.Reader, quiet bool, logger io.Writer) error {
glog.V(4).Infof("Extracting tar locally to %s", destinationDir)
if quiet {
return tar.ExtractTarStream(destinationDir, r)
}
return tar.ExtractTarStreamWithLogging(destinationDir, r, logger)
}