forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fetcher.go
40 lines (33 loc) · 1.05 KB
/
fetcher.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
package stemcell
import (
bideplmanifest "github.com/cloudfoundry/bosh-cli/deployment/manifest"
bitarball "github.com/cloudfoundry/bosh-cli/installation/tarball"
biui "github.com/cloudfoundry/bosh-cli/ui"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
)
type Fetcher struct {
TarballProvider bitarball.Provider
StemcellExtractor Extractor
}
func (s Fetcher) GetStemcell(deploymentManifest bideplmanifest.Manifest, stage biui.Stage) (ExtractedStemcell, error) {
stemcell, err := deploymentManifest.Stemcell(deploymentManifest.JobName())
if err != nil {
return nil, err
}
stemcellTarballPath, err := s.TarballProvider.Get(stemcell, stage)
if err != nil {
return nil, err
}
var extractedStemcell ExtractedStemcell
err = stage.Perform("Validating stemcell", func() error {
extractedStemcell, err = s.StemcellExtractor.Extract(stemcellTarballPath)
if err != nil {
return bosherr.WrapErrorf(err, "Extracting stemcell from '%s'", stemcellTarballPath)
}
return nil
})
if err != nil {
return nil, err
}
return extractedStemcell, nil
}