Merge pull request #46065 from corhere/libn/defuse-datastore-key-latent-race
libnetwork/datastore: prevent data races in Key()
This commit is contained in:
commit
7ced56b356
1 changed files with 8 additions and 3 deletions
|
@ -149,9 +149,14 @@ func (cfg *ScopeCfg) IsValid() bool {
|
|||
|
||||
// Key provides convenient method to create a Key
|
||||
func Key(key ...string) string {
|
||||
keychain := append(rootChain, key...)
|
||||
str := strings.Join(keychain, "/")
|
||||
return str + "/"
|
||||
var b strings.Builder
|
||||
for _, parts := range [][]string{rootChain, key} {
|
||||
for _, part := range parts {
|
||||
b.WriteString(part)
|
||||
b.WriteString("/")
|
||||
}
|
||||
}
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// ParseKey provides convenient method to unpack the key to complement the Key function
|
||||
|
|
Loading…
Add table
Reference in a new issue