hyperkit 1.0.2 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 31c1d9b05f7078a592ef2e0fcfaee2715cd16484
4
- data.tar.gz: 12e2f1eabed87b1691627e1c1a884eaaaaedc94f
3
+ metadata.gz: bf6274925427cf1c5670ea2af9eac26f7c959c3e
4
+ data.tar.gz: 2ba1e84fb843852eb70f07622b2a64b7407dd629
5
5
  SHA512:
6
- metadata.gz: 7608210cba76349bf7530ef5ea62e05be8b4e4e4f17654e0bbf772cc38554a0d7caf69297b483eccdba2bf0a61a8747996ca535b1d40584efa8456621e9edf25
7
- data.tar.gz: a38a4bd0fb00a4368d8d2919472e3e3378123cc358fe9dd3f58ffe70f8b6b4a7bd95b06a543e574ebdf6baa5997abf20cbd617da4dc88b98ab4575662aa6a78f
6
+ metadata.gz: d2387348bed823792209239144e5f46157aff3c470a12531956392cc1dab6c8b76badde557a36c5208eea70a8cbd695267cd753ec8a53ece6125bf7fbd0a9491
7
+ data.tar.gz: 7a82b8c65626199c48c9eff76834662d81b9822904f4f6e4f5abd60964096ec6831825797a3770df919fc3b0962144375824ccb5a2c8e6bc725ad1c664cdff1c
@@ -284,6 +284,9 @@ module Hyperkit
284
284
  # @param options [Hash] Additional data to be passed
285
285
  # @option options [Hash] :environment Environment variables to set prior to command execution
286
286
  # @option options [Boolean] :sync If <code>false</code>, returns an asynchronous operation that must be passed to {Hyperkit::Client::Operations#wait_for_operation}. If <code>true</code>, automatically waits and returns the result of the operation. Defaults to value of {Hyperkit::Configurable#auto_sync}.
287
+ # @option options [Boolean] :wait_for_websocket If <code>true</code> block and wait for a websocket connection to start.
288
+ # @option options [Boolean] :interactive If <code>true</code>a single websocket is returned and is mapped to a pts device for stdin, stdout and stderr of the execed process. If false, three pipes will be setup, one for each of stdin, stdout and stderr.
289
+ # @option options [Boolean] :record_output If <code>true</code>, captures the output of stdout and stderr.
287
290
  # @return [Sawyer::Resource] Operation or result, depending value of <code>:sync</code> parameter and/or {Hyperkit::Client::auto_sync}
288
291
  #
289
292
  # @example Run a command (passed as a string) in container "test-container"
@@ -312,8 +315,9 @@ module Hyperkit
312
315
  response = post(File.join(container_path(container), "exec"), {
313
316
  command: command,
314
317
  environment: opts[:environment] || {},
315
- "wait-for-websocket" => false,
316
- interactive: false
318
+ "wait-for-websocket" => options[:wait_for_websocket] || false,
319
+ interactive: options[:interactive] || false,
320
+ "record-output" => options[:record_output] || false
317
321
  }).metadata
318
322
 
319
323
  handle_async(response, options[:sync])
@@ -832,24 +836,31 @@ module Hyperkit
832
836
  #
833
837
  # @param container [String] Container name
834
838
  # @param source_file [String] Full path to a file within the container
835
- # @param dest_file [String] Full path of desired output file (will be created/overwritten)
839
+ # @param dest [String, IO] Full path of desired output file (will be created/overwritten), or an IO object to write to
836
840
  # @return [String] Full path to the local output file
837
841
  #
838
842
  # @example Copy /etc/passwd in container "test" to the local file /tmp/passwd
839
843
  # Hyperkit.pull_file("test", "/etc/passwd", "/tmp/passwd") #=> "/tmp/passwd"
840
- def pull_file(container, source_file, dest_file)
844
+ #
845
+ # @example Copy /etc/passwd in container "test" to a StringIO object
846
+ # Hyperkit.pull_file("test", "/etc/passwd", StringIO.new) #=> <StringIO:0x007fd196061a70>
847
+ def pull_file(container, source_file, dest)
841
848
  contents = get(file_path(container, source_file), url_encode: false)
842
849
  headers = last_response.headers
843
850
 
844
- File.open(dest_file, "wb") do |f|
845
- f.write(contents)
846
- end
851
+ if dest.respond_to? :write
852
+ dest.write(contents)
853
+ else
854
+ File.open(dest, "wb") do |f|
855
+ f.write(contents)
856
+ end
847
857
 
848
- if headers["x-lxd-mode"]
849
- File.chmod(headers["x-lxd-mode"].to_i(8), dest_file)
858
+ if headers["x-lxd-mode"]
859
+ File.chmod(headers["x-lxd-mode"].to_i(8), dest)
860
+ end
850
861
  end
851
862
 
852
- dest_file
863
+ dest
853
864
 
854
865
  end
855
866
 
@@ -909,7 +920,7 @@ module Hyperkit
909
920
  #
910
921
  # @param container [String] Container name
911
922
  # @param source_file [String] Full path to a file within the container
912
- # @param dest_file [String] Full path of desired output file (will be created/overwritten)
923
+ # @param dest [String, IO] Full path of desired output file (will be created/overwritten), or an IO object to write to
913
924
  # @param options [Hash] Additional data to be passed
914
925
  # @option options [Fixnum] :uid Owner to assign to the file
915
926
  # @option options [Fixnum] :gid Group to assign to the file
@@ -919,6 +930,9 @@ module Hyperkit
919
930
  # @example Copy /tmp/test.txt from the local system to /etc/passwd in the container
920
931
  # Hyperkit.push_file("/tmp/test.txt", "test-container", "/etc/passwd")
921
932
  #
933
+ # @example Write the contents of a StringIO object to /etc/passwd in the container
934
+ # Hyperkit.push_file(StringIO.new("test string"), "test-container", "/etc/passwd")
935
+ #
922
936
  # @example Assign uid, gid, and mode to a file:
923
937
  # Hyperkit.push_file("/tmp/test.txt",
924
938
  # "test-container",
@@ -927,10 +941,14 @@ module Hyperkit
927
941
  # gid: 1000,
928
942
  # mode: 0644
929
943
  # )
930
- def push_file(source_file, container, dest_file, options={})
944
+ def push_file(source, container, dest_file, options={})
931
945
 
932
946
  write_file(container, dest_file, options) do |f|
933
- f.write File.read(source_file)
947
+ if source.respond_to? :read
948
+ f.write source.read
949
+ else
950
+ f.write File.read(source)
951
+ end
934
952
  end
935
953
 
936
954
  end
@@ -1,3 +1,3 @@
1
1
  module Hyperkit
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperkit
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Shantz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-19 00:00:00.000000000 Z
11
+ date: 2016-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -109,9 +109,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.4.5
112
+ rubygems_version: 2.5.1
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Hyperkit is a flat API wrapper for LXD, the next-generation hypervisor
116
116
  test_files: []
117
- has_rdoc: