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 {
|
||||
VaultName string `json:"vaultName"`
|
||||
VaultPath string `json:"vaultPath"`
|
||||
TemplateDirectory string `json:"templateDirectory"`
|
||||
}
|
||||
|
|
@ -26,9 +27,9 @@ func (h InitializeHandler) Handle(ctx context.Context, raw json.RawMessage) (any
|
|||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
|||
BIN
dendrite
BIN
dendrite
Binary file not shown.
|
|
@ -1,12 +1,17 @@
|
|||
package persistenceconfig
|
||||
|
||||
type VaultConfiguration struct {
|
||||
name string
|
||||
path string
|
||||
templateDirectory string
|
||||
}
|
||||
|
||||
func NewVaultConfiguration(vaultPath, templateDirectory string) *VaultConfiguration {
|
||||
return &VaultConfiguration{path: vaultPath, templateDirectory: templateDirectory}
|
||||
func NewVaultConfiguration(vaultName, vaultPath, templateDirectory string) *VaultConfiguration {
|
||||
return &VaultConfiguration{name: vaultName, path: vaultPath, templateDirectory: templateDirectory}
|
||||
}
|
||||
|
||||
func (vc *VaultConfiguration) VaultName() string {
|
||||
return vc.name
|
||||
}
|
||||
|
||||
func (vc *VaultConfiguration) VaultPath() string {
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ type Database struct {
|
|||
var dbContext *Database
|
||||
|
||||
|
||||
func InitializeDBContext(vaultPath string) (error) {
|
||||
db, err := InitializeIndex(vaultPath)
|
||||
func InitializeDBContext(vaultName string) (error) {
|
||||
db, err := InitializeIndex(vaultName)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,11 +12,11 @@ type VaultStore struct {
|
|||
|
||||
var vaultStore *VaultStore
|
||||
|
||||
func NewVaultStore(vault, templateDir string) *VaultStore {
|
||||
func NewVaultStore(vaultName, vaultPath, templateDir string) *VaultStore {
|
||||
if vaultStore != nil {
|
||||
return vaultStore
|
||||
}
|
||||
vaultStore = &VaultStore{Config: persistenceconfig.NewVaultConfiguration(vault, templateDir)}
|
||||
vaultStore = &VaultStore{Config: persistenceconfig.NewVaultConfiguration(vaultName, vaultPath, templateDir)}
|
||||
return vaultStore
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ type DBFixture struct {
|
|||
DB *sql.DB
|
||||
DBPath string
|
||||
TestContext context.Context
|
||||
VaultStore *store.VaultStore
|
||||
VaultStore *store.VaultStore
|
||||
}
|
||||
|
||||
func NewDBFixture() *DBFixture {
|
||||
|
|
@ -38,7 +38,7 @@ func NewDBFixture() *DBFixture {
|
|||
DB: dbContext.DB,
|
||||
DBPath: dbPath,
|
||||
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