github.com/kotalco/kotal@v0.3.0/clients/near/near_client.go (about) 1 package near 2 3 import ( 4 "fmt" 5 "strings" 6 7 nearv1alpha1 "github.com/kotalco/kotal/apis/near/v1alpha1" 8 "github.com/kotalco/kotal/controllers/shared" 9 corev1 "k8s.io/api/core/v1" 10 ) 11 12 // NearClient is NEAR core client 13 // https://github.com/near/nearcore/ 14 type NearClient struct { 15 node *nearv1alpha1.Node 16 } 17 18 // Images 19 const ( 20 // NearHomeDir is go ipfs image home dir 21 // TODO: update home dir after building docker image with non-root user and home dir 22 NearHomeDir = "/home/near" 23 ) 24 25 // Command returns environment variables for the client 26 func (c *NearClient) Env() []corev1.EnvVar { 27 return nil 28 } 29 30 // Command is NEAR core client entrypoint 31 func (c *NearClient) Command() []string { 32 return nil 33 } 34 35 // Args returns NEAR core client args 36 func (c *NearClient) Args() (args []string) { 37 38 node := c.node 39 40 args = append(args, "neard") 41 args = append(args, NearArgHome, shared.PathData(c.HomeDir())) 42 args = append(args, "run") 43 44 args = append(args, NearArgNetworkAddress, fmt.Sprintf("%s:%d", shared.Host(true), node.Spec.P2PPort)) 45 46 if node.Spec.RPC { 47 args = append(args, NearArgRPCAddress, fmt.Sprintf("%s:%d", shared.Host(node.Spec.RPC), node.Spec.RPCPort)) 48 args = append(args, NearArgPrometheusAddress, fmt.Sprintf("%s:%d", shared.Host(true), node.Spec.PrometheusPort)) 49 } else { 50 args = append(args, NearArgDisableRPC) 51 } 52 53 if node.Spec.TelemetryURL != "" { 54 args = append(args, NearArgTelemetryURL, node.Spec.TelemetryURL) 55 } 56 57 if node.Spec.Archive { 58 args = append(args, NearArgArchive) 59 } 60 61 args = append(args, NearArgMinimumPeers, fmt.Sprintf("%d", node.Spec.MinPeers)) 62 63 if len(node.Spec.Bootnodes) != 0 { 64 args = append(args, NearArgBootnodes, strings.Join(node.Spec.Bootnodes, ",")) 65 } 66 67 return 68 } 69 70 // HomeDir is the home directory of NEAR core client image 71 func (c *NearClient) HomeDir() string { 72 return NearHomeDir 73 }