skylight 3.1.5 → 4.0.0.alpha

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
  SHA256:
3
- metadata.gz: fdfb403ebb2a5b06699295afa21247e71b61e3bef1818b9ce4160df30e8c2c09
4
- data.tar.gz: 95f4d5c385fef7794f03b67d78e7c3755b48726ce8c0a65987bc659358817791
3
+ metadata.gz: df25b1cb1ffff1e84bef0e911de92f5ed92ba455fe43b3319a332d3ca2670318
4
+ data.tar.gz: 758bab00fc5be7be085f507477a3ac4545d45205cc65a0863742d8698b7bc9a1
5
5
  SHA512:
6
- metadata.gz: 82a3897ec11249746ef2864900ba66a83316749fd1f85ed3e5dd2fa6fd375b47fa89c8312cb297c1922e0b7a70fa3e6a83b4355462b3721c10a84703d24d01a0
7
- data.tar.gz: f5eac98886f187f9f143474ddaace978125ff16d8e9d1561d489710f782d4f384e9ecf206b71c72db0e58bfd179ea41b4d44c0820f50cda6feeff62ee794a4b5
6
+ metadata.gz: f53ce448c301d94196132f0e392745aaff73bd7fa355cb7d5b469390c15f8694fd4c81639c0b5de5b9da4146134289b607d2ff7c830743456fbe7661edfd95aa
7
+ data.tar.gz: 1e6c1e179b7de9cb1752d690991c5216ac76e1aa4240f10c25de7475597375014a6bceabcef768576366baa8cb460298d1506da42e2dfed7843361e936e266f0
@@ -1,12 +1,9 @@
1
- ## 3.1.5 (March 20, 2019)
2
- * [BUGFIX] Make Action View probe compatible with Rails 6 (backported from 4.0.0.beta2)
3
-
4
- ## 3.1.4
5
- * [BUGFIX] ActiveJob#perform_now should not reassign the endpoint name
6
-
7
- ## 3.1.3
8
- * [BUGFIX] skylightd should close cloned file descriptors on startup
9
- * [BUGFIX] Convert numeric git shas to strings
1
+ ## 4.0.0.alpha (December 3, 2018)
2
+ * [FEATURE] Skylight for Background Jobs
3
+ * [FEATURE] Probe for Delayed::Job (standalone)
4
+ * [IMPROVEMENT] Handle 403 config validation response
5
+ * [IMPROVEMENT] Config for `prune_large_traces` is now true by default
6
+ * [BREAKING] New method for assigning 'segment' to a trace endpoint name
10
7
 
11
8
  ## 3.1.2 (November 29, 2018)
12
9
  * [BUGFIX] Fix derived endpoint names under Grape 1.2
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
2
  require "skylight/cli"
3
- Skylight::CLI::Base.start(ARGV)
3
+ Skylight::CLI::Base.start(ARGV)
@@ -1,34 +1,33 @@
1
- require 'rbconfig'
2
- require 'mkmf'
3
- require 'yaml'
4
- require 'logger'
5
- require 'fileutils'
1
+ require "rbconfig"
2
+ require "mkmf"
3
+ require "yaml"
4
+ require "logger"
5
+ require "fileutils"
6
6
 
7
- $:.unshift File.expand_path("../../lib", __FILE__)
7
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
8
8
 
9
- require 'skylight/version'
9
+ require "skylight/version"
10
10
 
11
11
  # Don't use the gem for dev
12
- if File.exists?(File.expand_path("../../Gemfile", __FILE__))
12
+ if File.exist?(File.expand_path("../Gemfile", __dir__))
13
13
  # This approach won't work in production since skylight-core isn't in the skylight gem
14
- $:.unshift File.expand_path("../../skylight-core/lib", __FILE__)
14
+ $LOAD_PATH.unshift File.expand_path("../skylight-core/lib", __dir__)
15
15
  else
16
16
  # Is there a better way to get this into lib?
