Skip to content

Commit

Permalink
fix(trigger): add example with 'NONE' action
Browse files Browse the repository at this point in the history
  • Loading branch information
brian-mulier-p committed Jan 18, 2024
1 parent 00cdfc4 commit 790fc16
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/main/java/io/kestra/plugin/aws/s3/ActionInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

public interface ActionInterface {
@Schema(
title = "The action to perform on the retrieved files."
title = "The action to perform on the retrieved files. If using 'NONE' make sure to do some actions on the files to avoid infinite triggering."
)
@PluginProperty(dynamic = true)
@NotNull
ActionInterface.Action getAction();

@Schema(
title = "The destination bucket and key."
title = "The destination bucket and key for `MOVE` action."
)
@PluginProperty(dynamic = true)
Copy.CopyObject getMoveTo();
Expand Down
37 changes: 36 additions & 1 deletion src/main/java/io/kestra/plugin/aws/s3/Trigger.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,41 @@
" moveTo: ",
" key: archive",
}
),
@Example(
title = "Wait for a list of files on a s3 bucket and iterate through the files. Delete files manually after processing to prevent infinite triggering.",
full = true,
code = {
"id: s3-listen",
"namespace: io.kestra.tests",
"",
"tasks:",
" - id: each",
" type: io.kestra.core.tasks.flows.EachSequential",
" tasks:",
" - id: return",
" type: io.kestra.core.tasks.debugs.Return",
" format: \"{{ taskrun.value }}\"",
" - id: delete",
" type: io.kestra.plugin.aws.s3.Delete",
" accessKeyId: \"<access-key>\"",
" secretKeyId: \"<secret-key>\"",
" region: \"eu-central-1\"",
" bucket: \"my-bucket\"",
" key: \"{{ taskrun.value }}\"",
" value: \"{{ trigger.objects | jq('.[].key') }}\"",
"",
"triggers:",
" - id: watch",
" type: io.kestra.plugin.aws.s3.Trigger",
" interval: \"PT5M\"",
" accessKeyId: \"<access-key>\"",
" secretKeyId: \"<secret-key>\"",
" region: \"eu-central-1\"",
" bucket: \"my-bucket\"",
" prefix: \"sub-dir\"",
" action: NONE",
}
)
}
)
Expand Down Expand Up @@ -134,7 +169,7 @@ public Optional<Execution> evaluate(ConditionContext conditionContext, TriggerCo
.build();
List.Output run = task.run(runContext);

if (run.getObjects().size() == 0) {
if (run.getObjects().isEmpty()) {
return Optional.empty();
}

Expand Down

0 comments on commit 790fc16

Please sign in to comment.