コード例 #1
0
ファイル: aci.go プロジェクト: puckel/dgr
func (aci *Aci) tarAci(path string) error {
	tar := new(archivex.TarFile)
	if err := tar.Create(path + pathImageAci); err != nil {
		return errs.WithEF(err, aci.fields.WithField("path", path+pathImageAci), "Failed to create image tar")
	}
	if err := tar.AddFile(path + common.PathManifest); err != nil {
		return errs.WithEF(err, aci.fields.WithField("path", path+common.PathManifest), "Failed to add manifest to tar")
	}
	if err := tar.AddAll(path+common.PathRootfs, true); err != nil {
		return errs.WithEF(err, aci.fields.WithField("path", path+common.PathRootfs), "Failed to add rootfs to tar")
	}
	if err := tar.Close(); err != nil {
		return errs.WithEF(err, aci.fields.WithField("path", path), "Failed to tar aci")
	}
	os.Rename(path+pathImageAci+".tar", path+pathImageAci)
	return nil
}
コード例 #2
0
ファイル: folder.go プロジェクト: sunatthegilddotcom/decker
// Pack ...
func Pack(inputPath string, outputPath string) (fileName string, err error) {
	err = Check(inputPath)

	if err != nil {
		return
	}

	packageFile := path.Join(inputPath, PackageFileName)
	binFolder := path.Join(inputPath, BinFolder)

	pkg, err := LoadFile(packageFile)

	if err != nil {
		return
	}

	fileName = pkg.Name
	if pkg.Version != "" {
		fileName += "-" + pkg.Version
	}
	fileName += ".tar.gz"
	filePath := path.Join(outputPath, fileName)

	tar := new(archivex.TarFile)
	tar.Compressed = true

	if err = tar.Create(filePath); err != nil {
		return
	}

	defer tar.Close()

	if err = tar.AddFile(packageFile); err != nil {
		return
	}

	if err = tar.AddAll(binFolder, true); err != nil {
		return
	}

	return
}