17
- gem 'skylight-core', Skylight::VERSION.tr('-', '.')
17
+ gem "skylight-core", Skylight::VERSION.tr("-", ".")
18
18
  end
19
19
 
20
- require 'skylight/native_ext_fetcher'
21
- require 'skylight/core/util/platform'
20
+ require "skylight/native_ext_fetcher"
21
+ require "skylight/core/util/platform"
22
22
 
23
23
  # Util allowing proxying writes to multiple location
24
24
  class MultiIO
25
-
26
25
  def initialize(*targets)
27
- @targets = targets
26
+ @targets = targets
28
27
  end
29
28
 
30
29
  def write(*args)
31
- @targets.each {|t| t.write(*args)}
30
+ @targets.each { |t| t.write(*args) }
32
31
  end
33
32
 
34
33
  def close
@@ -38,28 +37,28 @@ end
38
37
 
39
38
  include Skylight::Core::Util
40
39
 
41
- SKYLIGHT_INSTALL_LOG = File.expand_path("../install.log", __FILE__)
42
- SKYLIGHT_REQUIRED = ENV.key?("SKYLIGHT_REQUIRED") && ENV['SKYLIGHT_REQUIRED'] !~ /^false$/i
43
- SKYLIGHT_FETCH_LIB = !ENV.key?('SKYLIGHT_FETCH_LIB') || ENV['SKYLIGHT_FETCH_LIB'] !~ /^false$/i
40
+ SKYLIGHT_INSTALL_LOG = File.expand_path("install.log", __dir__)
41
+ SKYLIGHT_REQUIRED = ENV.key?("SKYLIGHT_REQUIRED") && ENV["SKYLIGHT_REQUIRED"] !~ /^false$/i
42
+ SKYLIGHT_FETCH_LIB = !ENV.key?("SKYLIGHT_FETCH_LIB") || ENV["SKYLIGHT_FETCH_LIB"] !~ /^false$/i
44
43
 
45
44
  # Directory where skylight.h exists
46
- SKYLIGHT_HDR_PATH = ENV['SKYLIGHT_HDR_PATH'] || ENV['SKYLIGHT_LIB_PATH'] || '.'
47
- SKYLIGHT_LIB_PATH = ENV['SKYLIGHT_LIB_PATH'] || File.expand_path("../../lib/skylight/native/#{Platform.tuple}", __FILE__)
45
+ SKYLIGHT_HDR_PATH = ENV["SKYLIGHT_HDR_PATH"] || ENV["SKYLIGHT_LIB_PATH"] || "."
46
+ SKYLIGHT_LIB_PATH = ENV["SKYLIGHT_LIB_PATH"] || File.expand_path("../../lib/skylight/native/#{Platform.tuple}", __FILE__)
48
47
 
49
- SKYLIGHT_SOURCE_URL = ENV['SKYLIGHT_SOURCE_URL']
50
- SKYLIGHT_VERSION = ENV['SKYLIGHT_VERSION']
51
- SKYLIGHT_CHECKSUM = ENV['SKYLIGHT_CHECKSUM']
48
+ SKYLIGHT_SOURCE_URL = ENV["SKYLIGHT_SOURCE_URL"]
49
+ SKYLIGHT_VERSION = ENV["SKYLIGHT_VERSION"]
50
+ SKYLIGHT_CHECKSUM = ENV["SKYLIGHT_CHECKSUM"]
52
51
 
53
- SKYLIGHT_EXT_STRICT = ENV.key?("SKYLIGHT_EXT_STRICT") && ENV['SKYLIGHT_EXT_STRICT'] =~ /^true$/i
52
+ SKYLIGHT_EXT_STRICT = ENV.key?("SKYLIGHT_EXT_STRICT") && ENV["SKYLIGHT_EXT_STRICT"] =~ /^true$/i
54
53
 
55
54
  # Setup logger
