-
Notifications
You must be signed in to change notification settings - Fork 90
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
Allow runner specifications for local connections #225
Conversation
This allows for overriding the default runner selection. For example, when running InSpec unit tests via AppVeyor on Windows the mock file loads would create too many named pipe processes thus exhausting available resources. Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
lib/train/transports/local.rb
Outdated
WindowsPipeRunner.new | ||
when 'windows_shell' | ||
WindowsShellRunner.new | ||
end |
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.
We should probably raise an exception if a runner was supplied that we don't support.
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.
Good catch, will add an exception.
lib/train/transports/local.rb
Outdated
def run_command_via_connection(cmd) | ||
@runner.run_command(cmd) | ||
if defined?(@runner) |
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.
If we add the exception handling above, do we need this change? Would there ever be a case where we didn't have a valid @runner
?
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.
Yes, the first few commands run do not use GenericRunner
, but instead just use ShellOut
.
The difference being that GenericRunner attempts to do the CommandWrapper
bits.
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.
Got it, I understand.
We can probably then just clean this up a wee bit.
def run_command_via_connection(cmd)
# use the runner if it's defined
return @runner.run_command(cmd) if defined?(@runner)
# if we don't have a runner, such as at the beginning of setting up the transport
# and while we're performing the first few steps of OS detection, fall back to
# standard shelling out.
res = Mixlib::ShellOut.new(cmd.
... etc ...
end
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.
Love it. Much nicer! Will make it so.
lib/train/transports/local.rb
Outdated
@runner = WindowsShellRunner.new | ||
end | ||
end | ||
@runner = if options[:runner] |
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 also wonder if this should be :command_runner
and not just :runner
in case we have file runners, etc. in the future.
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.
Don't see any reason not to do it. Will make it so.
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
1cc9137
to
39f9245
Compare
Signed-off-by: Jerry Aldrich <jerryaldrichiii@gmail.com>
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.
Fantastic fix thank you @jerryaldrichiii !
This allows for overriding the default runner selection. For example, when running InSpec unit tests via AppVeyor on Windows the mock file loads would create too many named pipe processes thus exhausting available resources.