-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathssh.go
57 lines (48 loc) · 1.12 KB
/
ssh.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
50
51
52
53
54
55
56
57
package provider
import (
"github.com/renproject/darknode-cli/darknode"
"github.com/renproject/darknode-cli/util"
"github.com/urfave/cli"
)
type providerSsh struct {
user string
hostname string
priKeyPath string
}
func NewSsh(ctx *cli.Context) (Provider, error) {
user := ctx.String("ssh-user")
hostname := ctx.String("ssh-hostname")
priKeyPath := ctx.String("ssh-private-key")
return providerSsh{
user: user,
hostname: hostname,
priKeyPath: priKeyPath,
}, nil
}
func (p providerSsh) Name() string {
return NameSsh
}
func (p providerSsh) Deploy(ctx *cli.Context) error {
name := ctx.String("name")
tags := ctx.String("tags")
latestVersion, err := util.LatestStableRelease()
if err != nil {
return err
}
// Initialization
network, err := darknode.NewNetwork(ctx.String("network"))
if err != nil {
return err
}
if err := initNode(name, tags, network); err != nil {
return err
}
// Generate terraform config and start deploying
if err := p.tfConfig(name, latestVersion); err != nil {
return err
}
if err := runTerraform(name); err != nil {
return err
}
return outputURL(name)
}