56
- LOG = Logger.new(MultiIO.new(STDOUT, File.open(SKYLIGHT_INSTALL_LOG, 'a')))
55
+ LOG = Logger.new(MultiIO.new(STDOUT, File.open(SKYLIGHT_INSTALL_LOG, "a")))
57
56
 
58
57
  # Handles terminating in the case of a failure. If we have a bug, we do not
59
58
  # want to break our customer's deploy, but extconf.rb requires a Makefile to be
60
59
  # present upon a successful exit. To satisfy this requirement, we create a
61
60
  # dummy Makefile.
62
- def fail(msg, type=:error)
61
+ def fail(msg, type = :error)
63
62
  LOG.send type, msg
64
63
 
65
64
  if SKYLIGHT_REQUIRED
@@ -77,38 +76,38 @@ end
77
76
  # Check that Xcode license has been approved
78
77
  # Based on Homebrew's implementation
79
78
  # https://github.com/Homebrew/homebrew/blob/03708b016755847facc4f19a43ee9f7a44141ed7/Library/Homebrew/cmd/doctor.rb#L1183
80
- if Platform::OS == 'darwin'
79
+ if Platform::OS == "darwin"
81
80
  # If the user installs Xcode-only, they have to approve the
82
81
  # license or no "xc*" tool will work.
83
- if `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$?.success?
84
- fail <<-EOS
82
+ if `/usr/bin/xcrun clang 2>&1` =~ /license/ && !$CHILD_STATUS.success?
83
+ fail <<-MESSAGE
85
84
  You have not agreed to the Xcode license and so we are unable to build the native agent.
86
85
  To resolve this, you can agree to the license by opening Xcode.app or running:
87
86
  sudo xcodebuild -license
88
- EOS
87
+ MESSAGE
89
88
  end
90
89
  end
91
90
 
92
91
  #
93
92
  # === Setup paths
94
93
  #
95
- root = File.expand_path('../', __FILE__)
94
+ root = File.expand_path(__dir__)
96
95
  hdrpath = File.expand_path(SKYLIGHT_HDR_PATH)
97
96
  libpath = File.expand_path(SKYLIGHT_LIB_PATH)
98
97
  libskylight = File.expand_path("libskylight.#{Platform.libext}", libpath)
99
- libskylight_yml = File.expand_path('libskylight.yml', root)
98
+ libskylight_yml = File.expand_path("libskylight.yml", root)
100
99
  skylight_dlopen_h = File.expand_path("skylight_dlopen.h", hdrpath)
101
100
  skylight_dlopen_c = File.expand_path("skylight_dlopen.c", hdrpath)
102
101
 
103
102
  LOG.info "SKYLIGHT_HDR_PATH=#{hdrpath}; SKYLIGHT_LIB_PATH=#{libpath}"
104
103
 
105
- LOG.info "file exists; path=#{libskylight}" if File.exists?(libskylight)
106
- LOG.info "file exists; path=#{skylight_dlopen_c}" if File.exists?(skylight_dlopen_c)
107
- LOG.info "file exists; path=#{skylight_dlopen_h}" if File.exists?(skylight_dlopen_h)
104
+ LOG.info "file exists; path=#{libskylight}" if File.exist?(libskylight)
105
+ LOG.info "file exists; path=#{skylight_dlopen_c}" if File.exist?(skylight_dlopen_c)
106
+ LOG.info "file exists; path=#{skylight_dlopen_h}" if File.exist?(skylight_dlopen_h)
108
107
 
109
108
  # If libskylight is not present, fetch it
110
109
  if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(skylight_dlopen_h)
111
- if !SKYLIGHT_FETCH_LIB
110
+ unless SKYLIGHT_FETCH_LIB
112
111
  fail "libskylight.#{LIBEXT} not found -- remote download disabled; aborting install"
113
112
  end
114
113
 
@@ -117,37 +116,35 @@ if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(
117
116
  fail "`#{libskylight_yml}` does not exist"
