github.com/kotalco/kotal@v0.3.0/clients/ethereum2/client.go (about) 1 package ethereum2 2 3 import ( 4 "fmt" 5 6 ethereum2v1alpha1 "github.com/kotalco/kotal/apis/ethereum2/v1alpha1" 7 "github.com/kotalco/kotal/clients" 8 "k8s.io/apimachinery/pkg/runtime" 9 ) 10 11 // Ethereum2Client is Ethereum 2.0 beacon node or validator client 12 type Ethereum2Client interface { 13 clients.Interface 14 } 15 16 // NewClient creates new ethereum 2.0 beacon node or validator client 17 func NewClient(obj runtime.Object) (Ethereum2Client, error) { 18 19 switch component := obj.(type) { 20 21 // create beacon nodes 22 case *ethereum2v1alpha1.BeaconNode: 23 switch component.Spec.Client { 24 case ethereum2v1alpha1.TekuClient: 25 return &TekuBeaconNode{component}, nil 26 case ethereum2v1alpha1.PrysmClient: 27 return &PrysmBeaconNode{component}, nil 28 case ethereum2v1alpha1.LighthouseClient: 29 return &LighthouseBeaconNode{component}, nil 30 case ethereum2v1alpha1.NimbusClient: 31 return &NimbusBeaconNode{component}, nil 32 default: 33 return nil, fmt.Errorf("client %s is not supported", component.Spec.Client) 34 } 35 36 // create validator clients 37 case *ethereum2v1alpha1.Validator: 38 switch component.Spec.Client { 39 case ethereum2v1alpha1.TekuClient: 40 return &TekuValidatorClient{component}, nil 41 case ethereum2v1alpha1.PrysmClient: 42 return &PrysmValidatorClient{component}, nil 43 case ethereum2v1alpha1.LighthouseClient: 44 return &LighthouseValidatorClient{component}, nil 45 case ethereum2v1alpha1.NimbusClient: 46 return &NimbusValidatorClient{component}, nil 47 default: 48 return nil, fmt.Errorf("client %s is not supported", component.Spec.Client) 49 } 50 default: 51 return nil, fmt.Errorf("no client support for %s", obj) 52 } 53 }