|  | 
|  | 1 | +/* | 
|  | 2 | +Copyright 2017 The Kubernetes 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 endpoint | 
|  | 18 | + | 
|  | 19 | +import "strings" | 
|  | 20 | + | 
|  | 21 | +// endpointTargetCleaner is essentially a function that cleans a target string for a given record. | 
|  | 22 | +// It returns the cleaned target string, which is used to create an endpoint. Different record types have different cleaning rules. | 
|  | 23 | +type endpointTargetCleaner interface { | 
|  | 24 | +	Clean(target string) string | 
|  | 25 | +} | 
|  | 26 | + | 
|  | 27 | +// defaultEndpointTargetCleaner is a function that cleans a target string for a given record, trimming trailing dots which are not allowed | 
|  | 28 | +// for most record types. | 
|  | 29 | +type defaultEndpointTargetCleaner struct{} | 
|  | 30 | + | 
|  | 31 | +func (v *defaultEndpointTargetCleaner) Clean(target string) string { | 
|  | 32 | +	return strings.TrimSuffix(target, ".") | 
|  | 33 | +} | 
|  | 34 | + | 
|  | 35 | +// arbitraryTextEndpointTargetCleaner is a function that cleans a target string for a given record, preserving arbitrary text including trailing dots. | 
|  | 36 | +// This is used for TXT and NAPTR records. | 
|  | 37 | +type arbitraryTextEndpointTargetCleaner struct{} | 
|  | 38 | + | 
|  | 39 | +func (v *arbitraryTextEndpointTargetCleaner) Clean(target string) string { | 
|  | 40 | +	return target | 
|  | 41 | +} | 
0 commit comments