本文整理匯總了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)
}