runpuppet 1.0.0 → 1.0.1
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.
- data/README.md +1 -1
- data/VERSION +1 -1
- data/lib/runpuppet/agent.rb +10 -3
- data/lib/runpuppet/client.rb +15 -7
- data/runpuppet.gemspec +1 -1
- data/test/agent_test.rb +9 -3
- data/test/client_test.rb +9 -6
- metadata +3 -3
data/README.md
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.1
|
data/lib/runpuppet/agent.rb
CHANGED
@@ -11,9 +11,16 @@ module Runpuppet
|
|
11
11
|
##### puppet
|
12
12
|
|
13
13
|
def check_status
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
begin
|
15
|
+
r = get("/puppet/run")
|
16
|
+
rescue Exception => e
|
17
|
+
end
|
18
|
+
|
19
|
+
if r
|
20
|
+
return (action, branch = *r.split('-'))
|
21
|
+
else
|
22
|
+
return nil
|
23
|
+
end
|
17
24
|
end
|
18
25
|
|
19
26
|
def report_start
|
data/lib/runpuppet/client.rb
CHANGED
@@ -13,8 +13,8 @@ module Runpuppet
|
|
13
13
|
|
14
14
|
def run
|
15
15
|
with_lock(config.lock_file) do
|
16
|
-
action, branch =
|
17
|
-
if
|
16
|
+
action, branch = calculate_run_params
|
17
|
+
if action == 'run'
|
18
18
|
agent.report_start
|
19
19
|
log "run #{branch}"
|
20
20
|
|
@@ -30,6 +30,19 @@ module Runpuppet
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
+
def calculate_run_params
|
34
|
+
(local_run_params || remote_run_params)
|
35
|
+
end
|
36
|
+
|
37
|
+
def local_run_params
|
38
|
+
return nil if run_options[:try]
|
39
|
+
return 'run', (run_options[:branch] ||config.default_branch)
|
40
|
+
end
|
41
|
+
|
42
|
+
def remote_run_params
|
43
|
+
agent.check_status
|
44
|
+
end
|
45
|
+
|
33
46
|
def run_command(branch)
|
34
47
|
cmd = if run_options[:verbose]
|
35
48
|
config.verbose_command
|
@@ -39,11 +52,6 @@ module Runpuppet
|
|
39
52
|
cmd.gsub('@@branch@@', branch)
|
40
53
|
end
|
41
54
|
|
42
|
-
def should_run?(action)
|
43
|
-
## always run if started without --try
|
44
|
-
(!run_options[:try] or action == 'run')
|
45
|
-
end
|
46
|
-
|
47
55
|
def with_lock(lock_file)
|
48
56
|
recently_locked = (File.exists?(lock_file) and File.mtime(lock_file) > Time.now - 15*60)
|
49
57
|
|
data/runpuppet.gemspec
CHANGED
data/test/agent_test.rb
CHANGED
@@ -2,7 +2,8 @@ require 'test/helper'
|
|
2
2
|
|
3
3
|
describe "Runpuppet::Agent" do
|
4
4
|
before do
|
5
|
-
@
|
5
|
+
@ctx = Dim::Container.new(TestContext)
|
6
|
+
@agent = @ctx.agent
|
6
7
|
end
|
7
8
|
|
8
9
|
describe :check_status do
|
@@ -10,6 +11,11 @@ describe "Runpuppet::Agent" do
|
|
10
11
|
@agent.stubs(:get).returns('run-master')
|
11
12
|
@agent.check_status.must_equal ["run", "master"]
|
12
13
|
end
|
14
|
+
|
15
|
+
it "returns nil for errors" do
|
16
|
+
@agent.stubs(:get).raises(RuntimeError)
|
17
|
+
@agent.check_status.must_be_nil
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
21
|
describe :base_url do
|
@@ -20,8 +26,8 @@ describe "Runpuppet::Agent" do
|
|
20
26
|
|
21
27
|
describe "URL manipulation" do
|
22
28
|
before do
|
23
|
-
|
24
|
-
|
29
|
+
@ctx.config.stubs(:local_ip).returns('10.10.10.10')
|
30
|
+
@ctx.config.stubs(:hostname).returns('example-vm')
|
25
31
|
end
|
26
32
|
|
27
33
|
|
data/test/client_test.rb
CHANGED
@@ -18,20 +18,23 @@ describe "Client" do
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
-
describe :
|
21
|
+
describe :local_run_params do
|
22
22
|
it "always runs without --try option" do
|
23
23
|
@ctx.register(:run_options){ {:try => false} }
|
24
|
-
@ctx.client.
|
24
|
+
@ctx.client.local_run_params.must_equal ["run", "master"]
|
25
25
|
end
|
26
26
|
|
27
|
-
it "
|
27
|
+
it "is nil with --try option" do
|
28
28
|
@ctx.register(:run_options){ {:try => true} }
|
29
|
-
@ctx.client.
|
29
|
+
@ctx.client.local_run_params.must_be_nil
|
30
30
|
end
|
31
|
+
end
|
31
32
|
|
32
|
-
|
33
|
+
describe :remote_run_params do
|
34
|
+
it "always runs without --try option" do
|
33
35
|
@ctx.register(:run_options){ {:try => true} }
|
34
|
-
@ctx.client.
|
36
|
+
@ctx.client.stubs(:remote_run_params).returns(["run", "master"])
|
37
|
+
@ctx.client.calculate_run_params.must_equal ['run', 'master']
|
35
38
|
end
|
36
39
|
end
|
37
40
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: runpuppet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Roman Heinrich
|