buildkit 1.4.0 → 1.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +2 -2
- data/.travis.yml +1 -3
- data/Gemfile +2 -0
- data/Rakefile +2 -0
- data/bin/console +1 -0
- data/buildkit.gemspec +3 -1
- data/dev.yml +13 -0
- data/lib/buildkit.rb +2 -0
- data/lib/buildkit/client.rb +9 -2
- data/lib/buildkit/client/agents.rb +2 -0
- data/lib/buildkit/client/artifacts.rb +2 -0
- data/lib/buildkit/client/builds.rb +2 -0
- data/lib/buildkit/client/jobs.rb +2 -0
- data/lib/buildkit/client/organizations.rb +2 -0
- data/lib/buildkit/client/pipelines.rb +3 -1
- data/lib/buildkit/error.rb +4 -2
- data/lib/buildkit/header_link_parser.rb +21 -17
- data/lib/buildkit/response/raise_error.rb +2 -0
- data/lib/buildkit/version.rb +3 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b660f3bc437b261aac25d8a7e8dbeb533570924857e17309f31c283d847725f4
|
4
|
+
data.tar.gz: 1c3e6d58d5a38377d30b62ba3a98fededa51cfdb121f8371c3801d93e185d234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fbc1cd2171b549376fd0baf0b342b53312d9d2c67deaa349bbeb5dc6e91a8eca3e61dd6a34dedbcc4e6bc47f9c90b8a63aefbbaabfc80de96907f648a8aa95e
|
7
|
+
data.tar.gz: 9b88b7ca24fba99297585e26e425dc31d33d9ed89c5e65e6db7d13c11c43b9bce98b65dfe2241c9570ca3cb297c2ebb4b21e46d632c17007c495e46208232961
|
data/.rubocop.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
inherit_from: .rubocop_todo.yml
|
2
2
|
|
3
3
|
AllCops:
|
4
|
-
TargetRubyVersion: 2.
|
4
|
+
TargetRubyVersion: 2.3
|
5
5
|
|
6
6
|
Metrics/LineLength:
|
7
7
|
Max: 120
|
@@ -39,7 +39,7 @@ Lint/AssignmentInCondition:
|
|
39
39
|
Style/PerlBackrefs:
|
40
40
|
Enabled: false
|
41
41
|
|
42
|
-
|
42
|
+
Layout/SpaceInsideHashLiteralBraces:
|
43
43
|
EnforcedStyle: no_space
|
44
44
|
|
45
45
|
Style/TrailingCommaInArrayLiteral:
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
data/buildkit.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'buildkit/version'
|
@@ -17,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
17
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
20
|
spec.require_paths = ['lib']
|
19
21
|
|
20
|
-
spec.required_ruby_version = '>= 2.
|
22
|
+
spec.required_ruby_version = '>= 2.3'
|
21
23
|
|
22
24
|
spec.add_dependency 'sawyer', '~> 0.6'
|
23
25
|
spec.add_development_dependency 'bundler'
|
data/dev.yml
ADDED
data/lib/buildkit.rb
CHANGED
data/lib/buildkit/client.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sawyer'
|
2
4
|
require 'buildkit/client/agents'
|
3
5
|
require 'buildkit/client/builds'
|
@@ -18,7 +20,7 @@ module Buildkit
|
|
18
20
|
include Artifacts
|
19
21
|
include HeaderLinkParser
|
20
22
|
|
21
|
-
DEFAULT_ENDPOINT = 'https://api.buildkite.com/v2/'
|
23
|
+
DEFAULT_ENDPOINT = 'https://api.buildkite.com/v2/'
|
22
24
|
|
23
25
|
# Header keys that can be passed in options hash to {#get},{#head}
|
24
26
|
CONVENIENCE_HEADERS = Set.new(%i[accept content_type])
|
@@ -139,10 +141,15 @@ module Buildkit
|
|
139
141
|
response = []
|
140
142
|
loop do
|
141
143
|
request method, path, data, options
|
144
|
+
|
145
|
+
# Paginated API calls always return Arrays.
|
146
|
+
return last_response.data unless @last_response.data.is_a?(Array)
|
147
|
+
|
142
148
|
response.concat @last_response.data
|
143
149
|
|
144
150
|
link_header = parse_link_header(@last_response.headers[:link])
|
145
151
|
break if link_header[:next].nil?
|
152
|
+
|
146
153
|
path = next_page(link_header[:next])
|
147
154
|
end
|
148
155
|
response
|
@@ -181,7 +188,7 @@ module Buildkit
|
|
181
188
|
end
|
182
189
|
query = options.delete(:query)
|
183
190
|
opts = {query: options}
|
184
|
-
opts[:query].merge!(query) if query
|
191
|
+
opts[:query].merge!(query) if query&.is_a?(Hash)
|
185
192
|
opts[:headers] = headers unless headers.empty?
|
186
193
|
|
187
194
|
opts
|
data/lib/buildkit/client/jobs.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Buildkit
|
2
4
|
class Client
|
3
5
|
# Methods for the pipelines API
|
@@ -31,7 +33,7 @@ module Buildkit
|
|
31
33
|
# @param org [String] Organization slug.
|
32
34
|
# @see https://buildkite.com/docs/api/pipelines#create-a-pipeline
|
33
35
|
# @example
|
34
|
-
# Buildkit.
|
36
|
+
# Buildkit.create_pipeline('my-great-org', {
|
35
37
|
# name: 'My pipeline',
|
36
38
|
# repository: 'git@github.com:acme/pipeline.git',
|
37
39
|
# steps: [
|
data/lib/buildkit/error.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Buildkit
|
2
4
|
# Custom error class for rescuing from all Buildkite errors
|
3
5
|
class Error < StandardError
|
@@ -44,7 +46,7 @@ module Buildkit
|
|
44
46
|
# Array of validation errors
|
45
47
|
# @return [Array<Hash>] Error info
|
46
48
|
def errors
|
47
|
-
if data
|
49
|
+
if data&.is_a?(Hash)
|
48
50
|
data[:errors] || []
|
49
51
|
else
|
50
52
|
[]
|
@@ -98,7 +100,7 @@ module Buildkit
|
|
98
100
|
def build_error_message
|
99
101
|
return nil if @response.nil?
|
100
102
|
|
101
|
-
message = "#{@response[:method].to_s.upcase} #{redact_url(@response[:url].to_s)}: #{@response[:status]} - "
|
103
|
+
message = +"#{@response[:method].to_s.upcase} #{redact_url(@response[:url].to_s)}: #{@response[:status]} - "
|
102
104
|
message << "#{response_message}#{response_error}#{response_error_summary}"
|
103
105
|
message << " // See: #{documentation_url}" unless documentation_url.nil?
|
104
106
|
message
|
@@ -1,26 +1,30 @@
|
|
1
|
-
|
2
|
-
module_function
|
1
|
+
# frozen_string_literal: true
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
module Buildkit
|
4
|
+
module HeaderLinkParser
|
5
|
+
module_function
|
6
|
+
|
7
|
+
def parse_link_header(link_header)
|
8
|
+
{}.tap do |hash_link|
|
9
|
+
link_header.split(',').each do |link|
|
10
|
+
link_obj = LinkParser.new(link)
|
11
|
+
hash_link[link_obj.name] = link_obj.link
|
12
|
+
end
|
9
13
|
end
|
10
14
|
end
|
11
|
-
end
|
12
15
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
16
|
+
class LinkParser
|
17
|
+
def initialize(value)
|
18
|
+
@value = value
|
19
|
+
end
|
17
20
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
def name
|
22
|
+
@name ||= @value[/rel="(.*)"/, 1].to_sym
|
23
|
+
end
|
21
24
|
|
22
|
-
|
23
|
-
|
25
|
+
def link
|
26
|
+
@link ||= @value[/<(.+)>/, 1]
|
27
|
+
end
|
24
28
|
end
|
25
29
|
end
|
26
30
|
end
|
data/lib/buildkit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: buildkit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-08-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sawyer
|
@@ -57,6 +57,7 @@ files:
|
|
57
57
|
- bin/console
|
58
58
|
- bin/setup
|
59
59
|
- buildkit.gemspec
|
60
|
+
- dev.yml
|
60
61
|
- lib/buildkit.rb
|
61
62
|
- lib/buildkit/client.rb
|
62
63
|
- lib/buildkit/client/agents.rb
|
@@ -81,15 +82,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
81
82
|
requirements:
|
82
83
|
- - ">="
|
83
84
|
- !ruby/object:Gem::Version
|
84
|
-
version: '2.
|
85
|
+
version: '2.3'
|
85
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
87
|
requirements:
|
87
88
|
- - ">="
|
88
89
|
- !ruby/object:Gem::Version
|
89
90
|
version: '0'
|
90
91
|
requirements: []
|
91
|
-
|
92
|
-
rubygems_version: 2.6.14
|
92
|
+
rubygems_version: 3.0.3
|
93
93
|
signing_key:
|
94
94
|
specification_version: 4
|
95
95
|
summary: Ruby toolkit for working with the Buildkite API
|