feature: entity filepaths are relative to the config dir
This commit is contained in:
parent
7464ca5543
commit
32cb8dd873
|
|
@ -207,10 +207,10 @@ entities:
|
||||||
# will load properly.
|
# will load properly.
|
||||||
#
|
#
|
||||||
# Docs: https://docs.olivetin.app/entities.html
|
# Docs: https://docs.olivetin.app/entities.html
|
||||||
- file: /etc/OliveTin/entities/servers.yaml
|
- file: entities/servers.yaml
|
||||||
name: server
|
name: server
|
||||||
|
|
||||||
- file: /etc/OliveTin/entities/containers.json
|
- file: entities/containers.json
|
||||||
name: container
|
name: container
|
||||||
|
|
||||||
# Dashboards are a way of taking actions from the default "actions" view, and
|
# Dashboards are a way of taking actions from the default "actions" view, and
|
||||||
|
|
|
||||||
|
|
@ -8,15 +8,30 @@ import (
|
||||||
sv "github.com/OliveTin/OliveTin/internal/stringvariables"
|
sv "github.com/OliveTin/OliveTin/internal/stringvariables"
|
||||||
"github.com/fsnotify/fsnotify"
|
"github.com/fsnotify/fsnotify"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
"github.com/spf13/viper"
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func SetupEntityFileWatchers(cfg *config.Config) {
|
func SetupEntityFileWatchers(cfg *config.Config) {
|
||||||
|
configDir := filepath.Dir(viper.ConfigFileUsed())
|
||||||
|
|
||||||
for _, ef := range cfg.Entities {
|
for _, ef := range cfg.Entities {
|
||||||
go watch(ef.File, ef.Name)
|
p := ef.File
|
||||||
loadEntityFile(ef.File, ef.Name)
|
|
||||||
|
if !filepath.IsAbs(p) {
|
||||||
|
p = filepath.Join(configDir, p)
|
||||||
|
|
||||||
|
log.WithFields(log.Fields{
|
||||||
|
"entityFile": p,
|
||||||
|
}).Debugf("Adding config dir to entity file path")
|
||||||
|
}
|
||||||
|
|
||||||
|
go watch(p, ef.Name)
|
||||||
|
|
||||||
|
loadEntityFile(p, ef.Name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue