wip: created example files with new config and implementing new config in init

This commit is contained in:
2024-03-24 13:24:47 +11:00
parent 6032b6c0c1
commit 8f68c4ace9
12 changed files with 108 additions and 28 deletions

View File

@@ -4,19 +4,43 @@ import (
"gitea.suyono.dev/suyono/wingmate/config"
wminit "gitea.suyono.dev/suyono/wingmate/init"
"gitea.suyono.dev/suyono/wingmate/task"
"github.com/spf13/viper"
"sync"
)
type wConfig struct {
tasks *task.Tasks
tasks *task.Tasks
config *config.Config
viperMtx *sync.Mutex
}
func (c *wConfig) Tasks() wminit.Tasks {
return c.tasks
}
func (c *wConfig) WMPidProxyPath() string {
c.viperMtx.Lock()
defer c.viperMtx.Unlock()
return viper.GetString(config.PidProxyPathConfig)
}
func (c *wConfig) WMExecPath() string {
c.viperMtx.Lock()
defer c.viperMtx.Unlock()
return viper.GetString(config.ExecPathConfig)
}
func (c *wConfig) Reload() error {
return nil
}
func convert(cfg *config.Config) *wConfig {
retval := &wConfig{
tasks: task.NewTasks(),
tasks: task.NewTasks(),
config: cfg,
viperMtx: &sync.Mutex{},
}
for _, s := range cfg.Service {

View File

@@ -14,7 +14,7 @@ func TestEntry_configPathEnv(t *testing.T) {
}
func TestEntry_configPathPFlag(t *testing.T) {
os.Args = []string{"wingmate", "--config", "/Volumes/Source/go/src/gitea.suyono.dev/suyono/wingmate/docker/bookworm/etc/wingmate"}
os.Args = []string{"wingmate", "--config", "/workspaces/wingmate/docker/bookworm-newconfig/etc/wingmate"}
main()
}