forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
export_release.go
42 lines (32 loc) · 903 Bytes
/
export_release.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
package cmd
import (
"fmt"
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshdir "github.com/cloudfoundry/bosh-cli/director"
)
type ExportReleaseCmd struct {
deployment boshdir.Deployment
downloader Downloader
}
func NewExportReleaseCmd(deployment boshdir.Deployment, downloader Downloader) ExportReleaseCmd {
return ExportReleaseCmd{deployment: deployment, downloader: downloader}
}
func (c ExportReleaseCmd) Run(opts ExportReleaseOpts) error {
rel := opts.Args.ReleaseSlug
os := opts.Args.OSVersionSlug
result, err := c.deployment.ExportRelease(rel, os)
if err != nil {
return err
}
prefix := fmt.Sprintf("%s-%s-%s-%s", rel.Name(), rel.Version(), os.OS(), os.Version())
err = c.downloader.Download(
result.BlobstoreID,
result.SHA1,
prefix,
opts.Directory.Path,
)
if err != nil {
return bosherr.WrapError(err, "Downloading exported release")
}
return nil
}