buildbox 0.3.9.1 → 0.4

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
  SHA1:
3
- metadata.gz: 24043ce2077ac39aa6d5a6205291bef303eee5b7
4
- data.tar.gz: fac6040beba83e33006d18b7aa3da0a1bfcac0db
3
+ metadata.gz: 27d1513d8d309bceab4f388476844564a5163ff7
4
+ data.tar.gz: 40dca9e43b72d5faff3e1bd0fa0b50da2fea8de7
5
5
  SHA512:
6
- metadata.gz: 9c72ff89331bfb556082c0a9c73867b6598f84fa3a8ecfe14f746648b965ca6ae968d8062f21363aa458e382179ff505c68f769673f88fabddfa8cb0a9541a13
7
- data.tar.gz: 38ddcbd216f2c29d1af27e300ee9abf37119239f1333b3a9a88af10e2db6e9150ab76608a1c3af62e82df10f6180663e03fc5e7bee424ba8b0cf0508ae7719e8
6
+ metadata.gz: d737db962c9335eb724e0538813282e5a2f197431fc49bb17f05b7e20d5a5908f227db59a8af6976a7f7eb4fab813dffef28fd8924b6cf76835f9234bf40b69d
7
+ data.tar.gz: 3ba1a9106292b8e7c42518a4b46488079d6ca28d76cc88abbfabace11cc28391ffaf552320af0de72cf2e6a1fb8c2c4e4f835b7532df33f249e85f9e439e200b
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- buildbox (0.3.9)
4
+ buildbox (0.4)
5
5
  celluloid (~> 0.14)
6
6
  childprocess (~> 0.3)
7
7
  faraday (~> 0.8)
data/README.md CHANGED
@@ -5,14 +5,10 @@
5
5
  Install the gem
6
6
 
7
7
  $ gem install buildbox
8
-
9
- Authenticate
10
8
 
11
- $ buildbox auth:login [api_key]
9
+ Add your agent access token
12
10
 
13
- Add your worker tokens
14
-
15
- $ buildbox agent:setup [token]
11
+ $ buildbox agent:setup [agent_access_token]
16
12
 
17
13
  Then you can start monitoring for builds like so:
18
14
 
@@ -19,9 +19,9 @@ module Buildbox
19
19
 
20
20
  while build = @queue.pop do
21
21
  # Let the agent know that we're about to start running this build
22
- @api.update_build(build, :agent_accepted => @access_token)
22
+ @api.update_build(@access_token, build, :agent_accepted => @access_token)
23
23
 
24
- Monitor.new(build, @api).async.monitor
24
+ Monitor.new(build, @access_token, @api).async.monitor
25
25
  Runner.new(build).start
26
26
  end
27
27
 
@@ -32,8 +32,8 @@ module Buildbox
32
32
  private
33
33
 
34
34
  def scheduled_builds
35
- agent = @api.agent(@access_token, :hostname => hostname, :version => Buildbox::VERSION)
36
- @api.scheduled_builds agent
35
+ @api.agent(@access_token, :hostname => hostname, :version => Buildbox::VERSION)
36
+ @api.scheduled_builds(@access_token)
37
37
  rescue Buildbox::API::AgentNotFoundError
38
38
  warn "Agent `#{@access_token}` does not exist"
39
39
  [] # return empty array to avoid breakage
@@ -12,6 +12,7 @@ module Buildbox
12
12
  def initialize(logger)
13
13
  @logger = logger
14
14
  end
15
+
15
16
  def info(*args)
16
17
  @logger.debug(*args)
17
18
  end
@@ -29,35 +30,28 @@ module Buildbox
29
30
  @logger = logger
30
31
  end
31
32
 
32
- def authenticate(api_key)
33
- @api_key = api_key
34
-
35
- get("user")
36
- end
37
-
38
33
  def agent(access_token, options)
39
- put("agents/#{access_token}", options)
34
+ put(access_token, options)
40
35
  rescue Faraday::Error::ClientError => e
41
- if e.response[:status] == 404
36
+ if e.response && e.response[:status] == 404
42
37
  raise AgentNotFoundError.new(e, e.response)
43
38
  else
44
39
  raise ServerError.new(e, e.response)
45
40
  end
46
41
  end
47
42
 
48
- def scheduled_builds(agent)
49
- get(agent.scheduled_builds_url).map { |build| Buildbox::Build.new(build) }
43
+ def scheduled_builds(access_token)
44
+ get("#{access_token}/builds/scheduled").map { |build| Buildbox::Build.new(build) }
50
45
  end
51
46
 
52
- def update_build(build, options)
53
- put(build.url, options)
47
+ def update_build(access_token, build, options)
48
+ put("#{access_token}/builds/#{build.id}", options)
54
49
  end
55
50
 
56
51
  private
57
52
 
58
53
  def connection
59
54
  @connection ||= Faraday.new(:url => @config.api_endpoint) do |faraday|
