Skip to content

Commit

Permalink
Scheduled triggers should be refreshed when the mod file has changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
vhadianto committed Feb 21, 2024
1 parent 1b7887d commit d0a0d51
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ _Bug fixes_
* Pipeline output attributes are now validated ([#239](https://github.com/turbot/pipe-fittings/issues/239)).
* Pipeline param default value data type is now validated against the specified type ([#262](https://github.com/turbot/pipe-fittings/issues/262)).
* Removed titles when merging multiple error messages ([#263](https://github.com/turbot/pipe-fittings/issues/263)).
* Scheduled triggers should be refreshed when the mod file has changed.

## v0.2.3 [2024-02-13]

Expand Down
28 changes: 28 additions & 0 deletions internal/es/estest/test_suite_mod/triggers/scheduled.fp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
trigger "schedule" "every_minute" {
enabled = false
schedule = "* * * * *"
pipeline = pipeline.two_params

args = {
param_one = "joe"
}
}


pipeline "two_params" {
param "param_one" {
default = "default value for param one"
}

param "param_two" {
default = "default value for param two"
}

output "one" {
value = param.param_one
}

output "two" {
value = param.param_two
}
}
9 changes: 8 additions & 1 deletion internal/trigger/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/hashicorp/hcl/v2"
"github.com/spf13/viper"
"github.com/turbot/flowpipe/internal/es/db"
"github.com/turbot/flowpipe/internal/es/event"
"github.com/turbot/flowpipe/internal/es/handler"
"github.com/turbot/flowpipe/internal/fqueue"
Expand Down Expand Up @@ -92,7 +93,13 @@ func (tr *TriggerRunnerBase) Run() {
return
}

pipelineArgs, diags := tr.Trigger.GetArgs(evalContext)
latestTrigger, err := db.GetTrigger(tr.Trigger.Name())
if err != nil {
slog.Error("Error getting latest trigger", "trigger", tr.Trigger.Name(), "error", err)
return
}

pipelineArgs, diags := latestTrigger.GetArgs(evalContext)

if diags.HasErrors() {
slog.Error("Error getting trigger args", "trigger", tr.Trigger.Name(), "errors", diags)
Expand Down

0 comments on commit d0a0d51

Please sign in to comment.