docker-api 1.30.1 → 1.30.2

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: 210dd4b08216025bc2584e22ae74642679ca3f3c
4
- data.tar.gz: c6860ab766b1ca34d19bba5a70966ce695c471af
3
+ metadata.gz: 5e2975a50b698d9d6a2a5fdaecd477f160677427
4
+ data.tar.gz: e652feb4204f7e52d5877a388820dfd5a31c13e2
5
5
  SHA512:
6
- metadata.gz: ccc27921a9ae57766505c7893e06bbefed7757c685b3c597c24ab8a833a076195c3f04dc3a8f065b64dd1d2d5b05e27acaa6d3f17185faf41b236969c7346922
7
- data.tar.gz: 11a113c975cfea7953615ec8a26454b8e8d3d2fe31e881115816356848842a8972c6dc0f615d9a9dec67040edb0ec47be21f85bbc80388f013e2ec985901889b
6
+ metadata.gz: ab26e9e3ba3f505ad0ac1ebb8b594913128473f7d7900c35886d867f041ba2dad1259162cdda3ce4bd51634107a44736667c82f3205f5d804f2ca35f0808ea63
7
+ data.tar.gz: 4e5d8807fa2a6942662dea8a7e29e0fcc93deb4aa15fa097f29a9f265f765b961920df6276efc60c1e021d4d88fc9df81c35ab7c3aa90e7e61188e0381c644a6
@@ -119,8 +119,12 @@ module Docker::Util
119
119
  def create_tar(hash = {})
120
120
  output = StringIO.new
121
121
  Gem::Package::TarWriter.new(output) do |tar|
122
- hash.each do |file_name, input|
123
- tar.add_file(file_name, 0640) { |tar_file| tar_file.write(input) }
122
+ hash.each do |file_name, file_details|
123
+ permissions = file_details.is_a?(Hash) ? file_details[:permissions] : 0640
124
+ tar.add_file(file_name, permissions) do |tar_file|
125
+ content = file_details.is_a?(Hash) ? file_details[:content] : file_details
126
+ tar_file.write(content)
127
+ end
124
128
  end
125
129
  end
126
130
  output.tap(&:rewind).string
@@ -203,15 +207,26 @@ module Docker::Util
203
207
  basename = File.basename(local_path)
204
208
  if File.directory?(local_path)
205
209
  tar = create_dir_tar(local_path)
206
- file_hash[basename] = tar.read
210
+ file_hash[basename] = {
211
+ content: tar.read,
212
+ permissions: filesystem_permissions(local_path)
213
+ }
207
214
  tar.close
208
215
  FileUtils.rm(tar.path)
209
216
  else
210
- file_hash[basename] = File.read(local_path, mode: 'rb')
217
+ file_hash[basename] = {
218
+ content: File.read(local_path, mode: 'rb'),
219
+ permissions: filesystem_permissions(local_path)
220
+ }
211
221
  end
212
222
  end
213
223
  end
214
224
 
225
+ def filesystem_permissions(path)
226
+ mode = sprintf("%o", File.stat(path).mode)
227
+ mode[(mode.length - 3)...mode.length].to_i(8)
228
+ end
229
+
215
230
  def build_auth_header(credentials)
216
231
  credentials = credentials.to_json if credentials.is_a?(Hash)
217
232
  encoded_creds = Base64.encode64(credentials).gsub(/\n/, '')
@@ -1,6 +1,6 @@
1
1
  module Docker
2
2
  # The version of the docker-api gem.
3
- VERSION = '1.30.1'
3
+ VERSION = '1.30.2'
4
4
 
5
5
  # The version of the compatible Docker remote API.
6
6
  API_VERSION = '1.16'
@@ -1,4 +1,5 @@
1
1
  require 'spec_helper'
2
+ require 'tempfile'
2
3
 
3
4
  describe Docker::Util do
4
5
  subject { described_class }
@@ -151,4 +152,19 @@ describe Docker::Util do
151
152
  end
152
153
  end
153
154
  end
155
+
156
+ describe '.filesystem_permissions' do
157
+ it 'returns the permissions on a file' do
158
+ file = Tempfile.new('test_file')
159
+ file.close
160
+ expected_permissions = 0600
161
+ File.chmod(expected_permissions, file.path)
162
+
163
+ actual_permissions = subject.filesystem_permissions(file.path)
164
+
165
+ file.unlink
166
+ expect(actual_permissions).to eql(expected_permissions)
167
+ end
168
+ end
169
+
154
170
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docker-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.30.1
4
+ version: 1.30.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Swipely, Inc.