forked from cloudfoundry/bosh-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
compiled_package_applier_provider.go
84 lines (75 loc) · 2.46 KB
/
compiled_package_applier_provider.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package packages
import (
"path"
"os"
"code.cloudfoundry.org/clock"
boshbc "github.com/cloudfoundry/bosh-agent/agent/applier/bundlecollection"
"github.com/cloudfoundry/bosh-agent/agent/http_blob_provider/blobstore_delegator"
boshcmd "github.com/cloudfoundry/bosh-utils/fileutil"
boshlog "github.com/cloudfoundry/bosh-utils/logger"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)
type compiledPackageApplierProvider struct {
installPath string
rootEnablePath string
jobSpecificEnablePath string
name string
blobstore blobstore_delegator.BlobstoreDelegator
compressor boshcmd.Compressor
fs boshsys.FileSystem
timeProvider clock.Clock
logger boshlog.Logger
}
func NewCompiledPackageApplierProvider(
installPath, rootEnablePath, jobSpecificEnablePath, name string,
blobstore blobstore_delegator.BlobstoreDelegator,
compressor boshcmd.Compressor,
fs boshsys.FileSystem,
timeProvider clock.Clock,
logger boshlog.Logger,
) ApplierProvider {
return compiledPackageApplierProvider{
installPath: installPath,
rootEnablePath: rootEnablePath,
jobSpecificEnablePath: jobSpecificEnablePath,
name: name,
blobstore: blobstore,
compressor: compressor,
fs: fs,
timeProvider: timeProvider,
logger: logger,
}
}
// Root provides package applier that operates on system-wide packages.
// (e.g manages /var/vcap/packages/pkg-a -> /var/vcap/data/packages/pkg-a)
func (p compiledPackageApplierProvider) Root() Applier {
return NewCompiledPackageApplier(p.RootBundleCollection(), true, p.blobstore, p.fs, p.logger)
}
// JobSpecific provides package applier that operates on job-specific packages.
// (e.g manages /var/vcap/jobs/job-name/packages/pkg-a -> /var/vcap/data/packages/pkg-a)
func (p compiledPackageApplierProvider) JobSpecific(jobName string) Applier {
enablePath := path.Join(p.jobSpecificEnablePath, jobName)
packagesBc := boshbc.NewFileBundleCollection(
p.installPath,
enablePath,
p.name,
os.FileMode(0755),
p.fs,
p.timeProvider,
p.compressor,
p.logger,
)
return NewCompiledPackageApplier(packagesBc, false, p.blobstore, p.fs, p.logger)
}
func (p compiledPackageApplierProvider) RootBundleCollection() boshbc.BundleCollection {
return boshbc.NewFileBundleCollection(
p.installPath,
p.rootEnablePath,
p.name,
os.FileMode(0755),
p.fs,
p.timeProvider,
p.compressor,
p.logger,
)
}