mirror of
https://github.com/goharbor/harbor.git
synced 2024-11-23 02:35:17 +01:00
【optimization】Use URL.Redacted method repleace redacted (#18716)
use URL.Redacted method replease redacted Signed-off-by: lengrongfu <1275177125@qq.com>
This commit is contained in:
parent
1b1af4a14c
commit
4652d752b6
2
src/lib/cache/cache.go
vendored
2
src/lib/cache/cache.go
vendored
@ -103,7 +103,7 @@ func Initialize(typ, addr string) error {
|
||||
|
||||
redactedAddr := addr
|
||||
if u, err := url.Parse(addr); err == nil {
|
||||
redactedAddr = redacted(u)
|
||||
redactedAddr = u.Redacted()
|
||||
}
|
||||
|
||||
options := []retry.Option{
|
||||
|
14
src/lib/cache/util.go
vendored
14
src/lib/cache/util.go
vendored
@ -15,23 +15,9 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
"sync"
|
||||
)
|
||||
|
||||
// TODO: use the URL.Redacted when golang upgrade to 1.15
|
||||
func redacted(u *url.URL) string {
|
||||
if u == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
ru := *u
|
||||
if _, has := ru.User.Password(); has {
|
||||
ru.User = url.UserPassword(ru.User.Username(), "xxxxx")
|
||||
}
|
||||
return ru.String()
|
||||
}
|
||||
|
||||
type keyMutex struct {
|
||||
m *sync.Map
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user