github.com/ferryproxy/api@v0.4.2/apis/traffic/v1alpha2/hub_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 // HubSpec defines the desired state of Hub 24 type HubSpec struct { 25 // Gateway is the default gateway of this Hub 26 Gateway HubSpecGateway `json:"gateway"` 27 28 // Override will replace the peer default gateway, the key is the name of peer Hub 29 Override map[string]HubSpecGateway `json:"override,omitempty"` 30 } 31 32 // HubStatus defines the observed state of Hub 33 type HubStatus struct { 34 // Phase is the phase of the Hub 35 Phase string `json:"phase,omitempty"` 36 37 // LastSynchronizationTimestamp is the last time synchronization 38 LastSynchronizationTimestamp metav1.Time `json:"lastSynchronizationTimestamp,omitempty"` 39 40 // Conditions current service state 41 Conditions []metav1.Condition `json:"conditions,omitempty"` 42 } 43 44 const ( 45 // ConnectedCondition means that Controller can connect to the Apiserver 46 ConnectedCondition = "Connected" 47 48 // TunnelHealthCondition means the Tunnel is healthy 49 TunnelHealthCondition = "TunnelHealth" 50 51 // HubReady means the hub is able to service. 52 HubReady = "Ready" 53 ) 54 55 // HubSpecGateway defines the desired state of Hub 56 type HubSpecGateway struct { 57 // Reachable indicates that this Hub is reachable 58 Reachable bool `json:"reachable"` 59 60 // Address is the address of this Hub, 61 // used when Reachable is true 62 Address string `json:"address,omitempty"` 63 64 // NavigationWay is a list of Hub names through which this Hub needs to reach other Hubs, 65 // used when this Hub reaches other Hubs, 66 // used by RoutePolicy to calculate Routes 67 NavigationWay []HubSpecGatewayWay `json:"navigationWay,omitempty"` 68 69 // ReceptionWay is a list of Hub names through which other hubs needs to reach this Hub, 70 // used when other Hubs reaches this Hub and Reachable is true, 71 // used by RoutePolicy to calculate Routes 72 ReceptionWay []HubSpecGatewayWay `json:"receptionWay,omitempty"` 73 74 // NavigationProxy is a list of proxies through which this Hub to reach other Hubs must need to go through, 75 // used when this Hub reaches other Hubs 76 NavigationProxy []HubSpecGatewayProxy `json:"navigationProxy,omitempty"` 77 78 // ReceptionProxy is a list of proxies through which other Hubs to reach this Hub must need to go through, 79 // used when other Hubs reaches this Hub and Reachable is true 80 ReceptionProxy []HubSpecGatewayProxy `json:"receptionProxy,omitempty"` 81 } 82 83 // HubSpecGatewayProxy defines the desired state of HubSpecGateway 84 type HubSpecGatewayProxy struct { 85 // HubName is the name of Hub to proxy, 86 // cannot be specified together with Proxy 87 HubName string `json:"hubName,omitempty"` 88 89 // Proxy is the proxy to use, 90 // cannot be specified together with HubName 91 Proxy string `json:"proxy,omitempty"` 92 } 93 94 // HubSpecGatewayWay defines the desired state of HubSpecGateway 95 type HubSpecGatewayWay struct { 96 // HubName is the name of Hub 97 HubName string `json:"hubName"` 98 } 99 100 // +genclient 101 //+kubebuilder:object:root=true 102 //+kubebuilder:subresource:status 103 //+kubebuilder:printcolumn:name="status",type="string",JSONPath=".status.phase" 104 //+kubebuilder:printcolumn:name="last-synchronization",type="date",JSONPath=".status.lastSynchronizationTimestamp" 105 //+kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp" 106 107 // Hub is the Schema for the hubs API 108 type Hub struct { 109 metav1.TypeMeta `json:",inline"` 110 metav1.ObjectMeta `json:"metadata,omitempty"` 111 112 Spec HubSpec `json:"spec,omitempty"` 113 Status HubStatus `json:"status,omitempty"` 114 } 115 116 //+kubebuilder:object:root=true 117 118 // HubList contains a list of Hub 119 type HubList struct { 120 metav1.TypeMeta `json:",inline"` 121 metav1.ListMeta `json:"metadata,omitempty"` 122 Items []Hub `json:"items"` 123 } 124 125 func init() { 126 SchemeBuilder.Register(&Hub{}, &HubList{}) 127 }