diff --git a/core/handlers/vault/initialize_handler.go b/core/handlers/vault/initialize_handler.go index 4fc6ba6..17d18a6 100644 --- a/core/handlers/vault/initialize_handler.go +++ b/core/handlers/vault/initialize_handler.go @@ -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 } diff --git a/dendrite b/dendrite index a53eca9..3e1187f 100755 Binary files a/dendrite and b/dendrite differ diff --git a/persistence/config/vault_configuration.go b/persistence/config/vault_configuration.go index cd9a16a..6d1df17 100644 --- a/persistence/config/vault_configuration.go +++ b/persistence/config/vault_configuration.go @@ -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 { diff --git a/persistence/db_context.go b/persistence/db_context.go index 1d4397c..c1ac6c6 100644 --- a/persistence/db_context.go +++ b/persistence/db_context.go @@ -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 } diff --git a/persistence/store/vault_store.go b/persistence/store/vault_store.go index 17cbfca..d557a5a 100644 --- a/persistence/store/vault_store.go +++ b/persistence/store/vault_store.go @@ -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 } diff --git a/test/test_integration/main_test.go b/test/test_integration/main_test.go index 05acda7..d4464e4 100644 --- a/test/test_integration/main_test.go +++ b/test/test_integration/main_test.go @@ -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")), } }