github.com/kotalco/kotal@v0.3.0/apis/ipfs/v1alpha1/peer.go (about)

     1  package v1alpha1
     2  
     3  import (
     4  	"github.com/kotalco/kotal/apis/shared"
     5  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     6  )
     7  
     8  // PeerSpec defines the desired state of Peer
     9  type PeerSpec struct {
    10  	// Image is ipfs peer client image
    11  	Image string `json:"image,omitempty"`
    12  	// ExtraArgs is extra arguments to pass down to the cli
    13  	ExtraArgs shared.ExtraArgs `json:"extraArgs,omitempty"`
    14  	// Replicas is number of replicas
    15  	// +kubebuilder:validation:Enum=0;1
    16  	Replicas *uint `json:"replicas,omitempty"`
    17  	// InitProfiles is the intial profiles to apply during
    18  	// +listType=set
    19  	InitProfiles []Profile `json:"initProfiles,omitempty"`
    20  	// Profiles is the configuration profiles to apply after peer initialization
    21  	// +listType=set
    22  	Profiles []Profile `json:"profiles,omitempty"`
    23  	// API enables API server
    24  	API bool `json:"api,omitempty"`
    25  	// APIPort is api server port
    26  	APIPort uint `json:"apiPort,omitempty"`
    27  	// Gateway enables IPFS gateway server
    28  	Gateway bool `json:"gateway,omitempty"`
    29  	// GatewayPort is local gateway port
    30  	GatewayPort uint `json:"gatewayPort,omitempty"`
    31  	// Routing is the content routing mechanism
    32  	Routing RoutingMechanism `json:"routing,omitempty"`
    33  	// SwarmKeySecretName is the k8s secret holding swarm key
    34  	SwarmKeySecretName string `json:"swarmKeySecretName,omitempty"`
    35  	// Logging is logging verboisty level
    36  	// +kubebuilder:validation:Enum=error;warn;info;debug;notice
    37  	Logging shared.VerbosityLevel `json:"logging,omitempty"`
    38  	// Resources is node compute and storage resources
    39  	shared.Resources `json:"resources,omitempty"`
    40  }
    41  
    42  // Profile is ipfs configuration
    43  // +kubebuilder:validation:Enum=server;randomports;default-datastore;local-discovery;test;default-networking;flatfs;badgerds;lowpower
    44  type Profile string
    45  
    46  const (
    47  	// ServerProfile is the server profile
    48  	ServerProfile Profile = "server"
    49  	// RandomPortsProfile is the random ports profile
    50  	RandomPortsProfile Profile = "randomports"
    51  	// DefaultDatastoreProfile is the default data store profile
    52  	DefaultDatastoreProfile Profile = "default-datastore"
    53  	// LocalDiscoveryProfile is the local discovery profile
    54  	LocalDiscoveryProfile Profile = "local-discovery"
    55  	// TestProfile is the test profile
    56  	TestProfile Profile = "test"
    57  	// DefaultNetworkingProfile is the default networking profile
    58  	DefaultNetworkingProfile Profile = "default-networking"
    59  	// FlatFSProfile is the flat file system profile
    60  	FlatFSProfile Profile = "flatfs"
    61  	// BadgerDSProfile is badger data store profile
    62  	BadgerDSProfile Profile = "badgerds"
    63  	// LowPowerProfile is the low power profile
    64  	LowPowerProfile Profile = "lowpower"
    65  )
    66  
    67  // RoutingMechanism is the content routing mechanism
    68  // +kubebuilder:validation:Enum=none;dht;dhtclient;dhtserver
    69  type RoutingMechanism string
    70  
    71  const (
    72  	// NoneRouting is no routing mechanism
    73  	NoneRouting RoutingMechanism = "none"
    74  	// DHTRouting is automatic dht routing mechanism
    75  	DHTRouting RoutingMechanism = "dht"
    76  	// DHTClientRouting is the dht client routing mechanism
    77  	DHTClientRouting RoutingMechanism = "dhtclient"
    78  	// DHTServerRouting is the dht server routing mechanism
    79  	DHTServerRouting RoutingMechanism = "dhtserver"
    80  )
    81  
    82  // PeerStatus defines the observed state of Peer
    83  type PeerStatus struct {
    84  	Client string `json:"client,omitempty"`
    85  }
    86  
    87  // +kubebuilder:object:root=true
    88  // +kubebuilder:subresource:status
    89  
    90  // Peer is the Schema for the peers API
    91  // +kubebuilder:printcolumn:name="Client",type=string,JSONPath=".status.client"
    92  type Peer struct {
    93  	metav1.TypeMeta   `json:",inline"`
    94  	metav1.ObjectMeta `json:"metadata,omitempty"`
    95  
    96  	Spec   PeerSpec   `json:"spec,omitempty"`
    97  	Status PeerStatus `json:"status,omitempty"`
    98  }
    99  
   100  // +kubebuilder:object:root=true
   101  
   102  // PeerList contains a list of Peer
   103  type PeerList struct {
   104  	metav1.TypeMeta `json:",inline"`
   105  	metav1.ListMeta `json:"metadata,omitempty"`
   106  	Items           []Peer `json:"items"`
   107  }
   108  
   109  func init() {
   110  	SchemeBuilder.Register(&Peer{}, &PeerList{})
   111  }