vitess.io/vitess@v0.16.2/go/vt/vtadmin/debug/debug.go (about) 1 /* 2 Copyright 2021 The Vitess 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 debug 18 19 import "time" 20 21 // Debuggable is an optional interface that different vtadmin subcomponents can 22 // implement to provide information to debug endpoints. 23 type Debuggable interface { 24 Debug() map[string]any 25 } 26 27 const sanitized = "********" 28 29 // SanitizeString returns a sanitized version of the input string. If the input 30 // is empty, an empty string is returned. Otherwise a constant-length string 31 // (irrespective of the input length) is returned. 32 func SanitizeString(s string) string { 33 if len(s) == 0 { 34 return s 35 } 36 37 return sanitized 38 } 39 40 // TimeToString returns a time in RFC3339-formatted string, so all debug-related 41 // times are in the same format. 42 func TimeToString(t time.Time) string { return t.Format(time.RFC3339) }