feat(vautl_cfg): add path & name for vault
This commit is contained in:
parent
21631a80e5
commit
c9bba78565
6 changed files with 16 additions and 10 deletions
|
|
@ -9,6 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type initializeCommand struct {
|
type initializeCommand struct {
|
||||||
|
VaultName string `json:"vaultName"`
|
||||||
VaultPath string `json:"vaultPath"`
|
VaultPath string `json:"vaultPath"`
|
||||||
TemplateDirectory string `json:"templateDirectory"`
|
TemplateDirectory string `json:"templateDirectory"`
|
||||||
}
|
}
|
||||||
|
|
@ -26,9 +27,9 @@ func (h InitializeHandler) Handle(ctx context.Context, raw json.RawMessage) (any
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
store := store.NewVaultStore(cmd.VaultPath, cmd.TemplateDirectory)
|
store := store.NewVaultStore(cmd.VaultName, cmd.VaultPath, cmd.TemplateDirectory)
|
||||||
|
|
||||||
err := persistence.InitializeDBContext(store.Config.VaultPath())
|
err := persistence.InitializeDBContext(store.Config.VaultName())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
BIN
dendrite
BIN
dendrite
Binary file not shown.
|
|
@ -1,12 +1,17 @@
|
||||||
package persistenceconfig
|
package persistenceconfig
|
||||||
|
|
||||||
type VaultConfiguration struct {
|
type VaultConfiguration struct {
|
||||||
|
name string
|
||||||
path string
|
path string
|
||||||
templateDirectory string
|
templateDirectory string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewVaultConfiguration(vaultPath, templateDirectory string) *VaultConfiguration {
|
func NewVaultConfiguration(vaultName, vaultPath, templateDirectory string) *VaultConfiguration {
|
||||||
return &VaultConfiguration{path: vaultPath, templateDirectory: templateDirectory}
|
return &VaultConfiguration{name: vaultName, path: vaultPath, templateDirectory: templateDirectory}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (vc *VaultConfiguration) VaultName() string {
|
||||||
|
return vc.name
|
||||||
}
|
}
|
||||||
|
|
||||||
func (vc *VaultConfiguration) VaultPath() string {
|
func (vc *VaultConfiguration) VaultPath() string {
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,8 @@ type Database struct {
|
||||||
var dbContext *Database
|
var dbContext *Database
|
||||||
|
|
||||||
|
|
||||||
func InitializeDBContext(vaultPath string) (error) {
|
func InitializeDBContext(vaultName string) (error) {
|
||||||
db, err := InitializeIndex(vaultPath)
|
db, err := InitializeIndex(vaultName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,11 +12,11 @@ type VaultStore struct {
|
||||||
|
|
||||||
var vaultStore *VaultStore
|
var vaultStore *VaultStore
|
||||||
|
|
||||||
func NewVaultStore(vault, templateDir string) *VaultStore {
|
func NewVaultStore(vaultName, vaultPath, templateDir string) *VaultStore {
|
||||||
if vaultStore != nil {
|
if vaultStore != nil {
|
||||||
return vaultStore
|
return vaultStore
|
||||||
}
|
}
|
||||||
vaultStore = &VaultStore{Config: persistenceconfig.NewVaultConfiguration(vault, templateDir)}
|
vaultStore = &VaultStore{Config: persistenceconfig.NewVaultConfiguration(vaultName, vaultPath, templateDir)}
|
||||||
return vaultStore
|
return vaultStore
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ func NewDBFixture() *DBFixture {
|
||||||
DB: dbContext.DB,
|
DB: dbContext.DB,
|
||||||
DBPath: dbPath,
|
DBPath: dbPath,
|
||||||
TestContext: context.Background(),
|
TestContext: context.Background(),
|
||||||
VaultStore: store.NewVaultStore(vaultPath, path.Join(vaultPath, "templates")),
|
VaultStore: store.NewVaultStore("testVault", vaultPath, path.Join(vaultPath, "templates")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue