open-vault/vault/mount_util_shared.go
Hamid Ghaf 27bb03bbc0
adding copyright header (#19555)
* adding copyright header

* fix fmt and a test
2023-03-15 09:00:52 -07:00

32 lines
837 B
Go

// Copyright (c) HashiCorp, Inc.
// SPDX-License-Identifier: MPL-2.0
package vault
import (
"github.com/hashicorp/vault/sdk/logical"
)
func (c *Core) addBackendWriteForwardedPaths(backend logical.Backend, viewPath string) {
paths := collectBackendSpecialPaths(backend, viewPath, func(specialPaths *logical.Paths) []string {
return specialPaths.WriteForwardedStorage
})
c.logger.Trace("adding write forwarded paths", "paths", paths)
c.writeForwardedPaths.AddPaths(paths)
}
func collectBackendSpecialPaths(backend logical.Backend, viewPath string, accessor func(specialPaths *logical.Paths) []string) []string {
if backend == nil || backend.SpecialPaths() == nil {
return nil
}
paths := accessor(backend.SpecialPaths())
var ret []string
for _, path := range paths {
ret = append(ret, viewPath+path)
}
return ret
}