1 // Copyright 2020 Datawire. All rights reserved 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package v1 16 17 import ( 18 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 19 20 ambv2 "github.com/emissary-ingress/emissary/v3/pkg/api/getambassador.io/v2" 21 ) 22 23 // Mapping is the Schema for the mappings API 24 // 25 // +kubebuilder:object:root=true 26 // +kubebuilder:subresource:status 27 // +kubebuilder:printcolumn:name="Source Host",type=string,JSONPath=`.spec.host` 28 // +kubebuilder:printcolumn:name="Source Prefix",type=string,JSONPath=`.spec.prefix` 29 // +kubebuilder:printcolumn:name="Dest Service",type=string,JSONPath=`.spec.service` 30 // +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.status.state` 31 // +kubebuilder:printcolumn:name="Reason",type=string,JSONPath=`.status.reason` 32 type Mapping struct { 33 metav1.TypeMeta `json:""` 34 metav1.ObjectMeta `json:"metadata,omitempty"` 35 36 Spec ambv2.MappingSpec `json:"spec,omitempty"` 37 Status *ambv2.MappingStatus `json:"status,omitempty"` 38 39 // dumbWorkaround is a dumb workaround for a bug in conversion-gen that it doesn't pay 40 // attention to +k8s:conversion-fn=drop or +k8s:conversion-gen=false when checking if it can 41 // do the direct-assignment or direct-conversion optimizations, and therefore might disobey 42 // the +k8s:conversion-fn=drop on metav1.TypeMeta. 43 // 44 // +k8s:conversion-gen=false 45 dumbWorkaround byte `json:"-"` //nolint:unused // dumb workaround 46 } 47 48 // MappingList contains a list of Mappings. 49 // 50 // +kubebuilder:object:root=true 51 type MappingList struct { 52 metav1.TypeMeta `json:""` 53 metav1.ListMeta `json:"metadata,omitempty"` 54 Items []Mapping `json:"items"` 55 } 56 57 func init() { 58 SchemeBuilder.Register(&Mapping{}, &MappingList{}) 59 } 60