-
Notifications
You must be signed in to change notification settings - Fork 2
/
common_steps.go
49 lines (43 loc) · 1.14 KB
/
common_steps.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
// Intended for creating a common configuration
// required by any target
package common
import (
"github.com/dorzheh/deployer/builder/image"
"github.com/dorzheh/deployer/controller"
"github.com/dorzheh/deployer/deployer"
gui "github.com/dorzheh/deployer/ui"
"github.com/dorzheh/deployer/utils"
)
func RegisterSteps(d *deployer.CommonData, storageConfigFile string) (*deployer.CommonConfig, error) {
var err error
c := new(deployer.CommonConfig)
c.StorageConfig, err = image.ParseConfigFile(storageConfigFile)
if err != nil {
return nil, utils.FormatError(err)
}
controller.RegisterSteps(func() func() error {
return func() error {
var err error
c.RemoteMode, err = gui.UiRemoteMode(d.Ui)
return err
}
}())
controller.RegisterSteps(func() func() error {
return func() error {
var err error
if c.RemoteMode {
c.SshConfig, err = gui.UiSshConfig(d.Ui)
return err
}
return controller.SkipStep
}
}())
controller.RegisterSteps(func() func() error {
return func() error {
var err error
c.ExportDir, err = gui.UiImagePath(d.Ui, d.DefaultExportDir, c.RemoteMode)
return err
}
}())
return c, nil
}