118
117
  end
119
118
 
120
- unless libskylight_info = YAML.load_file(libskylight_yml)
119
+ unless (libskylight_info = YAML.load_file(libskylight_yml))
121
120
  fail "`#{libskylight_yml}` does not contain data"
122
121
  end
123
122
 
124
- if version = SKYLIGHT_VERSION
125
- unless checksum = SKYLIGHT_CHECKSUM
123
+ if (version = SKYLIGHT_VERSION)
124
+ unless (checksum = SKYLIGHT_CHECKSUM)
126
125
  fail "no checksum provided when using custom version"
127
126
  end
127
+ elsif (platform_info = libskylight_info[Platform.tuple])
128
+ unless (version = platform_info["version"])
129
+ fail "libskylight version missing from `#{libskylight_yml}`; platform=#{Platform.tuple}"
130
+ end
131
+
132
+ unless (checksum = platform_info["checksum"])
133
+ fail "checksum missing from `#{libskylight_yml}`; platform=#{Platform.tuple}"
134
+ end
128
135
  else
129
- if platform_info = libskylight_info[Platform.tuple]
130
- unless version = platform_info["version"]
131
- fail "libskylight version missing from `#{libskylight_yml}`; platform=#{Platform.tuple}"
132
- end
133
-
134
- unless checksum = platform_info["checksum"]
135
- fail "checksum missing from `#{libskylight_yml}`; platform=#{Platform.tuple}"
136
- end
137
- else
138
- unless version = libskylight_info["version"]
139
- fail "libskylight version missing from `#{libskylight_yml}`"
140
- end
141
-
142
- unless checksums = libskylight_info["checksums"]
143
- fail "libskylight checksums missing from `#{libskylight_yml}`"
144
- end
145
-
146
- unless checksum = checksums[Platform.tuple]
147
- fail "no checksum entry for requested architecture -- " \
148
- "this probably means the requested architecture is not supported; " \
149
- "platform=#{Platform.tuple}; available=#{checksums.keys}", :info
150
- end
136
+ unless (version = libskylight_info["version"])
137
+ fail "libskylight version missing from `#{libskylight_yml}`"
138
+ end
139
+
140
+ unless (checksums = libskylight_info["checksums"])
141
+ fail "libskylight checksums missing from `#{libskylight_yml}`"
142
+ end
143
+
144
+ unless (checksum = checksums[Platform.tuple])
145
+ fail "no checksum entry for requested architecture -- " \
146
+ "this probably means the requested architecture is not supported; " \
147
+ "platform=#{Platform.tuple}; available=#{checksums.keys}", :info
151
148
  end
152
149
  end
153
150
 
@@ -160,7 +157,8 @@ if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(
160
157
  arch: Platform.tuple,
161
158
  required: SKYLIGHT_REQUIRED,
162
159
  platform: Platform.tuple,
163
- logger: LOG)
160
+ logger: LOG
161
+ )
164
162
 
165
163
  unless res
166
164
  fail "could not fetch archive -- aborting skylight native extension build"
