cloudformation-tool 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 83b8efc5704070ab9a788b2a90abd76c5cddf51e001a809b8eb4232404d6a4a1
|
|
4
|
+
data.tar.gz: 09e63883d8159f6331d06f8b5b4af28888f755134f55972272b53df0bd7fe3e6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bbf45c2d3e1e03db1ae3e686e5432175547e00dc92db30ed12bf4bf03c66c2d8be8832cb1e1244a67025379a3918162962a071c67431468ea83795669c7eac58
|
|
7
|
+
data.tar.gz: 4e6480feac36232936ef892541aa0cd6e528547dab38721b0acb290db1360ee1ebd8f9cadd45f6c02cac43f3701d0298fc45c744175a1dde8ab2ae42bf1ab349
|
|
@@ -15,7 +15,9 @@ module CloudFormationTool
|
|
|
15
15
|
@data['Url'] = url = tpl.resolveVal(@data['Url'])
|
|
16
16
|
return unless url.is_a? String
|
|
17
17
|
log "Downloading Lambda code from #{url}"
|
|
18
|
-
|
|
18
|
+
if already_in_cache(url)
|
|
19
|
+
log "Reusing remote cached object instead of downloading"
|
|
20
|
+
else
|
|
19
21
|
res = fetch_from_url(url)
|
|
20
22
|
@s3_url = URI(upload(make_filename(url.split('.').last), res.body, mime_type: res['content-type'], gzip: false))
|
|
21
23
|
log "uploaded Lambda function to #{@s3_url}"
|
|
@@ -51,27 +53,35 @@ module CloudFormationTool
|
|
|
51
53
|
end
|
|
52
54
|
end
|
|
53
55
|
|
|
54
|
-
def already_in_cache(uri_str
|
|
55
|
-
|
|
56
|
+
def already_in_cache(uri_str)
|
|
57
|
+
limit = 10
|
|
56
58
|
url = URI(uri_str)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
59
|
+
until url.nil?
|
|
60
|
+
begin
|
|
61
|
+
raise ArgumentError, 'too many HTTP redirects' if limit == 0
|
|
62
|
+
Net::HTTP.start(url.host, url.port, use_ssl: true) do |http|
|
|
63
|
+
request = Net::HTTP::Get.new(url)
|
|
64
|
+
http.request(request) do |response|
|
|
65
|
+
# handle redirects like Github likes to do
|
|
66
|
+
case response
|
|
67
|
+
when Net::HTTPSuccess then
|
|
68
|
+
url = nil
|
|
69
|
+
http.finish if check_cached(response['ETag'])
|
|
70
|
+
when Net::HTTPRedirection then
|
|
71
|
+
location = response['location']
|
|
72
|
+
log "Cache check redirected to #{location}"
|
|
73
|
+
limit = limit - 1
|
|
74
|
+
response.body
|
|
75
|
+
url = URI(location)
|
|
76
|
+
else
|
|
77
|
+
log "arg err"
|
|
78
|
+
raise ArgumentError, "Error getting response: #{response}"
|
|
79
|
+
end
|
|
71
80
|
end
|
|
72
81
|
end
|
|
82
|
+
rescue IOError => e
|
|
83
|
+
retry unless url.nil?
|
|
73
84
|
end
|
|
74
|
-
rescue EOFError
|
|
75
85
|
end
|
|
76
86
|
!@s3_url.nil?
|
|
77
87
|
end
|
|
@@ -79,9 +89,11 @@ module CloudFormationTool
|
|
|
79
89
|
def check_cached(etag)
|
|
80
90
|
etag.gsub!(/"/,'') unless etag.nil?
|
|
81
91
|
o = cached_object(etag)
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
92
|
+
if o.nil?
|
|
93
|
+
false
|
|
94
|
+
else
|
|
95
|
+
@s3_url = URI(o.public_url)
|
|
96
|
+
true
|
|
85
97
|
end
|
|
86
98
|
end
|
|
87
99
|
|