/
githubmirror
/
origin
Обзор
Документация
Войти
/
githubmirror
/
origin
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
vendor/github.com/vmware/govmomi/vim25/debug/debug.go
61 строка
1 KB
Justin Pierce
Add compat_otp package with openshift-tests-private (OTP) util implementations
11 авг 2025, 18:00
11 авг 2025, 18:00
80ac5c1
Код
Авторство
О чём код?
// © Broadcom. All Rights Reserved. // The term “Broadcom” refers to Broadcom Inc. and/or its subsidiaries. // SPDX-License-Identifier: Apache-2.0 package debug import ( "io" "regexp" ) // Provider specified the interface types must implement to be used as a // debugging sink. Having multiple such sink implementations allows it to be // changed externally (for example when running tests). type Provider interface { NewFile(s string) io.WriteCloser Flush() } // ReadCloser is a struct that satisfies the io.ReadCloser interface type ReadCloser struct { io.Reader io.Closer } // NewTeeReader wraps io.TeeReader and patches through the Close() function. func NewTeeReader(rc io.ReadCloser, w io.Writer) io.ReadCloser { return ReadCloser{ Reader: io.TeeReader(rc, w), Closer: rc, } } var currentProvider Provider = nil var scrubPassword = regexp.MustCompile(`<password>(.*)</password>`) func SetProvider(p Provider) { if currentProvider != nil { currentProvider.Flush() } currentProvider = p } // Enabled returns whether debugging is enabled or not. func Enabled() bool { return currentProvider != nil } // NewFile dispatches to the current provider's NewFile function. func NewFile(s string) io.WriteCloser { return currentProvider.NewFile(s) } // Flush dispatches to the current provider's Flush function. func Flush() { currentProvider.Flush() } func Scrub(in []byte) []byte { return scrubPassword.ReplaceAll(in, []byte(`<password>********</password>`)) }