@@ -174,11 +172,11 @@ if !File.exist?(libskylight) && !File.exist?(skylight_dlopen_c) && !File.exist?(
174
172
  # Move
175
173
  FileUtils.mv "#{hdrpath}/libskylight.#{Platform.libext}",
176
174
  "#{libpath}/libskylight.#{Platform.libext}",
177
- :force => true
175
+ force: true
178
176
 
179
177
  FileUtils.mv "#{hdrpath}/skylightd",
180
178
  "#{libpath}/skylightd",
181
- :force => true
179
+ force: true
182
180
  end
183
181
  rescue => e
184
182
  fail "unable to fetch native extension; msg=#{e.message}\n#{e.backtrace.join("\n")}"
@@ -192,35 +190,35 @@ end
192
190
  #
193
191
 
194
192
  def find_file(file, root = nil)
195
- path = File.expand_path(file, root || '.')
193
+ path = File.expand_path(file, root || ".")
196
194
 
197
195
  unless File.exist?(path)
198
196
  fail "#{file} missing; path=#{root}"
199
197
  end
200
198
  end
201
199
 
202
- $VPATH << libpath
200
+ $VPATH << libpath
203
201
 
204
202
  # Where the ruby binding src is
205
- SRC_PATH = File.expand_path('..', __FILE__)
203
+ SRC_PATH = File.expand_path(__dir__)
206
204
 
207
205
  $srcs = Dir[File.expand_path("*.c", SRC_PATH)].map { |f| File.basename(f) }
208
206
 
209
207
  # If the native agent support files were downloaded to a different directory,
210
208
  # explicitly the file to the list of sources.
211
- unless $srcs.include?('skylight_dlopen.c')
209
+ unless $srcs.include?("skylight_dlopen.c")
212
210
  $srcs << "skylight_dlopen.c" # From libskylight dist
213
211
  end
214
212
 
215
213
  # Make sure that the files are present
216
- find_file 'skylight_dlopen.h', hdrpath
217
- find_file 'skylight_dlopen.c', hdrpath
218
- find_header 'skylight_dlopen.h', hdrpath
219
- have_header 'dlfcn.h' or fail "could not create Makefile; dlfcn.h missing"
214
+ find_file "skylight_dlopen.h", hdrpath
215
+ find_file "skylight_dlopen.c", hdrpath
216
+ find_header "skylight_dlopen.h", hdrpath
217
+ fail "could not create Makefile; dlfcn.h missing" unless have_header "dlfcn.h"
220
218
 
221
219
  # For escaping the GVL
222
- unless have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
223
- have_func('rb_thread_blocking_region') or abort "Ruby is unexpectedly missing rb_thread_blocking_region. This should not happen."
220
+ unless have_func("rb_thread_call_without_gvl", "ruby/thread.h") || have_func("rb_thread_blocking_region")
221
+ abort "Ruby is unexpectedly missing rb_thread_blocking_region. This should not happen."
224
222
  end
225
223
 
226
224
  # Previous comment stated:
@@ -234,7 +232,7 @@ if SKYLIGHT_EXT_STRICT
234
232
  $CFLAGS << " -Werror"
235
233
  end
236
234
 
237
- checking_for 'fast thread local storage' do
235
+ checking_for "fast thread local storage" do
238
236
  if try_compile("__thread int foo;")
239
237
  $defs << "-DHAVE_FAST_TLS"
240
238
  true
@@ -250,4 +248,4 @@ if SKYLIGHT_EXT_STRICT
250
248
  end
251
249
 
252
250
  # TODO: Compute the relative path to the location
253
- create_makefile 'skylight_native', File.expand_path('..', __FILE__) # or fail "could not create makefile"
251
+ create_makefile "skylight_native", File.expand_path(__dir__) # or fail "could not create makefile"
@@ -1,7 +1,8 @@
1
- version: "3.1.0-c0a22d1"
1
+ version: "3.1.0-ef54598"
2
2
  checksums:
3
- x86-linux: "1dc6a9ee453756c8b984c5733d2631ed27538f20cfde2f037ae31010edec6232"
4
- x86_64-linux: "b91dc91c2bc2954bf4587f3733a3c696a443bce13738a9073229ab4dfd09938e"
5
- x86_64-linux-musl: "c7b00982688a344ee3808ea40452dd1f6c448e7f3aa0221b4c95fca2a51547b9"
6
- x86_64-darwin: "41cf89a75dc64cafb97303f31908b14a3ca2d15e5de935cbd57a611f396b5b90"
7
- x86_64-freebsd: "72ccb98f3f7604fddad116fe6ea4750643f9b088d4f25f3e21c4972680cc8f01"
3
+ x86-linux: "b2e0df4a907c75a7296b147145dcb756ee9c0c506e9ff34ccf5dbfd33f762707"
4
+ x86_64-linux: "ab6d9c22b4a9e1831370cd5a9dd100c70270aebe51be4ed99c2a636c972792fa"
5
+ x86_64-linux-musl: "0cc2e117097d0cbed11f6f8ce877d9bb48e9d7d8bb443eb19c00ccf1bc56c8c8"
6
+ x86_64-darwin: "183cafb3df420db56b4062a654708f0981f3ef3c3ba47c8a07810c93a7d689d4"
7
+ x86_64-freebsd: "bbdbd4c7faa4546278b557007f0131d554add50a4bc8aa2c24dd3d3288cf9337"
8
+
@@ -1,22 +1,25 @@
1
- require 'skylight/version'
2
- require 'skylight/core'
3
- require 'skylight/trace'
4
- require 'skylight/instrumenter'
5
- require 'skylight/middleware'
6
- require 'skylight/api'
7
- require 'skylight/helpers'
8
- require 'skylight/config'
9
- require 'skylight/errors'
10
- require 'skylight/native'
1
+ require "skylight/version"
2
+ require "skylight/core"
3
+ require "skylight/trace"
4
+ require "skylight/instrumenter"
5
+ require "skylight/middleware"
6
+ require "skylight/api"
7
+ require "skylight/helpers"
8
+ require "skylight/config"
9
+ require "skylight/errors"
10
+ require "skylight/native"
11
+
12
+ # For prettier global names
13
+ require "English"
11
14
 
12
15
  module Skylight
13
16
  # Used from the CLI
14
- autoload :CLI, 'skylight/cli'
17
+ autoload :CLI, "skylight/cli"
15
18
 
16
19
  # Specifically check for Railtie since we've had at least one case of a
17
20
  # customer having Rails defined without having all of Rails loaded.
18
21
  if defined?(Rails::Railtie)
19
- require 'skylight/railtie'
22
+ require "skylight/railtie"
20
23
  end
21
24
 
22
25
  include Core::Instrumentable
@@ -30,5 +33,4 @@ module Skylight
30
33
  end
31
34
 
32
35
  Core::Probes.add_path(File.expand_path("skylight/probes", __dir__))
33
-
34
36
  end
@@ -1,5 +1,5 @@
1
- require 'uri'
2
- require 'skylight/util/http'
1
+ require "uri"
2
+ require "skylight/util/http"
3
3
 
4
4
  module Skylight
5
5
  # @api private
@@ -21,14 +21,14 @@ module Skylight
21
21
 
22
22
  def errors
23
23
  return unless res.respond_to?(:body) && res.body.is_a?(Hash)
24
- res.body['errors']
24
+ res.body["errors"]
25
25
  end
26
26
 
27
27
  def to_s
28
28
  if errors
29
29
  errors.inspect
30
30
  elsif res
31
- "#{res.class.to_s}: #{res.to_s}"
31
+ "#{res.class}: #{res}"
32
32
  else
33
33
  super
34
34
  end
@@ -36,7 +36,6 @@ module Skylight
36
36
  end
37
37
 
38
38
  class ConfigValidationResults
39
-
40
39
  include Core::Util::Logging
41
40
 
42
41
  attr_reader :raw_response
@@ -46,7 +45,7 @@ module Skylight
46
45
  @raw_response = raw_response
47
46
  end
48
47
 
49
- def is_error_response?
48
+ def error_response?
50
49
  raw_response.is_a?(Util::HTTP::ErrorResponse) || status > 499
51
50
  end
52
51
 
@@ -55,7 +54,7 @@ module Skylight
55
54
  end
56
55
 
57
56
  def body
58
- return nil if is_error_response?
57
+ return nil if error_response?
59
58
 
60
59
  unless raw_response.body.is_a?(Hash)
61
60
  warn("Unable to parse server response: status=%s, body=%s", raw_response.status, raw_response.body)
@@ -67,11 +66,14 @@ module Skylight
67
66
 
68
67
  def token_valid?
69
68
  # Don't prevent boot if it's an error response, so assume token is valid
70
- return true if is_error_response?
69
+ return true if error_response?
71
70
  # A 2xx response means everything is good!
72
71
  return true if raw_response.success?
73
- # A 422 means an invalid config, but the token must be valid if we got this far
74
- return true if status === 422
72
+ return false if status == 401
73
+
74
+ # A 403/422 means an invalid config,
75
+ # but the token must be valid if we got this far
76
+ true
75
77
  end
76
78
 
77
79
  def config_valid?
@@ -79,23 +81,26 @@ module Skylight
79
81
  raw_response.success?
80
82
  end
81
83
 
84
+ def forbidden?
85
+ status == 403
86
+ end
87
+
82
88
  def validation_errors
83
- return if config_valid?
84
- body ? body['errors'] : nil
89
+ return {} if config_valid? || !body
90
+ body["errors"]
85
91
  end
86
92
 
87
93
  def corrected_config
88
- return if config_valid?
89
- body ? body['corrected'] : nil
94
+ return {} if config_valid? || !body
95
+ body["corrected"]
90
96
  end
91
-
92
97
  end
93
98
 
94
99
  def initialize(config)
95
100
  @config = config
96
101
  end
97
102
 
98
- def create_app(name, token=nil)
103
+ def create_app(name, token = nil)
99
104
  params = { app: { name: name } }
100
105
  params[:token] = token if token
101
106
 
@@ -106,17 +111,17 @@ module Skylight
106
111
  end
107
112
 
108
113
  def fetch_mergeable_apps(token)
109
- headers = { 'x-skylight-merge-token' => token }
114
+ headers = { "x-skylight-merge-token" => token }
110
115
  http_request(:merges, :get, headers).tap do |res|
111
- raise error_for_status(res.status).new("HTTP #{res.status}: #{res.body}") unless res.success?
116
+ raise error_for_status(res.status), "HTTP #{res.status}: #{res.body}" unless res.success?
112
117
  end
113
118
  end
114
119
 
115
120
  def merge_apps!(token, app_guid:, component_guid:, environment:)
116
- headers = { 'x-skylight-merge-token' => token }
121
+ headers = { "x-skylight-merge-token" => token }
117
122
  body = { environment: environment, app_guid: app_guid, component_guid: component_guid }
118
123
  http_request(:merges, :post, body, headers).tap do |res|
119
- raise error_for_status(res.status).new("HTTP #{res.status}: #{res.body}") unless res.success?
124
+ raise error_for_status(res.status), "HTTP #{res.status}: #{res.body}" unless res.success?
120
125
  end
121
126
  end
122
127
 
@@ -127,24 +132,22 @@ module Skylight
127
132
 
128
133
  private
129
134
 
130
- # TODO: Improve handling here: https://github.com/tildeio/direwolf-agent/issues/274
131
- def http_request(service, method, *args)
132
- http = Util::HTTP.new(config, service)
133
- uri = URI.parse(config.get("#{service}_url"))
134
- http.send(method, uri.path, *args)
135
- end
136
-
137
- def error_for_status(code)
138
- case code
139
- when 401
140
- Unauthorized
141
- when 409
142
- Conflict
143
- else
144
- Error
135
+ # TODO: Improve handling here: https://github.com/tildeio/direwolf-agent/issues/274
136
+ def http_request(service, method, *args)
137
+ http = Util::HTTP.new(config, service)
138
+ uri = URI.parse(config.get("#{service}_url"))
139
+ http.send(method, uri.path, *args)
145
140
  end
146
- end
147
141
 
142
+ def error_for_status(code)
143
+ case code
144
+ when 401
145
+ Unauthorized
146
+ when 409
147
+ Conflict
148
+ else
149
+ Error
150
+ end
151
+ end
148
152
  end
149
-
150
153
  end