-
Notifications
You must be signed in to change notification settings - Fork 162
/
stemcell.go
56 lines (46 loc) · 1.18 KB
/
stemcell.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
package stemcell
import (
"fmt"
biproperty "github.com/cloudfoundry/bosh-utils/property"
boshsys "github.com/cloudfoundry/bosh-utils/system"
)
type ExtractedStemcell interface {
Manifest() Manifest
Delete() error
OsAndVersion() string
fmt.Stringer
}
type extractedStemcell struct {
manifest Manifest
extractedPath string
fs boshsys.FileSystem
}
func NewExtractedStemcell(
manifest Manifest,
extractedPath string,
fs boshsys.FileSystem,
) ExtractedStemcell {
return &extractedStemcell{
manifest: manifest,
extractedPath: extractedPath,
fs: fs,
}
}
func (s *extractedStemcell) Manifest() Manifest { return s.manifest }
func (s *extractedStemcell) Delete() error {
return s.fs.RemoveAll(s.extractedPath)
}
func (s *extractedStemcell) String() string {
return fmt.Sprintf("ExtractedStemcell{name=%s version=%s}", s.manifest.Name, s.manifest.Version)
}
func (s *extractedStemcell) OsAndVersion() string {
return fmt.Sprintf("%s/%s", s.manifest.OS, s.manifest.Version)
}
type Manifest struct {
ImagePath string
Name string
Version string
OS string
SHA1 string
CloudProperties biproperty.Map
}