本文整理汇总了Golang中github.com/cloudfoundry/bosh-utils/fileutil.NewTarballCompressor函数的典型用法代码示例。如果您正苦于以下问题:Golang NewTarballCompressor函数的具体用法?Golang NewTarballCompressor怎么用?Golang NewTarballCompressor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewTarballCompressor函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewWindowsPlatform
func NewWindowsPlatform(
collector boshstats.Collector,
fs boshsys.FileSystem,
cmdRunner boshsys.CmdRunner,
dirProvider boshdirs.Provider,
netManager boshnet.Manager,
certManager boshcert.Manager,
devicePathResolver boshdpresolv.DevicePathResolver,
logger boshlog.Logger,
defaultNetworkResolver boshsettings.DefaultNetworkResolver,
) Platform {
return &WindowsPlatform{
fs: fs,
cmdRunner: cmdRunner,
collector: collector,
compressor: boshcmd.NewTarballCompressor(cmdRunner, fs),
copier: boshcmd.NewGenericCpCopier(fs, logger),
dirProvider: dirProvider,
netManager: netManager,
devicePathResolver: devicePathResolver,
vitalsService: boshvitals.NewService(collector, dirProvider),
certManager: certManager,
defaultNetworkResolver: defaultNetworkResolver,
}
}
示例2: loadCompressor
func (f *factory) loadCompressor() boshcmd.Compressor {
if f.compressor != nil {
return f.compressor
}
f.compressor = boshcmd.NewTarballCompressor(f.loadCMDRunner(), f.fs)
return f.compressor
}
示例3: NewDummyPlatform
func NewDummyPlatform(
collector boshstats.Collector,
fs boshsys.FileSystem,
cmdRunner boshsys.CmdRunner,
dirProvider boshdirs.Provider,
devicePathResolver boshdpresolv.DevicePathResolver,
logger boshlog.Logger,
) Platform {
return &dummyPlatform{
fs: fs,
cmdRunner: cmdRunner,
collector: collector,
compressor: boshcmd.NewTarballCompressor(cmdRunner, fs),
copier: boshcmd.NewCpCopier(cmdRunner, fs, logger),
dirProvider: dirProvider,
devicePathResolver: devicePathResolver,
vitalsService: boshvitals.NewService(collector, dirProvider),
certManager: boshcert.NewDummyCertManager(fs, cmdRunner, 0, logger),
}
}
示例4: init
//.........这里部分代码省略.........
runner := fakesys.NewFakeCmdRunner()
dirProvider = boshdirs.NewProvider("/var/vcap/bosh")
linuxOptions := boshplatform.LinuxOptions{
CreatePartitionIfNoEphemeralDisk: true,
}
logger = boshlog.NewLogger(boshlog.LevelNone)
diskManager := fakedisk.NewFakeDiskManager()
diskManager.FakeMountsSearcher.SearchMountsMounts = []boshdisk.Mount{
{MountPoint: "/", PartitionPath: "rootfs"},
{MountPoint: "/", PartitionPath: "/dev/vda1"},
}
// for the GrowRootFS call to findRootDevicePath
runner.AddCmdResult(
"readlink -f /dev/vda1",
fakesys.FakeCmdResult{Stdout: "/dev/vda1"},
)
// for the createEphemeralPartitionsOnRootDevice call to findRootDevicePath
runner.AddCmdResult(
"readlink -f /dev/vda1",
fakesys.FakeCmdResult{Stdout: "/dev/vda1"},
)
diskManager.FakeRootDevicePartitioner.GetDeviceSizeInBytesSizes["/dev/vda"] = 1024 * 1024 * 1024
udev := boshudev.NewConcreteUdevDevice(runner, logger)
linuxCdrom := boshcdrom.NewLinuxCdrom("/dev/sr0", udev, runner)
linuxCdutil := boshcdrom.NewCdUtil(dirProvider.SettingsDir(), fs, linuxCdrom, logger)
compressor := boshcmd.NewTarballCompressor(runner, fs)
copier := boshcmd.NewCpCopier(runner, fs, logger)
sigarCollector := boshsigar.NewSigarStatsCollector(&sigar.ConcreteSigar{})
vitalsService := boshvitals.NewService(sigarCollector, dirProvider)
ipResolver := boship.NewResolver(boship.NetworkInterfaceToAddrsFunc)
arping := bosharp.NewArping(runner, fs, logger, boshplatform.ArpIterations, boshplatform.ArpIterationDelay, boshplatform.ArpInterfaceCheckDelay)
interfaceConfigurationCreator := boshnet.NewInterfaceConfigurationCreator(logger)
interfaceAddrsProvider = &fakeip.FakeInterfaceAddressesProvider{}
interfaceAddressesValidator := boship.NewInterfaceAddressesValidator(interfaceAddrsProvider)
dnsValidator := boshnet.NewDNSValidator(fs)
fs.WriteFileString("/etc/resolv.conf", "8.8.8.8 4.4.4.4")
ubuntuNetManager := boshnet.NewUbuntuNetManager(fs, runner, ipResolver, interfaceConfigurationCreator, interfaceAddressesValidator, dnsValidator, arping, logger)
ubuntuCertManager := boshcert.NewUbuntuCertManager(fs, runner, 1, logger)
monitRetryable := boshplatform.NewMonitRetryable(runner)
monitRetryStrategy := boshretry.NewAttemptRetryStrategy(10, 1*time.Second, monitRetryable, logger)
devicePathResolver := devicepathresolver.NewIdentityDevicePathResolver()
routesSearcher := boshnet.NewCmdRoutesSearcher(runner)
defaultNetworkResolver = boshnet.NewDefaultNetworkResolver(routesSearcher, ipResolver)
state, err := boshplatform.NewBootstrapState(fs, "/tmp/agent_state.json")
Expect(err).NotTo(HaveOccurred())
platform = boshplatform.NewLinuxPlatform(
fs,
runner,
示例5:
})
Describe("Compress", func() {
Context("with a real fs & compressor", func() {
var (
fs boshsys.FileSystem
cmdRunner boshsys.CmdRunner
compressor boshcmd.Compressor
)
BeforeEach(func() {
fs = boshsys.NewOsFileSystem(logger)
cmdRunner = boshsys.NewExecCmdRunner(logger)
compressor = boshcmd.NewTarballCompressor(cmdRunner, fs)
renderedJobListCompressor = NewRenderedJobListCompressor(fs, compressor, fakeSHA1Calculator, logger)
})
It("copies rendered jobs into a new temp dir, compresses the temp dir, and wraps it in a RenderedJobListArchive", func() {
// create rendered job with 2 rendered scripts
renderedJobDir0, err := fs.TempDir("RenderedJobListCompressorTest")
Expect(err).ToNot(HaveOccurred())
renderedJob0 := NewRenderedJob(bireljob.Job{Name: "fake-job-name-0"}, renderedJobDir0, fs, logger)
defer func() { err := renderedJob0.Delete(); Expect(err).ToNot(HaveOccurred()) }()
err = fs.WriteFileString(filepath.Join(renderedJobDir0, "script-0"), "fake-rendered-job-0-script-0-content")
Expect(err).ToNot(HaveOccurred())
err = fs.WriteFileString(filepath.Join(renderedJobDir0, "script-1"), "fake-rendered-job-0-script-1-content")
Expect(err).ToNot(HaveOccurred())
renderedJobList.Add(renderedJob0)
示例6:
var _ = Describe("An Agent running on Windows", func() {
var (
fs boshsys.FileSystem
natsClient *NatsClient
blobstoreClient utils.BlobClient
)
BeforeEach(func() {
message := fmt.Sprintf(`{"method":"ping","arguments":[],"reply_to":"%s"}`, senderID)
blobstoreClient = utils.NewBlobstore(blobstoreURI())
logger := boshlog.NewLogger(boshlog.LevelNone)
cmdRunner := boshsys.NewExecCmdRunner(logger)
fs = boshsys.NewOsFileSystem(logger)
compressor := boshfileutil.NewTarballCompressor(cmdRunner, fs)
natsClient = NewNatsClient(compressor, blobstoreClient)
err := natsClient.Setup()
Expect(err).NotTo(HaveOccurred())
testPing := func() (string, error) {
response, err := natsClient.SendRawMessage(message)
return string(response), err
}
Eventually(testPing, 30*time.Second, 1*time.Second).Should(Equal(`{"value":"pong"}`))
})
AfterEach(func() {
natsClient.Cleanup()
示例7: NewProvider
func NewProvider(logger boshlog.Logger, dirProvider boshdirs.Provider, statsCollector boshstats.Collector, fs boshsys.FileSystem, options Options, bootstrapState *BootstrapState, clock clock.Clock) Provider {
runner := boshsys.NewExecCmdRunner(logger)
linuxDiskManager := boshdisk.NewLinuxDiskManager(logger, runner, fs, options.Linux.BindMountPersistentDisk)
udev := boshudev.NewConcreteUdevDevice(runner, logger)
linuxCdrom := boshcdrom.NewLinuxCdrom("/dev/sr0", udev, runner)
linuxCdutil := boshcdrom.NewCdUtil(dirProvider.SettingsDir(), fs, linuxCdrom, logger)
compressor := boshcmd.NewTarballCompressor(runner, fs)
copier := boshcmd.NewCpCopier(runner, fs, logger)
// Kick of stats collection as soon as possible
statsCollector.StartCollecting(SigarStatsCollectionInterval, nil)
vitalsService := boshvitals.NewService(statsCollector, dirProvider)
ipResolver := boship.NewResolver(boship.NetworkInterfaceToAddrsFunc)
arping := bosharp.NewArping(runner, fs, logger, ArpIterations, ArpIterationDelay, ArpInterfaceCheckDelay)
interfaceConfigurationCreator := boshnet.NewInterfaceConfigurationCreator(logger)
interfaceAddressesProvider := boship.NewSystemInterfaceAddressesProvider()
interfaceAddressesValidator := boship.NewInterfaceAddressesValidator(interfaceAddressesProvider)
dnsValidator := boshnet.NewDNSValidator(fs)
centosNetManager := boshnet.NewCentosNetManager(fs, runner, ipResolver, interfaceConfigurationCreator, interfaceAddressesValidator, dnsValidator, arping, logger)
ubuntuNetManager := boshnet.NewUbuntuNetManager(fs, runner, ipResolver, interfaceConfigurationCreator, interfaceAddressesValidator, dnsValidator, arping, logger)
windowsNetManager := boshnet.NewWindowsNetManager(runner, interfaceConfigurationCreator, boshnet.NewMACAddressDetector(), logger, clock)
centosCertManager := boshcert.NewCentOSCertManager(fs, runner, 0, logger)
ubuntuCertManager := boshcert.NewUbuntuCertManager(fs, runner, 60, logger)
routesSearcher := boshnet.NewRoutesSearcher(runner)
defaultNetworkResolver := boshnet.NewDefaultNetworkResolver(routesSearcher, ipResolver)
monitRetryable := NewMonitRetryable(runner)
monitRetryStrategy := boshretry.NewAttemptRetryStrategy(10, 1*time.Second, monitRetryable, logger)
var devicePathResolver devicepathresolver.DevicePathResolver
switch options.Linux.DevicePathResolutionType {
case "virtio":
udev := boshudev.NewConcreteUdevDevice(runner, logger)
idDevicePathResolver := devicepathresolver.NewIDDevicePathResolver(500*time.Millisecond, options.Linux.VirtioDevicePrefix, udev, fs)
mappedDevicePathResolver := devicepathresolver.NewMappedDevicePathResolver(30000*time.Millisecond, fs)
devicePathResolver = devicepathresolver.NewVirtioDevicePathResolver(idDevicePathResolver, mappedDevicePathResolver, logger)
case "scsi":
scsiIDPathResolver := devicepathresolver.NewSCSIIDDevicePathResolver(50000*time.Millisecond, fs, logger)
scsiVolumeIDPathResolver := devicepathresolver.NewSCSIVolumeIDDevicePathResolver(500*time.Millisecond, fs)
scsiLunPathResolver := devicepathresolver.NewSCSILunDevicePathResolver(50000*time.Millisecond, fs, logger)
devicePathResolver = devicepathresolver.NewScsiDevicePathResolver(scsiVolumeIDPathResolver, scsiIDPathResolver, scsiLunPathResolver)
default:
devicePathResolver = devicepathresolver.NewIdentityDevicePathResolver()
}
uuidGenerator := boshuuid.NewGenerator()
centos := NewLinuxPlatform(
fs,
runner,
statsCollector,
compressor,
copier,
dirProvider,
vitalsService,
linuxCdutil,
linuxDiskManager,
centosNetManager,
centosCertManager,
monitRetryStrategy,
devicePathResolver,
bootstrapState,
options.Linux,
logger,
defaultNetworkResolver,
uuidGenerator,
)
ubuntu := NewLinuxPlatform(
fs,
runner,
statsCollector,
compressor,
copier,
dirProvider,
vitalsService,
linuxCdutil,
linuxDiskManager,
ubuntuNetManager,
ubuntuCertManager,
monitRetryStrategy,
devicePathResolver,
bootstrapState,
options.Linux,
logger,
defaultNetworkResolver,
uuidGenerator,
)
windows := NewWindowsPlatform(
//.........这里部分代码省略.........