Rename View to StorageView to make it more distinct from SystemView

This commit is contained in:
Jeff Mitchell 2015-09-09 15:42:29 -04:00
parent f489c1c24e
commit 104b29ab04
6 changed files with 23 additions and 21 deletions

View File

@ -18,7 +18,7 @@ func Factory(conf *logical.BackendConfig) (logical.Backend, error) {
func Backend(conf *logical.BackendConfig) (*framework.Backend, error) {
// Initialize the salt
salt, err := salt.NewSalt(conf.View, nil)
salt, err := salt.NewSalt(conf.StorageView, nil)
if err != nil {
return nil, err
}
@ -82,7 +82,7 @@ func Backend(conf *logical.BackendConfig) (*framework.Backend, error) {
// but for now we want a smooth upgrade experience by automatically
// upgrading to use salting.
if salt.DidGenerate() {
if err := b.upgradeToSalted(conf.View); err != nil {
if err := b.upgradeToSalted(conf.StorageView); err != nil {
return nil, err
}
}

View File

@ -22,7 +22,7 @@ func Factory(conf *logical.BackendConfig) (logical.Backend, error) {
}
func Backend(conf *logical.BackendConfig) (*framework.Backend, error) {
salt, err := salt.NewSalt(conf.View, nil)
salt, err := salt.NewSalt(conf.StorageView, nil)
if err != nil {
return nil, err
}

View File

@ -33,7 +33,7 @@ type Backend interface {
// BackendConfig is provided to the factory to initialize the backend
type BackendConfig struct {
// View should not be stored, and should only be used for initialization
View Storage
StorageView Storage
// The backend should use this logger. The log should not contain any secrets.
Logger *log.Logger

View File

@ -25,8 +25,8 @@ const (
)
var (
// loadAuthFailed if loadCreddentials encounters an error
loadAuthFailed = errors.New("failed to setup auth table")
// errLoadAuthFailed if loadCreddentials encounters an error
errLoadAuthFailed = errors.New("failed to setup auth table")
)
// enableCredential is used to enable a new credential backend
@ -185,13 +185,13 @@ func (c *Core) loadCredentials() error {
raw, err := c.barrier.Get(coreAuthConfigPath)
if err != nil {
c.logger.Printf("[ERR] core: failed to read auth table: %v", err)
return loadAuthFailed
return errLoadAuthFailed
}
if raw != nil {
c.auth = &MountTable{}
if err := json.Unmarshal(raw.Value, c.auth); err != nil {
c.logger.Printf("[ERR] core: failed to decode auth table: %v", err)
return loadAuthFailed
return errLoadAuthFailed
}
}
@ -203,7 +203,7 @@ func (c *Core) loadCredentials() error {
// Create and persist the default auth table
c.auth = defaultAuthTable()
if err := c.persistAuth(c.auth); err != nil {
return loadAuthFailed
return errLoadAuthFailed
}
return nil
}
@ -247,7 +247,7 @@ func (c *Core) setupCredentials() error {
c.logger.Printf(
"[ERR] core: failed to create credential entry %#v: %v",
entry, err)
return loadAuthFailed
return errLoadAuthFailed
}
// Mount the backend
@ -255,7 +255,7 @@ func (c *Core) setupCredentials() error {
err = c.router.Mount(backend, path, entry, view)
if err != nil {
c.logger.Printf("[ERR] core: failed to mount auth entry %#v: %v", entry, err)
return loadAuthFailed
return errLoadAuthFailed
}
// Ensure the path is tainted if set in the mount table
@ -288,10 +288,9 @@ func (c *Core) newCredentialBackend(
}
config := &logical.BackendConfig{
View: view,
StorageView: view,
Logger: c.logger,
Config: conf,
System: sysView,
}
b, err := f(config)

View File

@ -62,7 +62,7 @@ func PassthroughBackendFactory(conf *logical.BackendConfig) (logical.Backend, er
}
// PassthroughBackend is used storing secrets directly into the physical
// backend. The secrest are encrypted in the durable storage and custom TTL
// backend. The secrets are encrypted in the durable storage and custom TTL
// information can be specified, but otherwise this backend doesn't do anything
// fancy.
type PassthroughBackend struct {

View File

@ -486,10 +486,13 @@ func (c *Core) newLogicalBackend(t string, sysView logical.SystemView, view logi
}
config := &logical.BackendConfig{
View: view,
StorageView: view,
Logger: c.logger,
Config: conf,
System: sysView,
System: &logical.StaticSystemView{
DefaultLeaseTTLVal: c.defaultLeaseTTL,
MaxLeaseTTLVal: c.maxLeaseTTL,
},
}
b, err := f(config)