github.com/ferryproxy/api@v0.4.2/apis/traffic/v1alpha2/routepolicy_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 // RoutePolicySpec defines the desired state of RoutePolicy 24 type RoutePolicySpec struct { 25 // Exports is a list of exports of the RoutePolicy 26 Exports []RoutePolicySpecRule `json:"exports"` 27 28 // Imports is a list of imports of the RoutePolicy 29 Imports []RoutePolicySpecRule `json:"imports"` 30 } 31 32 // RoutePolicyStatus defines the observed state of RoutePolicy 33 type RoutePolicyStatus struct { 34 // RouteCount is the number of Route in the RoutePolicy 35 RouteCount int `json:"routeCount,omitempty"` 36 37 // Phase is the phase of the RoutePolicy 38 Phase string `json:"phase,omitempty"` 39 40 // LastSynchronizationTimestamp is the last time synchronization 41 LastSynchronizationTimestamp metav1.Time `json:"lastSynchronizationTimestamp,omitempty"` 42 43 // Conditions current service state 44 Conditions []metav1.Condition `json:"conditions,omitempty"` 45 } 46 47 const ( 48 // RoutePolicyReady means the RoutePolicy have been converted to Routes 49 RoutePolicyReady = "Ready" 50 ) 51 52 // RoutePolicySpecRule defines the desired import of RoutePolicySpec 53 type RoutePolicySpecRule struct { 54 // HubName is specifies the name of the Hub 55 HubName string `json:"hubName"` 56 57 // Service is specifies the service of matched 58 Service RoutePolicySpecRuleService `json:"service,omitempty"` 59 } 60 61 // RoutePolicySpecRuleService defines the desired match of RoutePolicySpecRule 62 type RoutePolicySpecRuleService struct { 63 // Labels is specifies the labels of matched 64 Labels map[string]string `json:"labels,omitempty"` 65 66 // Namespace is specifies the namespace of matched 67 Namespace string `json:"namespace,omitempty"` 68 69 // Name is specifies the name of matched 70 Name string `json:"name,omitempty"` 71 } 72 73 // +genclient 74 //+kubebuilder:object:root=true 75 //+kubebuilder:subresource:status 76 //+kubebuilder:printcolumn:name="route-count",type="integer",JSONPath=".status.routeCount" 77 //+kubebuilder:printcolumn:name="status",type="string",JSONPath=".status.phase" 78 //+kubebuilder:printcolumn:name="last-synchronization",type="date",JSONPath=".status.lastSynchronizationTimestamp" 79 //+kubebuilder:printcolumn:name="age",type="date",JSONPath=".metadata.creationTimestamp" 80 81 // RoutePolicy is the Schema for the routepolicies API 82 type RoutePolicy struct { 83 metav1.TypeMeta `json:",inline"` 84 metav1.ObjectMeta `json:"metadata,omitempty"` 85 86 Spec RoutePolicySpec `json:"spec,omitempty"` 87 Status RoutePolicyStatus `json:"status,omitempty"` 88 } 89 90 //+kubebuilder:object:root=true 91 92 // RoutePolicyList contains a list of RoutePolicy 93 type RoutePolicyList struct { 94 metav1.TypeMeta `json:",inline"` 95 metav1.ListMeta `json:"metadata,omitempty"` 96 Items []RoutePolicy `json:"items"` 97 } 98 99 func init() { 100 SchemeBuilder.Register(&RoutePolicy{}, &RoutePolicyList{}) 101 }