github.com/kotalco/kotal@v0.3.0/clients/ethereum2/nimbus_beacon_node.go (about) 1 package ethereum2 2 3 import ( 4 "fmt" 5 "strings" 6 7 ethereum2v1alpha1 "github.com/kotalco/kotal/apis/ethereum2/v1alpha1" 8 "github.com/kotalco/kotal/controllers/shared" 9 corev1 "k8s.io/api/core/v1" 10 ) 11 12 // NimbusBeaconNode is Status Ethereum 2.0 client 13 // https://github.com/status-im/nimbus-eth2 14 type NimbusBeaconNode struct { 15 node *ethereum2v1alpha1.BeaconNode 16 } 17 18 // HomeDir returns container home directory 19 func (t *NimbusBeaconNode) HomeDir() string { 20 return NimbusHomeDir 21 } 22 23 // Command returns environment variables for running the client 24 func (t *NimbusBeaconNode) Env() []corev1.EnvVar { 25 return nil 26 } 27 28 // Args returns command line arguments required for client 29 func (t *NimbusBeaconNode) Args() (args []string) { 30 31 node := t.node 32 33 args = append(args, NimbusNonInteractive) 34 35 args = append(args, argWithVal(NimbusDataDir, shared.PathData(t.HomeDir()))) 36 37 args = append(args, argWithVal(NimbusLogging, string(t.node.Spec.Logging))) 38 39 args = append(args, argWithVal(NimbusNetwork, node.Spec.Network)) 40 41 args = append(args, argWithVal(NimbusExecutionEngineEndpoint, node.Spec.ExecutionEngineEndpoint)) 42 43 args = append(args, argWithVal(NimbusFeeRecipient, string(node.Spec.FeeRecipient))) 44 45 jwtSecretPath := fmt.Sprintf("%s/jwt.secret", shared.PathSecrets(t.HomeDir())) 46 args = append(args, argWithVal(NimbusJwtSecretFile, jwtSecretPath)) 47 48 if node.Spec.REST { 49 args = append(args, NimbusREST) 50 args = append(args, argWithVal(NimbusRESTAddress, shared.Host(node.Spec.REST))) 51 args = append(args, argWithVal(NimbusRESTPort, fmt.Sprintf("%d", node.Spec.RESTPort))) 52 args = append(args, argWithVal(NimbusRESTAllowOrigin, strings.Join(node.Spec.CORSDomains, ","))) 53 } 54 55 args = append(args, argWithVal(NimbusTCPPort, fmt.Sprintf("%d", node.Spec.P2PPort))) 56 args = append(args, argWithVal(NimbusUDPPort, fmt.Sprintf("%d", node.Spec.P2PPort))) 57 58 return 59 } 60 61 // Command returns command for running the client 62 func (t *NimbusBeaconNode) Command() (command []string) { 63 command = []string{"nimbus_beacon_node"} 64 return 65 } 66 67 // nimbus accepts arguments in the form of --arg=val 68 // --arg val is not recoginized by nimbus 69 func argWithVal(arg, val string) string { 70 return fmt.Sprintf("%s=%s", arg, val) 71 }