-
Notifications
You must be signed in to change notification settings - Fork 0
Review comments #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,20 +15,38 @@ | |
| */ | ||
| package io.serverlessworkflow.impl.container.executors; | ||
|
|
||
| import static io.serverlessworkflow.impl.WorkflowUtils.isValid; | ||
|
|
||
| import com.github.dockerjava.api.command.CreateContainerCmd; | ||
| import io.serverlessworkflow.api.types.Container; | ||
| import java.util.function.Function; | ||
| import io.serverlessworkflow.impl.TaskContext; | ||
| import io.serverlessworkflow.impl.WorkflowContext; | ||
| import io.serverlessworkflow.impl.WorkflowDefinition; | ||
| import io.serverlessworkflow.impl.WorkflowModel; | ||
| import io.serverlessworkflow.impl.WorkflowUtils; | ||
| import io.serverlessworkflow.impl.WorkflowValueResolver; | ||
| import java.util.Optional; | ||
|
|
||
| class CommandPropertySetter implements ContainerPropertySetter { | ||
|
|
||
| class CommandPropertySetter extends ContainerPropertySetter { | ||
| private Optional<WorkflowValueResolver<String>> command; | ||
|
|
||
| CommandPropertySetter(CreateContainerCmd createContainerCmd, Container configuration) { | ||
| super(createContainerCmd, configuration); | ||
| CommandPropertySetter(WorkflowDefinition definition, Container configuration) { | ||
| String commandName = configuration.getCommand(); | ||
| command = | ||
| isValid(commandName) | ||
| ? Optional.of(WorkflowUtils.buildStringFilter(definition.application(), commandName)) | ||
| : Optional.empty(); | ||
| } | ||
|
|
||
| @Override | ||
| public void accept(Function<String, String> resolver) { | ||
| if (configuration.getCommand() != null && !configuration.getCommand().isEmpty()) { | ||
| createContainerCmd.withCmd("sh", "-c", configuration.getCommand()); | ||
| } | ||
| public void accept( | ||
| CreateContainerCmd containerCmd, | ||
| WorkflowContext workflowContext, | ||
| TaskContext taskContext, | ||
| WorkflowModel model) { | ||
| command | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. During runtime, we evaluate the filter and then set container command with that info |
||
| .map(c -> c.apply(workflowContext, taskContext, model)) | ||
| .ifPresent(c -> containerCmd.withCmd("sh", "-c", c)); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -16,17 +16,14 @@ | |
| package io.serverlessworkflow.impl.container.executors; | ||
|
|
||
| import com.github.dockerjava.api.command.CreateContainerCmd; | ||
| import io.serverlessworkflow.api.types.Container; | ||
| import java.util.function.Consumer; | ||
| import java.util.function.Function; | ||
| import io.serverlessworkflow.impl.TaskContext; | ||
| import io.serverlessworkflow.impl.WorkflowContext; | ||
| import io.serverlessworkflow.impl.WorkflowModel; | ||
|
|
||
| abstract class ContainerPropertySetter implements Consumer<Function<String, String>> { | ||
|
|
||
| protected final CreateContainerCmd createContainerCmd; | ||
| protected final Container configuration; | ||
|
|
||
| ContainerPropertySetter(CreateContainerCmd createContainerCmd, Container configuration) { | ||
| this.createContainerCmd = createContainerCmd; | ||
| this.configuration = configuration; | ||
| } | ||
| interface ContainerPropertySetter { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ContainerPropertySetter is now a interface which implementations add things to the container command |
||
| abstract void accept( | ||
| CreateContainerCmd command, | ||
| WorkflowContext workflowContext, | ||
| TaskContext taskContext, | ||
| WorkflowModel model); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
During parsing time (when the constructor is invoked) we create the filter to resolve the command