mirror of
https://github.com/datarhei/core.git
synced 2025-09-26 20:11:29 +08:00
Fix proper version handling for uploading a new config
This commit is contained in:
@@ -16,6 +16,8 @@ import (
|
||||
|
||||
"github.com/datarhei/core/v16/app"
|
||||
"github.com/datarhei/core/v16/config"
|
||||
configstore "github.com/datarhei/core/v16/config/store"
|
||||
configvars "github.com/datarhei/core/v16/config/vars"
|
||||
"github.com/datarhei/core/v16/ffmpeg"
|
||||
"github.com/datarhei/core/v16/http"
|
||||
"github.com/datarhei/core/v16/http/cache"
|
||||
@@ -96,7 +98,7 @@ type api struct {
|
||||
|
||||
config struct {
|
||||
path string
|
||||
store config.Store
|
||||
store configstore.Store
|
||||
config *config.Config
|
||||
}
|
||||
|
||||
@@ -145,7 +147,7 @@ func (a *api) Reload() error {
|
||||
|
||||
logger := log.New("Core").WithOutput(log.NewConsoleWriter(a.log.writer, log.Lwarn, true))
|
||||
|
||||
store, err := config.NewJSONStore(a.config.path, func() {
|
||||
store, err := configstore.NewJSON(a.config.path, func() {
|
||||
a.errorChan <- ErrConfigReload
|
||||
})
|
||||
if err != nil {
|
||||
@@ -157,7 +159,7 @@ func (a *api) Reload() error {
|
||||
cfg.Merge()
|
||||
|
||||
if len(cfg.Host.Name) == 0 && cfg.Host.Auto {
|
||||
cfg.SetPublicIPs()
|
||||
cfg.Host.Name = net.GetPublicIPs(5 * time.Second)
|
||||
}
|
||||
|
||||
cfg.Validate(false)
|
||||
@@ -226,7 +228,7 @@ func (a *api) Reload() error {
|
||||
logger.Info().WithFields(logfields).Log("")
|
||||
|
||||
configlogger := logger.WithComponent("Config")
|
||||
cfg.Messages(func(level string, v config.Variable, message string) {
|
||||
cfg.Messages(func(level string, v configvars.Variable, message string) {
|
||||
configlogger = configlogger.WithFields(log.Fields{
|
||||
"variable": v.Name,
|
||||
"value": v.Value,
|
||||
|
@@ -4,7 +4,8 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/datarhei/core/v16/config"
|
||||
cfgstore "github.com/datarhei/core/v16/config/store"
|
||||
cfgvars "github.com/datarhei/core/v16/config/vars"
|
||||
"github.com/datarhei/core/v16/log"
|
||||
"github.com/datarhei/core/v16/restream/store"
|
||||
|
||||
@@ -14,7 +15,7 @@ import (
|
||||
func main() {
|
||||
logger := log.New("Import").WithOutput(log.NewConsoleWriter(os.Stderr, log.Linfo, true)).WithField("version", "v1")
|
||||
|
||||
configstore, err := config.NewJSONStore(os.Getenv("CORE_CONFIGFILE"), nil)
|
||||
configstore, err := cfgstore.NewJSON(os.Getenv("CORE_CONFIGFILE"), nil)
|
||||
if err != nil {
|
||||
logger.Error().WithError(err).Log("Loading configuration failed")
|
||||
os.Exit(1)
|
||||
@@ -25,7 +26,7 @@ func main() {
|
||||
}
|
||||
}
|
||||
|
||||
func doImport(logger log.Logger, configstore config.Store) error {
|
||||
func doImport(logger log.Logger, configstore cfgstore.Store) error {
|
||||
if logger == nil {
|
||||
logger = log.New("")
|
||||
}
|
||||
@@ -41,7 +42,7 @@ func doImport(logger log.Logger, configstore config.Store) error {
|
||||
if cfg.HasErrors() {
|
||||
logger.Error().Log("The configuration contains errors")
|
||||
messages := []string{}
|
||||
cfg.Messages(func(level string, v config.Variable, message string) {
|
||||
cfg.Messages(func(level string, v cfgvars.Variable, message string) {
|
||||
if level == "error" {
|
||||
logger.Error().WithFields(log.Fields{
|
||||
"variable": v.Name,
|
||||
|
@@ -3,12 +3,12 @@ package main
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/datarhei/core/v16/config"
|
||||
"github.com/datarhei/core/v16/config/store"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestImport(t *testing.T) {
|
||||
configstore := config.NewDummyStore()
|
||||
configstore := store.NewDummy()
|
||||
|
||||
cfg := configstore.Get()
|
||||
|
||||
|
Reference in New Issue
Block a user