feat: add Sense device inventory and credential boundary (#23)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
package sense
|
||||
|
||||
import (
|
||||
"os"
|
||||
"yovision.local/sense/app/sense/device"
|
||||
"yovision.local/sense/internal/platform"
|
||||
)
|
||||
|
||||
func init() {
|
||||
registerModule(func(app *platform.App) error {
|
||||
memory := app.Config().DatabaseMode == platform.DatabaseModeMemory
|
||||
vault, err := device.NewCredentialVault(os.Getenv("SENSE_CREDENTIAL_KEY"), memory)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var store device.Store
|
||||
if memory {
|
||||
store = device.NewMemoryStore()
|
||||
} else {
|
||||
store = device.NewPostgresStore(app.Database())
|
||||
}
|
||||
app.RegisterMigration(platform.Migration{Version: 2026081202, Name: "sense_device", SQL: device.MigrationSQL})
|
||||
device.NewModule(device.NewService(store, vault)).Register(app)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user