-
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
Enable caching on connections #214
Changes from all commits
e58f229
5f1ede5
a1784d8
31214ba
231bae3
1dba81b
b8cd014
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 |
---|---|---|
|
@@ -69,18 +69,27 @@ def close | |
# nothing to do at the moment | ||
end | ||
|
||
def file(path) | ||
@files[path] ||=\ | ||
if os.aix? | ||
Train::File::Remote::Aix.new(self, path) | ||
elsif os.solaris? | ||
Train::File::Remote::Unix.new(self, path) | ||
else | ||
Train::File::Remote::Linux.new(self, path) | ||
end | ||
def uri | ||
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. Is there a reason to make this public? 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. I think we need it for now as inspec calls it here: https://github.com/chef/inspec/blob/master/lib/inspec/rspec_json_formatter.rb#L561 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. Missed it, thank you. |
||
if @container.nil? | ||
"docker://#{@id}" | ||
else | ||
"docker://#{@container.id}" | ||
end | ||
end | ||
|
||
private | ||
|
||
def file_via_connection(path) | ||
if os.aix? | ||
Train::File::Remote::Aix.new(self, path) | ||
elsif os.solaris? | ||
Train::File::Remote::Unix.new(self, path) | ||
else | ||
Train::File::Remote::Linux.new(self, path) | ||
end | ||
end | ||
|
||
def run_command(cmd) | ||
def run_command_via_connection(cmd) | ||
cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil? | ||
stdout, stderr, exit_status = @container.exec( | ||
[ | ||
|
@@ -93,13 +102,5 @@ def run_command(cmd) | |
# @TODO: differentiate any other error | ||
raise | ||
end | ||
|
||
def uri | ||
if @container.nil? | ||
"docker://#{@id}" | ||
else | ||
"docker://#{@container.id}" | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,34 +23,35 @@ def initialize(options) | |
@cmd_wrapper = CommandWrapper.load(self, options) | ||
end | ||
|
||
def run_command(cmd) | ||
cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil? | ||
res = Mixlib::ShellOut.new(cmd) | ||
res.run_command | ||
CommandResult.new(res.stdout, res.stderr, res.exitstatus) | ||
rescue Errno::ENOENT => _ | ||
CommandResult.new('', '', 1) | ||
def login_command | ||
nil # none, open your shell | ||
end | ||
|
||
def uri | ||
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. Why are we exposing this one? |
||
'local://' | ||
end | ||
|
||
def local? | ||
true | ||
end | ||
|
||
def file(path) | ||
@files[path] ||= \ | ||
if os.windows? | ||
Train::File::Local::Windows.new(self, path) | ||
else | ||
Train::File::Local::Unix.new(self, path) | ||
end | ||
end | ||
private | ||
|
||
def login_command | ||
nil # none, open your shell | ||
def run_command_via_connection(cmd) | ||
cmd = @cmd_wrapper.run(cmd) unless @cmd_wrapper.nil? | ||
res = Mixlib::ShellOut.new(cmd) | ||
res.run_command | ||
CommandResult.new(res.stdout, res.stderr, res.exitstatus) | ||
rescue Errno::ENOENT => _ | ||
CommandResult.new('', '', 1) | ||
end | ||
|
||
def uri | ||
'local://' | ||
def file_via_connection(path) | ||
if os.windows? | ||
Train::File::Local::Windows.new(self, path) | ||
else | ||
Train::File::Local::Unix.new(self, path) | ||
end | ||
end | ||
end | ||
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.
Those two methods need to be private
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, moved.