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

     1  package ipfs
     2  
     3  import (
     4  	ipfsv1alpha1 "github.com/kotalco/kotal/apis/ipfs/v1alpha1"
     5  	"github.com/kotalco/kotal/controllers/shared"
     6  	corev1 "k8s.io/api/core/v1"
     7  )
     8  
     9  // KuboClient is an ipfs implementation in golang
    10  // https://github.com/ipfs/kubo
    11  type KuboClient struct {
    12  	peer *ipfsv1alpha1.Peer
    13  }
    14  
    15  // Images
    16  const (
    17  	//  GoIPFSHomeDir is go ipfs image home dir
    18  	GoIPFSHomeDir = "/home/ipfs"
    19  )
    20  
    21  // Command is kubo entrypoint
    22  func (c *KuboClient) Command() []string {
    23  	return []string{"ipfs"}
    24  }
    25  
    26  // Command returns environment variables for the client
    27  func (c *KuboClient) Env() []corev1.EnvVar {
    28  	return []corev1.EnvVar{
    29  		{
    30  			Name:  EnvIPFSPath,
    31  			Value: shared.PathData(c.HomeDir()),
    32  		},
    33  		{
    34  			Name:  EnvIPFSLogging,
    35  			Value: string(c.peer.Spec.Logging),
    36  		},
    37  	}
    38  }
    39  
    40  // Args returns kubo args
    41  func (c *KuboClient) Args() (args []string) {
    42  
    43  	peer := c.peer
    44  
    45  	args = append(args, GoIPFSDaemonArg)
    46  
    47  	args = append(args, GoIPFSRoutingArg, string(peer.Spec.Routing))
    48  
    49  	return
    50  }
    51  
    52  func (c *KuboClient) HomeDir() string {
    53  	return GoIPFSHomeDir
    54  }