-
Notifications
You must be signed in to change notification settings - Fork 161
/
provider.go
57 lines (45 loc) · 1.87 KB
/
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
package index
import (
"path/filepath"
boshblob "github.com/cloudfoundry/bosh-utils/blobstore"
boshsys "github.com/cloudfoundry/bosh-utils/system"
boshrel "github.com/cloudfoundry/bosh-cli/release"
)
type Provider struct {
reporter Reporter
blobstore boshblob.DigestBlobstore
fs boshsys.FileSystem
}
func NewProvider(
reporter Reporter,
blobstore boshblob.DigestBlobstore,
fs boshsys.FileSystem,
) Provider {
return Provider{
reporter: reporter,
blobstore: blobstore,
fs: fs,
}
}
func (p Provider) DevAndFinalIndicies(dirPath string) (boshrel.ArchiveIndicies, boshrel.ArchiveIndicies) {
cachePath := filepath.Join("~", ".bosh", "cache")
devBlobsCache := NewFSIndexBlobs(cachePath, p.reporter, nil, p.fs)
finalBlobsCache := NewFSIndexBlobs(cachePath, p.reporter, p.blobstore, p.fs)
devJobsPath := filepath.Join(dirPath, ".dev_builds", "jobs")
devPkgsPath := filepath.Join(dirPath, ".dev_builds", "packages")
devLicPath := filepath.Join(dirPath, ".dev_builds", "license")
finalJobsPath := filepath.Join(dirPath, ".final_builds", "jobs")
finalPkgsPath := filepath.Join(dirPath, ".final_builds", "packages")
finalLicPath := filepath.Join(dirPath, ".final_builds", "license")
devIndicies := boshrel.ArchiveIndicies{
Jobs: NewFSIndex("job", devJobsPath, true, false, p.reporter, devBlobsCache, p.fs),
Packages: NewFSIndex("package", devPkgsPath, true, false, p.reporter, devBlobsCache, p.fs),
Licenses: NewFSIndex("license", devLicPath, false, false, p.reporter, devBlobsCache, p.fs),
}
finalIndicies := boshrel.ArchiveIndicies{
Jobs: NewFSIndex("job", finalJobsPath, true, true, p.reporter, finalBlobsCache, p.fs),
Packages: NewFSIndex("package", finalPkgsPath, true, true, p.reporter, finalBlobsCache, p.fs),
Licenses: NewFSIndex("license", finalLicPath, false, true, p.reporter, finalBlobsCache, p.fs),
}
return devIndicies, finalIndicies
}