forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_runtime_config.go
40 lines (31 loc) · 1.1 KB
/
update_runtime_config.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 cmd
import (
bosherr "github.com/cloudfoundry/bosh-utils/errors"
boshdir "github.com/cloudfoundry/bosh-cli/director"
boshtpl "github.com/cloudfoundry/bosh-cli/director/template"
boshui "github.com/cloudfoundry/bosh-cli/ui"
)
type UpdateRuntimeConfigCmd struct {
ui boshui.UI
director boshdir.Director
releaseUploader ReleaseUploader
}
func NewUpdateRuntimeConfigCmd(ui boshui.UI, director boshdir.Director, releaseUploader ReleaseUploader) UpdateRuntimeConfigCmd {
return UpdateRuntimeConfigCmd{ui: ui, director: director, releaseUploader: releaseUploader}
}
func (c UpdateRuntimeConfigCmd) Run(opts UpdateRuntimeConfigOpts) error {
tpl := boshtpl.NewTemplate(opts.Args.RuntimeConfig.Bytes)
bytes, err := tpl.Evaluate(opts.VarFlags.AsVariables(), opts.OpsFlags.AsOp(), boshtpl.EvaluateOpts{})
if err != nil {
return bosherr.WrapErrorf(err, "Evaluating runtime config")
}
bytes, err = c.releaseUploader.UploadReleases(bytes)
if err != nil {
return err
}
err = c.ui.AskForConfirmation()
if err != nil {
return err
}
return c.director.UpdateRuntimeConfig(bytes)
}