diff --git a/config.yaml b/config.yaml index 4e51976..95968c8 100644 --- a/config.yaml +++ b/config.yaml @@ -154,21 +154,23 @@ actions: icon: box shell: docker start {{ container.Names }} entity: container + trigger: Update container entity file - title: Stop {{ container.Names }} icon: box shell: docker stop {{ container.Names }} entity: container + trigger: Update container entity file # Lastly, you can hide actions from the web UI, this is useful for creating # background helpers that execute only on startup or a cron, for updating # entity files. - # - title: Update container entity file - # shell: 'docker ps -a --format json > /etc/OliveTin/containers.json' - # hidden: true - # execOnStartup: true - # execOnCron: '*/1 * * * *' + - title: Update container entity file + shell: 'docker ps -a --format json > /etc/OliveTin/entities/containers.json' + hidden: true + execOnStartup: true + execOnCron: '*/1 * * * *' # An entity is something that exists - a "thing", like a VM, or a Container # is an entity. OliveTin allows you to then dynamically generate actions based diff --git a/internal/config/config.go b/internal/config/config.go index b538643..8babebb 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -17,6 +17,7 @@ type Action struct { ExecOnCron []string ExecOnFileCreatedInDir []string ExecOnFileChangedInDir []string + Trigger string MaxConcurrent int Arguments []ActionArgument PopupOnStart string diff --git a/internal/executor/executor.go b/internal/executor/executor.go index 8a770ce..c218a06 100644 --- a/internal/executor/executor.go +++ b/internal/executor/executor.go @@ -89,6 +89,7 @@ func DefaultExecutor() *Executor { stepExec, stepExecAfter, stepLogFinish, + stepTrigger, } return &e @@ -357,3 +358,19 @@ func stepExecAfter(req *ExecutionRequest) bool { return true } + +func stepTrigger(req *ExecutionRequest) bool { + if req.Action.Trigger != "" { + trigger := &ExecutionRequest{ + ActionTitle: req.Action.Trigger, + TrackingID: uuid.NewString(), + Tags: []string{"trigger"}, + AuthenticatedUser: req.AuthenticatedUser, + Cfg: req.Cfg, + } + + req.executor.ExecRequest(trigger) + } + + return true +}