60
- faraday.basic_auth @api_key || @config.api_key, ''
61
55
  faraday.request :retry
62
56
  faraday.request :json
63
57
 
@@ -9,11 +9,11 @@ module Buildbox
9
9
  @commands = {}
10
10
  @options = {}
11
11
 
12
- @commands['auth:login'] = OptionParser.new do |opts|
13
- opts.banner = "Usage: buildbox auth:login"
12
+ @commands['agent:setup'] = OptionParser.new do |opts|
13
+ opts.banner = "Usage: buildbox agent:setup [token]"
14
14
 
15
15
  opts.on("--help", "You're looking at it.") do
16
- puts @commands['auth:login']
16
+ puts @commands['agent:setup']
17
17
  exit
18
18
  end
19
19
  end
@@ -27,15 +27,6 @@ module Buildbox
27
27
  end
28
28
  end
29
29
 
30
- @commands['agent:setup'] = OptionParser.new do |opts|
31
- opts.banner = "Usage: buildbox agent:setup [token]"
32
-
33
- opts.on("--help", "You're looking at it.") do
34
- puts @commands['agent:setup']
35
- exit
36
- end
37
- end
38
-
39
30
  @commands['version'] = OptionParser.new do |opts|
40
31
  opts.banner = "Usage: buildbox version"
41
32
  end
@@ -74,24 +65,6 @@ module Buildbox
74
65
  puts "Successfully added agent access token"
75
66
  puts "You can now start the agent with: buildbox agent:start."
76
67
  puts "If the agent is already running, you'll have to restart it for the new changes to take effect"
77
- elsif command == "auth:login"
78
- if @argv.length == 0
79
- puts "No api key provided"
80
- exit 1
81
- end
82
-
83
- api_key = @argv.first
84
-
85
- begin
86
- Buildbox::API.new.authenticate(api_key)
87
- Buildbox.config.update(:api_key => api_key)
88
-
89
- puts "Successfully added your api_key"
90
- puts "You can now add agents with: buildbox agent:setup [agent_token]"
91
- rescue
92
- puts "Could not authenticate your api_key"
93
- exit 1
94
- end
95
68
  end
96
69
  else
97
70
  puts global.help
@@ -112,7 +85,6 @@ module Buildbox
112
85
  def help
113
86
  <<HELP
114
87
 
115
- auth:login [api_key] # login to buildbox
116
88
  agent:setup [access_token] # set the access token for the agent
117
89
  agent:start # start the buildbox agent
118
90
  version # display version
@@ -18,14 +18,7 @@ module Buildbox
18
18
  end
19
19
 
20
20
  def api_endpoint
21
- ENV['BUILDBOX_API_ENDPOINT'] || self[:api_endpoint] || "https://api.buildbox.io/v1"
22
- end
23
-
24
- def check
25
- unless api_key
26
- puts "No api_key set. You can set it with\nbuildbox auth:login [api_key]"
27
- exit 1
28
- end
21
+ ENV['BUILDBOX_API_ENDPOINT'] || self[:api_endpoint] || "https://agent.buildbox.io/v1"
29
22
  end
30
23
 
31
24
  def update(attributes)
@@ -4,9 +4,10 @@ module Buildbox
4
4
  class Monitor
5
5
  include Celluloid
6
6
 
7
- def initialize(build, api)
8
- @build = build
9
- @api = api
7
+ def initialize(build, access_token, api)
8
+ @build = build
9
+ @access_token = access_token
10
+ @api = api
10
11
  end
11
12
 
12
13
  def monitor
@@ -17,10 +18,10 @@ module Buildbox
17
18
  # same finished_at timestamp throughout the entire method.
18
19
  finished_at = @build.finished_at
19
20
 
20
- updated_build = @api.update_build(@build, :started_at => @build.started_at,
21
- :finished_at => finished_at,
22
- :output => @build.output,
23
- :exit_status => @build.exit_status)
21
+ updated_build = @api.update_build(@access_token, @build, :started_at => @build.started_at,
22
+ :finished_at => finished_at,
23
+ :output => @build.output,
24
+ :exit_status => @build.exit_status)
24
25
 
25
26
  if updated_build.state == 'canceled' && !@build.cancelling?
26
27
  Buildbox::Canceler.new(@build).async.cancel
@@ -1,3 +1,3 @@
1
1
  module Buildbox
2
- VERSION = "0.3.9.1"
2
+ VERSION = "0.4"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: buildbox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.9.1
4
+ version: '0.4'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keith Pitt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-23 00:00:00.000000000 Z
11
+ date: 2013-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -225,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
225
  version: '0'
226
226
  requirements: []
227
227
  rubyforge_project:
228
- rubygems_version: 2.1.3
228
+ rubygems_version: 2.0.3
229
229
  signing_key:
230
230
  specification_version: 4
231
231
  summary: Ruby agent for buildbox