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.
|
||||
#
|
||||
# Docs: https://docs.olivetin.app/entities.html
|
||||
- file: /etc/OliveTin/entities/servers.yaml
|
||||
- file: entities/servers.yaml
|
||||
name: server
|
||||
|
||||
- file: /etc/OliveTin/entities/containers.json
|
||||
- file: entities/containers.json
|
||||
name: container
|
||||
|
||||
# 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"
|
||||
"github.com/fsnotify/fsnotify"
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/spf13/viper"
|
||||
"gopkg.in/yaml.v3"
|
||||
"io/ioutil"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func SetupEntityFileWatchers(cfg *config.Config) {
|
||||
configDir := filepath.Dir(viper.ConfigFileUsed())
|
||||
|
||||
for _, ef := range cfg.Entities {
|
||||
go watch(ef.File, ef.Name)
|
||||
loadEntityFile(ef.File, ef.Name)
|
||||
p := ef.File
|
||||
|
||||
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