mirror of
https://github.com/OliveTin/OliveTin
synced 2025-12-14 01:55:39 +00:00
* feature: Execute actions on startup. Externalize the executor and add tags to logs. * fmt: Codestyle fixes
33 lines
735 B
Go
33 lines
735 B
Go
package onstartup
|
|
|
|
import (
|
|
"github.com/OliveTin/OliveTin/internal/acl"
|
|
config "github.com/OliveTin/OliveTin/internal/config"
|
|
"github.com/OliveTin/OliveTin/internal/executor"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
func Execute(cfg *config.Config, ex *executor.Executor) {
|
|
user := &acl.AuthenticatedUser{
|
|
Username: "startup-user",
|
|
}
|
|
|
|
for _, action := range cfg.Actions {
|
|
if action.ExecOnStartup {
|
|
log.WithFields(log.Fields{
|
|
"action": action.Title,
|
|
}).Infof("Startup action")
|
|
|
|
req := &executor.ExecutionRequest{
|
|
ActionName: action.Title,
|
|
Arguments: nil,
|
|
Cfg: cfg,
|
|
Tags: []string{"startup"},
|
|
AuthenticatedUser: user,
|
|
}
|
|
|
|
ex.ExecRequest(req)
|
|
}
|
|
}
|
|
}
|