github.com/kotalco/kotal@v0.3.0/clients/ipfs/client.go (about)

     1  package ipfs
     2  
     3  import (
     4  	"fmt"
     5  
     6  	ipfsv1alpha1 "github.com/kotalco/kotal/apis/ipfs/v1alpha1"
     7  	"github.com/kotalco/kotal/clients"
     8  	"k8s.io/apimachinery/pkg/runtime"
     9  )
    10  
    11  // IPFSClient is IPFS peer client
    12  type IPFSClient interface {
    13  	clients.Interface
    14  }
    15  
    16  // NewClient creates a new client for ipfs peer or cluster peer
    17  func NewClient(obj runtime.Object) (IPFSClient, error) {
    18  	switch peer := obj.(type) {
    19  	case *ipfsv1alpha1.Peer:
    20  		return &KuboClient{peer}, nil
    21  	case *ipfsv1alpha1.ClusterPeer:
    22  		return &GoIPFSClusterClient{peer}, nil
    23  	}
    24  	return nil, fmt.Errorf("no client support for %s", obj)
    25  }