github.com/ferryproxy/api@v0.4.2/apis/traffic/v1alpha2/route_types.go (about) 1 /* 2 Copyright 2022 FerryProxy Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package v1alpha2 18 19 import ( 20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 21 ) 22 23 // RouteSpec defines the desired state of Route 24 type RouteSpec struct { 25 // Import is one of import of the Route 26 Import RouteSpecRule `json:"import"` 27 28 // Export is one of export of the Route 29 Export RouteSpecRule `json:"export"` 30 } 31 32 // RouteStatus defines the observed state of Route 33 type RouteStatus struct { 34 // Way is describe of the way 35 Way string `json:"way,omitempty"` 36 37 // Export is describe of the export 38 Export string `json:"export,omitempty"` 39 40 // Import is describe of the import 41 Import string `json:"import,omitempty"` 42 43 // Phase is the phase of the Route 44 Phase string `json:"phase,omitempty"` 45 46 // LastSynchronizationTimestamp is the last time synchronization 47 LastSynchronizationTimestamp metav1.Time `json:"lastSynchronizationTimestamp,omitempty"` 48 49 // Conditions current service state 50 Conditions []metav1.Condition `json:"conditions,omitempty"` 51 } 52 53 const ( 54 // ExportHubReadyCondition means the Hub of export is ready. 55 ExportHubReadyCondition = "ExportHubReady" 56 57 // ImportHubReadyCondition means the Hub of export is ready. 58 ImportHubReadyCondition = "ImportHubReady" 59 60 // PortsAllocatedCondition means ports has been allocated to it in the Tunnel. 61 PortsAllocatedCondition = "PortsAllocated" 62 63 // PathReachableCondition means path of the Route is reachable. 64 PathReachableCondition = "PathReachable" 65 66 // RouteSyncedCondition means the Route is synced to tunnel. 67 RouteSyncedCondition = "Synced" 68 69 // RouteReady means the Route is able to service requests. 70 RouteReady = "Ready" 71 ) 72 73 // RouteSpecRule defines the desired state of RouteSpec 74 type RouteSpecRule struct { 75 // HubName is specifies the name of the Hub 76 HubName string `json:"hubName"` 77 78 // Service is the service 79 Service RouteSpecRuleService `json:"service"` 80 } 81 82 // RouteSpecRuleService defines the desired state of RouteSpecRule 83 type RouteSpecRuleService struct { 84 // Name is the service name 85 Name string `json:"name"` 86 87 // Namespace is the service namespace 88 Namespace string `json:"namespace"` 89 } 90 91 // +genclient 92 //+kubebuilder:object:root=true 93 //+kubebuilder:subresource:status 94 //+kubebuilder:printcolumn:name="export",type="string",JSONPath=".status.export" 95 //+kubebuilder:printcolumn:name="way",type="string",JSONPath=".status.way" 96 //+kubebuilder:printcolumn:name="import",type="string",JSONPath=".status.import" 97 //+kubebuilder:printcolumn:name="status",type="string",JSONPath=".status.phase" 98 //+kubebuilder:printcolumn:name="last-synchronization",type="date",JSONPath=".status.lastSynchronizationTimestamp" 99 //+kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp" 100 101 // Route is the Schema for the routes API 102 type Route struct { 103 metav1.TypeMeta `json:",inline"` 104 metav1.ObjectMeta `json:"metadata,omitempty"` 105 106 Spec RouteSpec `json:"spec,omitempty"` 107 Status RouteStatus `json:"status,omitempty"` 108 } 109 110 //+kubebuilder:object:root=true 111 112 // RouteList contains a list of Route 113 type RouteList struct { 114 metav1.TypeMeta `json:",inline"` 115 metav1.ListMeta `json:"metadata,omitempty"` 116 Items []Route `json:"items"` 117 } 118 119 func init() { 120 SchemeBuilder.Register(&Route{}, &RouteList{}) 121 }