-
Notifications
You must be signed in to change notification settings - Fork 7
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
Introduce the ExecutorBuilder. #273
base: master
Are you sure you want to change the base?
Conversation
pkg/executor/executor_builder.go
Outdated
|
||
// ExecutorBuilder build executor with specific program and args | ||
type ExecutorBuilder interface { | ||
NewExecutor(program string, args ...string) Executor |
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.
or Simply New
?
pkg/executor/executor_builder.go
Outdated
// ExecutorBuilder build executor with specific program and args | ||
type ExecutorBuilder interface { | ||
NewExecutor(program string, args ...string) Executor | ||
NewShell(cmdline string) Executor |
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.
or NewExecutorShell
?
package executor | ||
|
||
type executorBuilderImpl struct { | ||
} |
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.
What do you think of keeping the struct private ?
executor.SetOutputPrefix("---") | ||
result := executor.Run() | ||
impl := executor.(*executorImpl) | ||
impl.outputWriter = buf |
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.
I was searching for a better way but i cannot think of something
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.
I think this is fine for now. We could improve this by introducing a executor.SetOutputWriter(writer)
at some point.
The I don't see the big picture about the builder interface... maybe this should be another PR, also including how we use this builder. |
Why
It would be handy to generate executor from the task context: in the future by example we would be able to keep trace of every requested commands.
How
This PR is introducing a set of interfaces for the ExecutorBuilder but also the Executor itself.
Following PR will add the builder into the TaskContext