Make DefaultSystemView StaticSystemView with statically-configured information. Export this from Framework to make it easy to override for testing.

This commit is contained in:
Jeff Mitchell
2015-08-27 11:25:07 -07:00
parent 003d53106a
commit 84be5cff30
4 changed files with 18 additions and 30 deletions

View File

@@ -56,10 +56,13 @@ type Backend struct {
// See the built-in AuthRenew helpers in lease.go for common callbacks.
AuthRenew OperationFunc
logger *log.Logger
once sync.Once
pathsRe []*regexp.Regexp
sysconfig logical.SystemView
// System provides an interface to access certain system configuration
// information, such as globally configured default and max lease TTLs.
System logical.SystemView
logger *log.Logger
once sync.Once
pathsRe []*regexp.Regexp
}
// OperationFunc is the callback called for an operation on a path.
@@ -143,7 +146,7 @@ func (b *Backend) SpecialPaths() *logical.Paths {
// Setup is used to initialize the backend with the initial backend configuration
func (b *Backend) Setup(config *logical.BackendConfig) (logical.Backend, error) {
b.logger = config.Logger
b.sysconfig = config.System
b.System = config.System
return b, nil
}
@@ -157,13 +160,6 @@ func (b *Backend) Logger() *log.Logger {
return log.New(ioutil.Discard, "", 0)
}
// SystemConfig can be used to get an object that provides methods for
// looking up some system configuration information, such as the global
// max lease.
func (b *Backend) SystemConfig() logical.SystemView {
return b.sysconfig
}
// Route looks up the path that would be used for a given path string.
func (b *Backend) Route(path string) *Path {
result, _ := b.route(path)