github.com/smartcontractkit/chainlink-testing-framework/libs@v0.0.0-20240227141906-ec710b4eb1a3/k8s/pkg/helm/sol/sol.go (about) 1 package sol 2 3 import ( 4 "fmt" 5 "os" 6 "strconv" 7 8 "github.com/rs/zerolog/log" 9 10 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/client" 11 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/config" 12 "github.com/smartcontractkit/chainlink-testing-framework/libs/k8s/environment" 13 "github.com/smartcontractkit/chainlink-testing-framework/libs/utils/projectpath" 14 ) 15 16 type Props struct { 17 NetworkName string `envconfig:"network_name"` 18 HttpURLs []string `envconfig:"http_url"` 19 WsURLs []string `envconfig:"ws_url"` 20 Values map[string]interface{} 21 } 22 23 type HelmProps struct { 24 Name string 25 Path string 26 Version string 27 Values *map[string]interface{} 28 } 29 30 type Chart struct { 31 HelmProps *HelmProps 32 Props *Props 33 } 34 35 func (m Chart) IsDeploymentNeeded() bool { 36 return true 37 } 38 39 func (m Chart) GetProps() interface{} { 40 return m.Props 41 } 42 43 func (m Chart) GetName() string { 44 return m.HelmProps.Name 45 } 46 47 func (m Chart) GetPath() string { 48 return m.HelmProps.Path 49 } 50 51 func (m Chart) GetVersion() string { 52 return m.HelmProps.Version 53 } 54 55 func (m Chart) GetValues() *map[string]interface{} { 56 return m.HelmProps.Values 57 } 58 59 func (m Chart) ExportData(e *environment.Environment) error { 60 netLocal, err := e.Fwd.FindPort("sol:0", "sol-val", "http-rpc").As(client.LocalConnection, client.HTTP) 61 if err != nil { 62 return err 63 } 64 netLocalWS, err := e.Fwd.FindPort("sol:0", "sol-val", "ws-rpc").As(client.LocalConnection, client.WS) 65 if err != nil { 66 return err 67 } 68 netInternal, err := e.Fwd.FindPort("sol:0", "sol-val", "http-rpc").As(client.RemoteConnection, client.HTTP) 69 if err != nil { 70 return err 71 } 72 netInternalWS, err := e.Fwd.FindPort("sol:0", "sol-val", "ws-rpc").As(client.RemoteConnection, client.WS) 73 if err != nil { 74 return err 75 } 76 e.URLs[m.Props.NetworkName] = []string{netLocal, netLocalWS} 77 if e.Cfg.InsideK8s { 78 e.URLs[m.Props.NetworkName] = []string{netInternal, netInternalWS} 79 } 80 log.Info().Str("Name", m.Props.NetworkName).Str("URLs", netLocal).Msg("Solana network") 81 return nil 82 } 83 84 func defaultProps() *Props { 85 return &Props{ 86 NetworkName: "sol", 87 Values: map[string]interface{}{ 88 "replicas": "1", 89 "sol": map[string]interface{}{ 90 "image": map[string]interface{}{ 91 "image": "solanalabs/solana", 92 "version": "v1.13.3", 93 }, 94 "resources": map[string]interface{}{ 95 "requests": map[string]interface{}{ 96 "cpu": "2000m", 97 "memory": "4000Mi", 98 }, 99 "limits": map[string]interface{}{ 100 "cpu": "2000m", 101 "memory": "4000Mi", 102 }, 103 }, 104 }, 105 }, 106 } 107 } 108 109 func New(props *Props) environment.ConnectedChart { 110 return NewVersioned("", props) 111 } 112 113 // NewVersioned enables choosing a specific helm chart version 114 func NewVersioned(helmVersion string, props *Props) environment.ConnectedChart { 115 if props == nil { 116 props = defaultProps() 117 } 118 chartPath := "chainlink-qa/solana-validator" 119 if b, err := strconv.ParseBool(os.Getenv(config.EnvVarLocalCharts)); err == nil && b { 120 chartPath = fmt.Sprintf("%s/solana-validator", projectpath.ChartsRoot) 121 } 122 return Chart{ 123 HelmProps: &HelmProps{ 124 Name: "sol", 125 Path: chartPath, 126 Values: &props.Values, 127 Version: helmVersion, 128 }, 129 Props: props, 130 } 131 }