-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
connect.go
40 lines (33 loc) · 955 Bytes
/
connect.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 connect
import (
"drawbridge/pkg/config"
"drawbridge/pkg/utils"
"fmt"
"path/filepath"
"syscall"
)
type ConnectEngine struct {
Config config.Interface
}
func (e *ConnectEngine) Start(answerData map[string]interface{}) error {
//"-c", "command1; command2; command3; ..."
tmplData, err := e.Config.GetActiveConfigTemplate()
if err != nil {
return nil
}
tmplConfigFilepath, err := utils.PopulateTemplate(tmplData.FilePath, answerData)
if err != nil {
return nil
}
tmplConfigFilepath, err = utils.ExpandPath(filepath.Join(e.Config.GetString("options.config_dir"), tmplConfigFilepath))
if err != nil {
return nil
}
//Print the lines we're running.
//Check that the bastion host is accessible.
return syscall.Exec("/bin/bash", []string{"-c",
fmt.Sprintf("ssh bastion -F %v",
//filepath.Join(e.Config.GetString("options.pem_dir"), e.Config.GetString("options.pem_filename")),
tmplConfigFilepath),
}, []string{})
}