Skip to content

Commit

Permalink
Merge 2726308 into c60a7d9
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kaes committed Jun 21, 2016
2 parents c60a7d9 + 2726308 commit bb48e60
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
15 changes: 10 additions & 5 deletions lib/fpm/fry/build_output_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ def initialize(*_)
end

def call(chunk, *_)
json = JSON.parse(chunk)
stream = json['stream']
if /\ASuccessfully built (\w+)\Z/.match(stream)
images << $1
# new docker for Mac results in data like this:
# "{'stream':' ---\\u003e 3bc51d6a4c46\\n'}\r\n{'stream':'Step 2 : WORKDIR /tmp/build\\n'}\r\n"
# this isn't valid JSON, of course, so we process each part individually
chunk.split("\r\n").each do |sub_chunk|
json = JSON.parse(sub_chunk)
stream = json['stream']
if /\ASuccessfully built (\w+)\Z/.match(stream)
images << $1
end
out << stream
end
out << stream
end

end
Expand Down
24 changes: 16 additions & 8 deletions lib/fpm/fry/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,22 @@ def url(*path)

def read(name, resource)
return to_enum(:read, name, resource) unless block_given?
body = JSON.generate({'Resource' => resource})
res = agent.post(
path: url('containers',name,'copy'),
headers: { 'Content-Type' => 'application/json' },
body: body,
expects: [200,500]
)
if res.status == 500
res = if (server_version['ApiVersion'] < "1.20")
agent.post(
path: url('containers', name, 'copy'),
headers: { 'Content-Type' => 'application/json' },
body: JSON.generate({'Resource' => resource}),
expects: [200,404,500]
)
else
agent.get(
path: url('containers', name, 'archive'),
headers: { 'Content-Type' => 'application/json' },
query: {:path => resource},
expects: [200,404,500]
)
end
if res.status == 500 || res.status == 404
raise FileNotFound, "File #{resource.inspect} not found: #{res.body}"
end
sio = StringIO.new(res.body)
Expand Down

0 comments on commit bb48e60

Please sign in to comment.