|
| 1 | +package v1alpha1 |
| 2 | + |
| 3 | +import ( |
| 4 | + corev1 "k8s.io/api/core/v1" |
| 5 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 6 | +) |
| 7 | + |
| 8 | +// NetworkRouterSpec defines the desired state of NetworkRouter. |
| 9 | +type NetworkRouterSpec struct { |
| 10 | + // DNSZoneRef is a reference to the DNS zone used to create records for resources. |
| 11 | + // +required |
| 12 | + DNSZoneRef DNSZoneReference `json:"dnsZoneRef"` |
| 13 | + |
| 14 | + // WorkloadOverride contains configuration that will override the default workload. |
| 15 | + // +optional |
| 16 | + WorkloadOverride *WorkloadOverride `json:"workloadOverride,omitempty"` |
| 17 | +} |
| 18 | + |
| 19 | +// DNSZoneReference references a Netbird DNS zone by domain name. |
| 20 | +type DNSZoneReference struct { |
| 21 | + // Name is the domain name of an existing Netbird DNS zone, e.g. "example.com". |
| 22 | + // +required |
| 23 | + Name string `json:"name"` |
| 24 | +} |
| 25 | + |
| 26 | +type WorkloadOverride struct { |
| 27 | + // Labels that will be added. |
| 28 | + // +optional |
| 29 | + Labels map[string]string `json:"labels"` |
| 30 | + |
| 31 | + // Annotations that will be added. |
| 32 | + // +optional |
| 33 | + Annotations map[string]string `json:"annotations"` |
| 34 | + |
| 35 | + // Replicas sets the amount of client replicas. |
| 36 | + // +optional |
| 37 | + Replicas *int32 `json:"replicas"` |
| 38 | + |
| 39 | + // PodTemplate overrides the pod template. |
| 40 | + // +optional |
| 41 | + // +kubebuilder:pruning:PreserveUnknownFields |
| 42 | + // +kubebuilder:validation:Schemaless |
| 43 | + PodTemplate *corev1.PodTemplateSpec `json:"podTemplate"` |
| 44 | +} |
| 45 | + |
| 46 | +// NetworkRouterStatus defines the observed state of NetworkRouter. |
| 47 | +type NetworkRouterStatus struct { |
| 48 | + // ObservedGeneration is the last reconciled generation. |
| 49 | + // +optional |
| 50 | + ObservedGeneration int64 `json:"observedGeneration,omitempty"` |
| 51 | + |
| 52 | + // Conditions holds the conditions for the NetworkRouter. |
| 53 | + // +listType=map |
| 54 | + // +listMapKey=type |
| 55 | + // +optional |
| 56 | + Conditions []metav1.Condition `json:"conditions,omitempty"` |
| 57 | + |
| 58 | + // RoutingPeerID is the id of the created routing peer. |
| 59 | + // +optional |
| 60 | + RoutingPeerID string `json:"routingPeerID,omitempty"` |
| 61 | + |
| 62 | + // NetworkID is the id of the network the routing peer was created in. |
| 63 | + // +optional |
| 64 | + NetworkID string `json:"networkID,omitempty"` |
| 65 | +} |
| 66 | + |
| 67 | +// +kubebuilder:object:root=true |
| 68 | +// +kubebuilder:subresource:status |
| 69 | +// +kubebuilder:resource |
| 70 | +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.conditions[?(@.type==\"Ready\")].status",description="" |
| 71 | +// +kubebuilder:printcolumn:name="Age",type="date",JSONPath=".metadata.creationTimestamp",description="" |
| 72 | + |
| 73 | +// NetworkRouter is the Schema for the networkrouters API. |
| 74 | +type NetworkRouter struct { |
| 75 | + metav1.TypeMeta `json:",inline"` |
| 76 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 77 | + |
| 78 | + // +required |
| 79 | + Spec NetworkRouterSpec `json:"spec"` |
| 80 | + |
| 81 | + // +kubebuilder:default={"observedGeneration":-1} |
| 82 | + Status NetworkRouterStatus `json:"status,omitempty"` |
| 83 | +} |
| 84 | + |
| 85 | +// GetConditions returns the status conditions of the object. |
| 86 | +func (n *NetworkRouter) GetConditions() []metav1.Condition { |
| 87 | + return n.Status.Conditions |
| 88 | +} |
| 89 | + |
| 90 | +// SetConditions sets the status conditions on the object. |
| 91 | +func (n *NetworkRouter) SetConditions(conditions []metav1.Condition) { |
| 92 | + n.Status.Conditions = conditions |
| 93 | +} |
| 94 | + |
| 95 | +// +kubebuilder:object:root=true |
| 96 | + |
| 97 | +// NetworkRouterList contains a list of NetworkRouter. |
| 98 | +type NetworkRouterList struct { |
| 99 | + metav1.TypeMeta `json:",inline"` |
| 100 | + metav1.ListMeta `json:"metadata,omitzero"` |
| 101 | + Items []NetworkRouter `json:"items"` |
| 102 | +} |
| 103 | + |
| 104 | +func init() { |
| 105 | + SchemeBuilder.Register(&NetworkRouter{}, &NetworkRouterList{}) |
| 106 | +} |
0 commit comments