API + Data changes to support split up of stream keys and admin passwords

This commit is contained in:
Gabe Kangas
2022-11-29 16:05:44 -08:00
parent 1645451faa
commit c9e3ccad45
11 changed files with 116 additions and 37 deletions
+13 -2
View File
@@ -7,18 +7,23 @@ import (
)
const (
datastoreValuesVersion = 1
datastoreValuesVersion = 2
datastoreValueVersionKey = "DATA_STORE_VERSION"
)
func migrateDatastoreValues(datastore *Datastore) {
currentVersion, _ := _datastore.GetNumber(datastoreValueVersionKey)
if currentVersion == 0 {
currentVersion = datastoreValuesVersion
}
for v := currentVersion; v < datastoreValuesVersion; v++ {
log.Tracef("Migration datastore values from %d to %d\n", int(v), int(v+1))
log.Infof("Migration datastore values from %d to %d\n", int(v), int(v+1))
switch v {
case 0:
migrateToDatastoreValues1(datastore)
case 1:
migrateToDatastoreValues2(datastore)
default:
log.Fatalln("missing datastore values migration step")
}
@@ -47,3 +52,9 @@ func migrateToDatastoreValues1(datastore *Datastore) {
}
}
}
func migrateToDatastoreValues2(datastore *Datastore) {
oldAdminPassword, _ := datastore.GetString("stream_key")
_ = SetAdminPassword(oldAdminPassword)
_ = SetStreamKeys([]string{oldAdminPassword})
}