vault: Adding mount type
This commit is contained in:
parent
8ec69eae81
commit
ff5834ddb4
|
@ -24,13 +24,14 @@ func NewRouter() *Router {
|
||||||
|
|
||||||
// mountEntry is used to represent a mount point
|
// mountEntry is used to represent a mount point
|
||||||
type mountEntry struct {
|
type mountEntry struct {
|
||||||
|
mtype string
|
||||||
backend LogicalBackend
|
backend LogicalBackend
|
||||||
view *BarrierView
|
view *BarrierView
|
||||||
rootPaths *radix.Tree
|
rootPaths *radix.Tree
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mount is used to expose a logical backend at a given prefix
|
// Mount is used to expose a logical backend at a given prefix
|
||||||
func (r *Router) Mount(backend LogicalBackend, prefix string, view *BarrierView) error {
|
func (r *Router) Mount(backend LogicalBackend, mtype, prefix string, view *BarrierView) error {
|
||||||
r.l.Lock()
|
r.l.Lock()
|
||||||
defer r.l.Unlock()
|
defer r.l.Unlock()
|
||||||
|
|
||||||
|
@ -56,6 +57,7 @@ func (r *Router) Mount(backend LogicalBackend, prefix string, view *BarrierView)
|
||||||
|
|
||||||
// Create a mount entry
|
// Create a mount entry
|
||||||
me := &mountEntry{
|
me := &mountEntry{
|
||||||
|
mtype: mtype,
|
||||||
backend: backend,
|
backend: backend,
|
||||||
view: view,
|
view: view,
|
||||||
rootPaths: rootPaths,
|
rootPaths: rootPaths,
|
||||||
|
|
|
@ -29,12 +29,12 @@ func TestRouter_Mount(t *testing.T) {
|
||||||
view := NewBarrierView(barrier, "logical/")
|
view := NewBarrierView(barrier, "logical/")
|
||||||
|
|
||||||
n := &NoopBackend{}
|
n := &NoopBackend{}
|
||||||
err := r.Mount(n, "prod/aws/", view)
|
err := r.Mount(n, "noop", "prod/aws/", view)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = r.Mount(n, "prod/aws/", view)
|
err = r.Mount(n, "noop", "prod/aws/", view)
|
||||||
if !strings.Contains(err.Error(), "cannot mount under existing mount") {
|
if !strings.Contains(err.Error(), "cannot mount under existing mount") {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ func TestRouter_Unmount(t *testing.T) {
|
||||||
view := NewBarrierView(barrier, "logical/")
|
view := NewBarrierView(barrier, "logical/")
|
||||||
|
|
||||||
n := &NoopBackend{}
|
n := &NoopBackend{}
|
||||||
err := r.Mount(n, "prod/aws/", view)
|
err := r.Mount(n, "noop", "prod/aws/", view)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func TestRouter_Remount(t *testing.T) {
|
||||||
view := NewBarrierView(barrier, "logical/")
|
view := NewBarrierView(barrier, "logical/")
|
||||||
|
|
||||||
n := &NoopBackend{}
|
n := &NoopBackend{}
|
||||||
err := r.Mount(n, "prod/aws/", view)
|
err := r.Mount(n, "noop", "prod/aws/", view)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ func TestRouter_RootPath(t *testing.T) {
|
||||||
"policy/*",
|
"policy/*",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err := r.Mount(n, "prod/aws/", view)
|
err := r.Mount(n, "noop", "prod/aws/", view)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue