pcf_blue_green 0.32 → 0.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pcf_blue_green.rb +10 -3
- data/lib/pcf_blue_green/version.rb +1 -1
- data/spec/pcf_blue_green_spec.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a4f4f1981b3ac479f39115d0e3578dedc5664aa
|
4
|
+
data.tar.gz: 5bcc132d664993edec39483667b5d2007bac015e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e569d397e4a7af8c782ee8415f20b1b0a51bdea1c1b5c20e552dd58600ed27f2f98b4d37abb6ef703dd19c2ef21413e2930328f12456398ec9a6e509c36e8eaf
|
7
|
+
data.tar.gz: a2c71b0849421aa4f3890d1652d04771ebe43b60e596839eca2aeb01bbbdab1c18771072f2aa8342528b9a794b930b309bd9b45cd7d54273e7b3fd1a87865bd5
|
data/lib/pcf_blue_green.rb
CHANGED
@@ -22,6 +22,12 @@ module PcfBlueGreen
|
|
22
22
|
@space = space
|
23
23
|
@login_options = @options[:login]
|
24
24
|
login if call_login
|
25
|
+
cmd = "echo $(gem which pcf_blue_green)"
|
26
|
+
shell = Mixlib::ShellOut.new(cmd)
|
27
|
+
shell.run_command
|
28
|
+
gem_path = shell.stdout
|
29
|
+
sdf_path = gem_path.gsub("pcf_blue_green.rb\n", "shared-deploy-functions.sh")
|
30
|
+
@source_cmd = "source \'#{sdf_path}\'"
|
25
31
|
end
|
26
32
|
|
27
33
|
def cleanup_blue
|
@@ -36,11 +42,11 @@ module PcfBlueGreen
|
|
36
42
|
puts "cf_app is #{ENV['cf_app']}"
|
37
43
|
puts "green is #{ENV['green']}"
|
38
44
|
|
39
|
-
puts cf_routes_output
|
40
45
|
mapped_routes = []
|
41
46
|
|
42
47
|
if ENV['handle_all_paths']
|
43
48
|
cmd = "#{cf_routes_output} | tail -n +4 | awk '($5==ENVIRON[\"cf_app\"]) {print $3\" -n \"$2 \" --path \"substr($4,2) }' | xargs -n 5 #{map_route_command} #{ENV['green']}"
|
49
|
+
puts cmd
|
44
50
|
shell = Mixlib::ShellOut.new(cmd)
|
45
51
|
shell.run_command
|
46
52
|
unless shell.stderr.empty?
|
@@ -50,6 +56,7 @@ module PcfBlueGreen
|
|
50
56
|
mapped_routes += shell.stdout.split("\n")
|
51
57
|
end
|
52
58
|
cmd = "#{cf_routes_output} | tail -n +4 | awk '($4==ENVIRON[\"cf_app\"]) {print $3\" -n \" $2}' | xargs -n 3 #{map_route_command} #{ENV['green']}"
|
59
|
+
puts cmd
|
53
60
|
shell = Mixlib::ShellOut.new(cmd)
|
54
61
|
shell.run_command
|
55
62
|
unless shell.stderr.empty?
|
@@ -57,8 +64,8 @@ module PcfBlueGreen
|
|
57
64
|
raise PcfBlueGreen::CleanupBlueFailed
|
58
65
|
end
|
59
66
|
mapped_routes += shell.stdout.split("\n")
|
60
|
-
|
61
|
-
mapped_routes
|
67
|
+
puts "Mappped routes: #{mapped_routes.uniq.join(', ')} "
|
68
|
+
mapped_routes.uniq.join(",\n")
|
62
69
|
end
|
63
70
|
|
64
71
|
private
|
data/spec/pcf_blue_green_spec.rb
CHANGED
@@ -31,7 +31,7 @@ describe PcfBlueGreen do
|
|
31
31
|
@pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
|
32
32
|
@pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/simple_routes.txt')
|
33
33
|
@pcf_blue_green.stub(:map_route_command).and_return('echo')
|
34
|
-
expect(expected_routes).to eq(@pcf_blue_green.remap_routes
|
34
|
+
expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
|
35
35
|
end
|
36
36
|
|
37
37
|
it "it doesn't re-map routes with a path. Also doesn't re-map routes for other applications. Even with the same hostname" do
|
@@ -60,7 +60,7 @@ customapp-app-space-green apps.prod.domain.com -n otherapp}
|
|
60
60
|
@pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
|
61
61
|
@pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes.txt')
|
62
62
|
@pcf_blue_green.stub(:map_route_command).and_return('echo')
|
63
|
-
expect(expected_routes).to eq(@pcf_blue_green.remap_routes
|
63
|
+
expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
@@ -95,7 +95,7 @@ customapp-app-space-green apps.prod.domain.com -n otherapp}
|
|
95
95
|
@pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
|
96
96
|
@pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes.txt')
|
97
97
|
@pcf_blue_green.stub(:map_route_command).and_return('echo')
|
98
|
-
expect(expected_routes).to eq(@pcf_blue_green.remap_routes
|
98
|
+
expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
|
99
99
|
end
|
100
100
|
it "re-maps application routes including paths" do
|
101
101
|
|
@@ -129,7 +129,7 @@ second-app-app-space-green apps.prod.domain.com.com -n second-app}
|
|
129
129
|
@pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
|
130
130
|
@pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes_domain_host.txt')
|
131
131
|
@pcf_blue_green.stub(:map_route_command).and_return('echo')
|
132
|
-
expect(expected_routes).to eq(@pcf_blue_green.remap_routes
|
132
|
+
expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
|
133
133
|
end
|
134
134
|
|
135
135
|
it "re-maps application routes including paths. Also true for custom domain and host" do
|
@@ -160,7 +160,7 @@ third-app-app-space-green apps.prod.otherdomain.com -n third-app-other-host}
|
|
160
160
|
@pcf_blue_green = PcfBlueGreen::Routing.new(api_url, username, password, org, space, login = false)
|
161
161
|
@pcf_blue_green.stub(:cf_routes_output).and_return('cat spec/mocks/custom_routes_domain_host.txt')
|
162
162
|
@pcf_blue_green.stub(:map_route_command).and_return('echo')
|
163
|
-
expect(expected_routes).to eq(@pcf_blue_green.remap_routes
|
163
|
+
expect(expected_routes).to eq(@pcf_blue_green.remap_routes)
|
164
164
|
end
|
165
165
|
end
|
166
166
|
end
|