本文整理汇总了Golang中github.com/docker/docker/pkg/archive.NewTempArchive函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTempArchive函数的具体用法?Golang NewTempArchive怎么用?Golang NewTempArchive使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTempArchive函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TempLayerArchive
// TempLayerArchive creates a temporary archive of the given image's filesystem layer.
// The archive is stored on disk and will be automatically deleted as soon as has been read.
// If output is not nil, a human-readable progress bar will be written to it.
func (graph *Graph) TempLayerArchive(id string, sf *streamformatter.StreamFormatter, output io.Writer) (*archive.TempArchive, error) {
image, err := graph.Get(id)
if err != nil {
return nil, err
}
tmp, err := graph.mktemp()
if err != nil {
return nil, err
}
defer os.RemoveAll(tmp)
a, err := graph.TarLayer(image)
if err != nil {
return nil, err
}
progressReader := progressreader.New(progressreader.Config{
In: a,
Out: output,
Formatter: sf,
Size: 0,
NewLines: false,
ID: stringid.TruncateID(id),
Action: "Buffering to disk",
})
defer progressReader.Close()
return archive.NewTempArchive(progressReader, tmp)
}
开发者ID:previousnext,项目名称:kube-ingress,代码行数:29,代码来源:graph.go
示例2: commitChanges
//krgo commit -r rootfs
//commit current changes in a new properly formated branch ready for pushing
func commitChanges(rootfs, message string) error {
if !isGitRepo(rootfs) {
return fmt.Errorf("%v not a git repository", rootfs)
}
gitRepo, _ := newGitRepo(rootfs)
layerData, err := gitRepo.exportUncommitedChangeSet()
if err != nil {
return err
}
defer layerData.Close()
//Load image data
image, err := image.LoadImage(gitRepo.Path) //reading json file in rootfs
if err != nil {
return err
}
//fill new infos
image.Parent = image.ID
image.ID = utils.GenerateRandomID()
image.Created = time.Now()
image.Comment = message
layer, err := archive.NewTempArchive(layerData, "")
if err != nil {
return err
}
image.Size = layer.Size
os.RemoveAll(layer.Name())
if err := image.SaveSize(rootfs); err != nil {
return err
}
jsonRaw, err := json.Marshal(image)
if err != nil {
return err
}
err = ioutil.WriteFile(path.Join(rootfs, "json"), jsonRaw, 0600)
if err != nil {
return err
}
//commit the changes in a new branch
n, _ := gitRepo.countBranch()
br := newBranch(n, image.ID)
if _, err = gitRepo.checkoutB(br); err != nil {
return err
}
if _, err := gitRepo.addAllAndCommit(message); err != nil {
return err
}
fmt.Printf("Changes commited in %v\n", br)
fmt.Printf("Image ID: %v\nParent: %v\nChecksum: %v\nLayer size: %v\n", image.ID, image.Parent, image.Size)
return nil
}
开发者ID:HowardMei,项目名称:krgo,代码行数:62,代码来源:commit.go
示例3: TempLayerArchive
// TempLayerArchive creates a temporary archive of the given image's filesystem layer.
// The archive is stored on disk and will be automatically deleted as soon as has been read.
// If output is not nil, a human-readable progress bar will be written to it.
// FIXME: does this belong in Graph? How about MktempFile, let the caller use it for archives?
func (graph *Graph) TempLayerArchive(id string, compression archive.Compression, sf *utils.StreamFormatter, output io.Writer) (*archive.TempArchive, error) {
image, err := graph.Get(id)
if err != nil {
return nil, err
}
tmp, err := graph.Mktemp("")
if err != nil {
return nil, err
}
a, err := image.TarLayer()
if err != nil {
return nil, err
}
progress := utils.ProgressReader(a, 0, output, sf, false, utils.TruncateID(id), "Buffering to disk")
defer progress.Close()
return archive.NewTempArchive(progress, tmp)
}
开发者ID:TencentSA,项目名称:docker-1.3,代码行数:21,代码来源:graph.go
注:本文中的github.com/docker/docker/pkg/archive.NewTempArchive函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论