forked from cloudfoundry/bosh-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_cpi_config.go
34 lines (26 loc) · 885 Bytes
/
update_cpi_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
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 UpdateCPIConfigCmd struct {
ui boshui.UI
director boshdir.Director
}
func NewUpdateCPIConfigCmd(ui boshui.UI, director boshdir.Director) UpdateCPIConfigCmd {
return UpdateCPIConfigCmd{ui: ui, director: director}
}
func (c UpdateCPIConfigCmd) Run(opts UpdateCPIConfigOpts) error {
tpl := boshtpl.NewTemplate(opts.Args.CPIConfig.Bytes)
bytes, err := tpl.Evaluate(opts.VarFlags.AsVariables(), opts.OpsFlags.AsOp(), boshtpl.EvaluateOpts{})
if err != nil {
return bosherr.WrapErrorf(err, "Evaluating cpi config")
}
err = c.ui.AskForConfirmation()
if err != nil {
return err
}
return c.director.UpdateCPIConfig(bytes)
}