-
Notifications
You must be signed in to change notification settings - Fork 0
/
sol.go
111 lines (97 loc) · 2.36 KB
/
sol.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
package deployment_part
import (
"github.com/rs/zerolog/log"
"github.com/goplugin/plugin-env/client"
"github.com/goplugin/plugin-env/environment"
)
type Props struct {
NetworkName string `envconfig:"network_name"`
HttpURLs []string `envconfig:"http_url"`
WsURLs []string `envconfig:"ws_url"`
Values map[string]interface{}
}
type HelmProps struct {
Name string
Path string
Version string
Values *map[string]interface{}
}
type Chart struct {
HelmProps *HelmProps
Props *Props
}
func (m Chart) IsDeploymentNeeded() bool {
return true
}
func (m Chart) GetProps() interface{} {
return m.Props
}
func (m Chart) GetName() string {
return m.HelmProps.Name
}
func (m Chart) GetPath() string {
return m.HelmProps.Path
}
func (m Chart) GetVersion() string {
return m.HelmProps.Version
}
func (m Chart) GetValues() *map[string]interface{} {
return m.HelmProps.Values
}
func (m Chart) ExportData(e *environment.Environment) error {
netLocal, err := e.Fwd.FindPort("sol:0", "sol-val", "http-rpc").As(client.LocalConnection, client.HTTP)
if err != nil {
return err
}
netLocalWS, err := e.Fwd.FindPort("sol:0", "sol-val", "ws-rpc").As(client.LocalConnection, client.WS)
if err != nil {
return err
}
netInternal, err := e.Fwd.FindPort("sol:0", "sol-val", "http-rpc").As(client.RemoteConnection, client.HTTP)
if err != nil {
return err
}
e.URLs[m.Props.NetworkName] = []string{netLocal, netLocalWS}
if e.Cfg.InsideK8s {
e.URLs[m.Props.NetworkName] = []string{netInternal}
}
log.Info().Str("Name", m.Props.NetworkName).Str("URLs", netLocal).Msg("Solana network")
return nil
}
func defaultProps() *Props {
return &Props{
NetworkName: "sol",
Values: map[string]interface{}{
"replicas": "1",
"sol": map[string]interface{}{
"image": map[string]interface{}{
"image": "solanalabs/solana",
"version": "v1.9.14",
},
"resources": map[string]interface{}{
"requests": map[string]interface{}{
"cpu": "2000m",
"memory": "4000Mi",
},
"limits": map[string]interface{}{
"cpu": "2000m",
"memory": "4000Mi",
},
},
},
},
}
}
func New(props *Props) environment.ConnectedChart {
if props == nil {
props = defaultProps()
}
return Chart{
HelmProps: &HelmProps{
Name: "sol",
Path: "plugin-qa/solana-validator",
Values: &props.Values,
},
Props: props,
}
}