fpm-fry 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/fpm/fry/command/cook.rb +1 -1
- data/lib/fpm/fry/plugin/service.rb +3 -5
- data/lib/fpm/fry/stream_parser.rb +47 -20
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4911dfb40c91dd585e0ccbbad499a4d71eebadd4c00846b982ed100b186c963f
|
4
|
+
data.tar.gz: 7122bfa7728cb976d3b12010e63be177ccc23d00c360c4830317369f1d1012f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1ef45f2c7b25b759e3f170b0a3a41d745e686a8a008da43494f6c53166f9695b241f3f2e45dab5fafacfd18a88ae5320e3e7831c4114d5a5e0cbbea08cf10c
|
7
|
+
data.tar.gz: fbe991bb53e481eab8293c0631079af94795f60dc6381635448fac81aaea0b879fe97e50860688654795a820d2813fab581bc06881223514c289bdd70b9dd42f
|
data/lib/fpm/fry/command/cook.rb
CHANGED
@@ -197,7 +197,7 @@ module FPM; module Fry
|
|
197
197
|
)
|
198
198
|
|
199
199
|
client.post(
|
200
|
-
path: client.url('containers',container,'attach?stderr=1&stdout=1&stream=1'),
|
200
|
+
path: client.url('containers',container,'attach?stderr=1&stdout=1&stream=1&logs=1'),
|
201
201
|
body: '',
|
202
202
|
expects: [200],
|
203
203
|
middlewares: [
|
@@ -10,11 +10,9 @@ module FPM::Fry::Plugin ; module Service
|
|
10
10
|
|
11
11
|
def render(file)
|
12
12
|
_erbout = ""
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
)
|
17
|
-
eval(erb.src,nil,File.join(File.dirname(__FILE__),'..','templates',file))
|
13
|
+
path = File.join(File.dirname(__FILE__),'..','templates',file)
|
14
|
+
erb = ERB.new(IO.read(path), trim_mode: "-")
|
15
|
+
eval erb.src, nil, path
|
18
16
|
return _erbout
|
19
17
|
end
|
20
18
|
|
@@ -16,38 +16,56 @@ module FPM; module Fry
|
|
16
16
|
if datum[:response]
|
17
17
|
# probably mocked
|
18
18
|
if datum[:response][:body]
|
19
|
-
|
19
|
+
headers = datum[:response][:headers]
|
20
|
+
fake_socket = StringIO.new(datum[:response][:body])
|
21
|
+
parse_response_data(fake_socket, headers)
|
20
22
|
end
|
21
|
-
return @stack.response_call(datum)
|
22
23
|
else
|
23
|
-
socket = datum
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
}
|
36
|
-
|
24
|
+
socket, headers = extract_socket_and_headers(datum)
|
25
|
+
parse_response_data(socket, headers)
|
26
|
+
end
|
27
|
+
@stack.response_call(datum)
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def extract_socket_and_headers(datum)
|
33
|
+
socket = datum[:connection].send(:socket)
|
34
|
+
begin
|
35
|
+
line = socket.readline
|
36
|
+
match = /^HTTP\/\d+\.\d+\s(\d{3})\s/.match(line)
|
37
|
+
end while !match
|
38
|
+
status = match[1].to_i
|
39
|
+
|
40
|
+
headers = Excon::Headers.new
|
41
|
+
datum[:response] = {
|
42
|
+
:body => '',
|
43
|
+
:headers => headers,
|
44
|
+
:status => status,
|
45
|
+
:remote_ip => socket.respond_to?(:remote_ip) && socket.remote_ip,
|
46
|
+
}
|
47
|
+
Excon::Response.parse_headers(socket, datum)
|
48
|
+
|
49
|
+
[socket, headers]
|
50
|
+
end
|
37
51
|
|
52
|
+
def parse_response_data(socket, headers)
|
53
|
+
if headers["Transfer-Encoding"] == "chunked"
|
54
|
+
@parser.parse_chunked(socket)
|
55
|
+
else
|
38
56
|
@parser.parse(socket)
|
39
|
-
return @stack.response_call(datum)
|
40
57
|
end
|
41
58
|
end
|
42
59
|
|
43
60
|
end
|
44
61
|
|
45
|
-
attr :out, :err
|
62
|
+
attr :out, :err, :streams
|
46
63
|
|
47
64
|
def initialize(out, err)
|
48
65
|
@out, @err = out, err
|
49
66
|
@state = :null
|
50
67
|
@left = 0
|
68
|
+
@streams = { 1 => out, 2 => err }
|
51
69
|
end
|
52
70
|
|
53
71
|
def new(stack)
|
@@ -55,8 +73,6 @@ module FPM; module Fry
|
|
55
73
|
end
|
56
74
|
|
57
75
|
def parse(socket)
|
58
|
-
left = 0
|
59
|
-
streams = {1 => out, 2 => err}
|
60
76
|
loop do
|
61
77
|
type = read_exactly(socket,4){|part|
|
62
78
|
if part.bytesize == 0
|
@@ -94,5 +110,16 @@ module FPM; module Fry
|
|
94
110
|
return buf
|
95
111
|
end
|
96
112
|
|
113
|
+
def parse_chunked(socket)
|
114
|
+
loop do
|
115
|
+
line = socket.readline
|
116
|
+
chunk_size = line.chomp.to_i(16)
|
117
|
+
break if chunk_size.zero?
|
118
|
+
chunk = socket.read(chunk_size)
|
119
|
+
parse(StringIO.new(chunk))
|
120
|
+
line = socket.readline
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
97
124
|
end
|
98
125
|
end ; end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fpm-fry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maxime Lagresle
|
@@ -95,28 +95,28 @@ dependencies:
|
|
95
95
|
name: coveralls
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
97
97
|
requirements:
|
98
|
-
- - "
|
98
|
+
- - ">="
|
99
99
|
- !ruby/object:Gem::Version
|
100
|
-
version:
|
100
|
+
version: 0.8.23
|
101
101
|
type: :development
|
102
102
|
prerelease: false
|
103
103
|
version_requirements: !ruby/object:Gem::Requirement
|
104
104
|
requirements:
|
105
|
-
- - "
|
105
|
+
- - ">="
|
106
106
|
- !ruby/object:Gem::Version
|
107
|
-
version:
|
107
|
+
version: 0.8.23
|
108
108
|
- !ruby/object:Gem::Dependency
|
109
109
|
name: simplecov
|
110
110
|
requirement: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- - "
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
type: :development
|
116
116
|
prerelease: false
|
117
117
|
version_requirements: !ruby/object:Gem::Requirement
|
118
118
|
requirements:
|
119
|
-
- - "
|
119
|
+
- - ">="
|
120
120
|
- !ruby/object:Gem::Version
|
121
121
|
version: '0'
|
122
122
|
description: deep-fried package builder
|