-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeployment.go
138 lines (119 loc) · 4.11 KB
/
deployment.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
package workers
import (
"fmt"
"strings"
"github.com/aws/aws-sdk-go-v2/service/acm"
"github.com/aws/aws-sdk-go-v2/service/ec2"
elbv2 "github.com/aws/aws-sdk-go-v2/service/elasticloadbalancingv2"
"github.com/aws/aws-sdk-go-v2/service/route53"
"github.com/cantara/nerthus2/cloud/aws/ami"
"github.com/cantara/nerthus2/cloud/aws/executor"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/cert"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/image"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/key"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/lb"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/listener"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/node"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/rule"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/target"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/vpc"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/vpc/lbsg"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/vpc/sg"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/vpc/sn"
"github.com/cantara/nerthus2/cloud/aws/executor/workers/vpc/tg"
"github.com/cantara/nerthus2/system"
)
type Executor interface {
Add(executor.Func)
}
func Deploy(sys system.System, env, nerthus, visuale string, e Executor, e2 *ec2.Client, elb *elbv2.Client, rc *route53.Client, cc *acm.Client) { //TODO: Change fingerprint to take inn config object
reqList := []listener.Requireing{}
reqKey := []key.Requireing{}
reqSN := []sn.Requireing{}
reqVPC := []vpc.Requireing{}
for _, cluster := range sys.Clusters {
reqNode := []node.Requireing{}
for _, service := range cluster.Services {
te := target.Executor(elb)
reqNode = append(reqNode, te)
re := rule.Executor(elb)
reqList = append(reqList, re)
//Move the path creation to config parsing
tge := tg.Executor(env, sys.Name, cluster.Name, fmt.Sprintf("/%s", strings.ToLower(service.ServiceInfo.Artifact.Id)), *service.WebserverPort, []tg.Requireing{
te,
re,
}, elb)
reqVPC = append(reqVPC, tge)
}
ne := node.Executor(cluster.NodeNames, cluster.Name, sys.Name, env, cluster.InstanceType, nerthus, visuale, reqNode, e2)
reqKey = append(reqKey, ne)
reqSN = append(reqSN, ne)
e.Add(image.Executor(cluster.OSName, cluster.Arch, []image.Requireing{
ne,
}, e2).Execute)
sge := sg.Executor(env, sys.Name, cluster.Name, []sg.Requireing{
ne,
}, e2)
reqVPC = append(reqVPC, sge)
}
le := listener.Executor(reqList, elb)
e.Add(cert.Executor(sys.Domain, []cert.Requireing{
le,
}, cc, rc).Execute)
lbe := lb.Executor(env, sys.Name, []lb.Requireing{
le,
}, elb)
reqSN = append(reqSN, lbe)
e.Add(key.Executor(env, sys.Name, reqKey, e2).Execute)
lbsge := lbsg.Executor(env, sys.Name, []lbsg.Requireing{
lbe,
}, e2)
reqVPC = append(reqVPC, lbsge)
sne := sn.Executor(reqSN, e2)
reqVPC = append(reqVPC, sne)
e.Add(vpc.Executor(env, sys.Name, sys.CIDR, reqVPC, e2).Execute)
}
func DeployInfra(nodes []string, arch ami.Arch, imageName, network, cluster, system, env, size, nerthus, visuale, domain string, e Executor, e2 *ec2.Client, elb *elbv2.Client, rc *route53.Client, cc *acm.Client) { //TODO: Change fingerprint to take inn config object
te := target.Executor(elb)
re := rule.Executor(elb)
le := listener.Executor([]listener.Requireing{
re,
}, elb)
e.Add(cert.Executor(domain, []cert.Requireing{
le,
}, cc, rc).Execute)
lbe := lb.Executor(env, system, []lb.Requireing{
le,
}, elb)
ne := node.Executor(nodes, cluster, system, env, size, nerthus, visuale, []node.Requireing{
te,
}, e2)
e.Add(key.Executor(env, system, []key.Requireing{
ne,
}, e2).Execute)
e.Add(image.Executor(imageName, arch, []image.Requireing{
ne,
}, e2).Execute)
lbsge := lbsg.Executor(env, system, []lbsg.Requireing{
lbe,
}, e2)
sne := sn.Executor([]sn.Requireing{
ne,
lbe,
}, e2)
sge := sg.Executor(env, system, cluster, []sg.Requireing{
ne,
}, e2)
/*
tge := tg.Executor(env, cluster, path, port, []tg.Requireing{
te,
re,
}, elb)
*/
e.Add(vpc.Executor(env, system, network, []vpc.Requireing{
lbsge,
sne,
sge,
//tge,
}, e2).Execute)
}