ol-whisk_deploy 0.6.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/CHANGELOG +292 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.integration_specs +24 -0
  4. data/README.markdown +832 -0
  5. data/Rakefile +105 -0
  6. data/VERSION +1 -0
  7. data/WHY.txt +45 -0
  8. data/bin/wd +61 -0
  9. data/bin/wd_role +42 -0
  10. data/examples/deploy-configs.yml +13 -0
  11. data/examples/deploy-local.yml +4 -0
  12. data/examples/deploy-multiple-remotes.yml +26 -0
  13. data/examples/deploy-staging.yml +8 -0
  14. data/examples/deploy.rake +11 -0
  15. data/examples/deploy.yml +16 -0
  16. data/init.rb +1 -0
  17. data/install.rb +5 -0
  18. data/lib/whiskey_disk.rb +327 -0
  19. data/lib/whiskey_disk/config.rb +127 -0
  20. data/lib/whiskey_disk/config/abstract_filter.rb +19 -0
  21. data/lib/whiskey_disk/config/filter.rb +48 -0
  22. data/lib/whiskey_disk/config/filters/add_environment_name_filter.rb +11 -0
  23. data/lib/whiskey_disk/config/filters/add_project_name_filter.rb +11 -0
  24. data/lib/whiskey_disk/config/filters/check_for_duplicate_domains_filter.rb +21 -0
  25. data/lib/whiskey_disk/config/filters/convert_role_strings_to_list_filter.rb +20 -0
  26. data/lib/whiskey_disk/config/filters/default_config_target_filter.rb +12 -0
  27. data/lib/whiskey_disk/config/filters/default_domain_filter.rb +12 -0
  28. data/lib/whiskey_disk/config/filters/drop_empty_domain_roles_filter.rb +32 -0
  29. data/lib/whiskey_disk/config/filters/environment_scope_filter.rb +20 -0
  30. data/lib/whiskey_disk/config/filters/hashify_domain_entries_filter.rb +29 -0
  31. data/lib/whiskey_disk/config/filters/localize_domains_filter.rb +24 -0
  32. data/lib/whiskey_disk/config/filters/modules/scope_helper.rb +11 -0
  33. data/lib/whiskey_disk/config/filters/normalize_ssh_options_filter.rb +29 -0
  34. data/lib/whiskey_disk/config/filters/project_scope_filter.rb +34 -0
  35. data/lib/whiskey_disk/config/filters/select_project_and_environment_filter.rb +12 -0
  36. data/lib/whiskey_disk/config/filters/stringify_hash_keys_filter.rb +25 -0
  37. data/lib/whiskey_disk/helpers.rb +50 -0
  38. data/lib/whiskey_disk/rake.rb +47 -0
  39. data/scenarios/git_repositories/config.git/HEAD +1 -0
  40. data/scenarios/git_repositories/config.git/config +5 -0
  41. data/scenarios/git_repositories/config.git/description +1 -0
  42. data/scenarios/git_repositories/config.git/git-daemon-export-ok +0 -0
  43. data/scenarios/git_repositories/config.git/hooks/applypatch-msg.sample +15 -0
  44. data/scenarios/git_repositories/config.git/hooks/commit-msg.sample +24 -0
  45. data/scenarios/git_repositories/config.git/hooks/post-commit.sample +8 -0
  46. data/scenarios/git_repositories/config.git/hooks/post-receive.sample +15 -0
  47. data/scenarios/git_repositories/config.git/hooks/post-update.sample +8 -0
  48. data/scenarios/git_repositories/config.git/hooks/pre-applypatch.sample +14 -0
  49. data/scenarios/git_repositories/config.git/hooks/pre-commit.sample +46 -0
  50. data/scenarios/git_repositories/config.git/hooks/pre-rebase.sample +169 -0
  51. data/scenarios/git_repositories/config.git/hooks/prepare-commit-msg.sample +36 -0
  52. data/scenarios/git_repositories/config.git/hooks/update.sample +128 -0
  53. data/scenarios/git_repositories/config.git/info/exclude +6 -0
  54. data/scenarios/git_repositories/config.git/objects/0d/b14dd6ddc54017c0a11960dcda82ed802cde69 +0 -0
  55. data/scenarios/git_repositories/config.git/objects/0e/e781f5ce80d64db32a74a7aae7b5248dafe112 +3 -0
  56. data/scenarios/git_repositories/config.git/objects/17/6bf54cf17d1d1c24556dc059c4144a5df230e8 +0 -0
  57. data/scenarios/git_repositories/config.git/objects/20/e9ff3feaa8ede30f707e5f1b4356e3c02bb7ec +0 -0
  58. data/scenarios/git_repositories/config.git/objects/45/117b1c775f0de415478dbf08ed9d667ab17d13 +0 -0
  59. data/scenarios/git_repositories/config.git/objects/51/3954c9aca090e6ce40359f0e9fde30ea78eb8c +0 -0
  60. data/scenarios/git_repositories/config.git/objects/66/947a7a11a6f5d3d561fe95de284ced3010819a +0 -0
  61. data/scenarios/git_repositories/config.git/objects/6b/bc79311bfac47d3ed724aa82a4814e0dda4c67 +0 -0
  62. data/scenarios/git_repositories/config.git/objects/71/eb5df52676e8e6efba471050b46978173af110 +1 -0
  63. data/scenarios/git_repositories/config.git/objects/84/17d2fe3e8fcc0825249c517b29b0f9ea8b8b31 +2 -0
  64. data/scenarios/git_repositories/config.git/objects/8b/384fcfcf7c0dee7c3c1d5636bee9e645d9cf38 +0 -0
  65. data/scenarios/git_repositories/config.git/objects/bb/59da633ba74296b0c2f9ff70784ac155ddb599 +0 -0
  66. data/scenarios/git_repositories/config.git/objects/cc/b86b26189afbf45d8eb9165812ab86dbdfca63 +0 -0
  67. data/scenarios/git_repositories/config.git/objects/d1/0bcd51fec41f854001e4d61f99d9e282a695d3 +0 -0
  68. data/scenarios/git_repositories/config.git/objects/d8/a8b0f5b1fd66844efb141d9544965ea0065f2d +0 -0
  69. data/scenarios/git_repositories/config.git/objects/e6/b02c66ad632e6b8535c4630cb8fe07732a72fc +0 -0
  70. data/scenarios/git_repositories/config.git/objects/e8/b8bfeeba735c0a1a873082554cb4d7256ac125 +0 -0
  71. data/scenarios/git_repositories/config.git/objects/f9/0181466a1a60b793ca9cc9abd584c18d4e3887 +0 -0
  72. data/scenarios/git_repositories/config.git/objects/f9/49d5d8a4f12c91471e34d4e277239c35ebd10d +0 -0
  73. data/scenarios/git_repositories/config.git/refs/heads/master +1 -0
  74. data/scenarios/git_repositories/project.git/HEAD +1 -0
  75. data/scenarios/git_repositories/project.git/config +5 -0
  76. data/scenarios/git_repositories/project.git/description +1 -0
  77. data/scenarios/git_repositories/project.git/git-daemon-export-ok +0 -0
  78. data/scenarios/git_repositories/project.git/hooks/applypatch-msg.sample +15 -0
  79. data/scenarios/git_repositories/project.git/hooks/commit-msg.sample +24 -0
  80. data/scenarios/git_repositories/project.git/hooks/post-commit.sample +8 -0
  81. data/scenarios/git_repositories/project.git/hooks/post-receive.sample +15 -0
  82. data/scenarios/git_repositories/project.git/hooks/post-update.sample +8 -0
  83. data/scenarios/git_repositories/project.git/hooks/pre-applypatch.sample +14 -0
  84. data/scenarios/git_repositories/project.git/hooks/pre-commit.sample +46 -0
  85. data/scenarios/git_repositories/project.git/hooks/pre-rebase.sample +169 -0
  86. data/scenarios/git_repositories/project.git/hooks/prepare-commit-msg.sample +36 -0
  87. data/scenarios/git_repositories/project.git/hooks/update.sample +128 -0
  88. data/scenarios/git_repositories/project.git/info/exclude +6 -0
  89. data/scenarios/git_repositories/project.git/objects/04/26e152e66c8cd42974279bdcae09be9839c172 +0 -0
  90. data/scenarios/git_repositories/project.git/objects/04/f4de85eaf72ef1631dc6d7424045c0a749b757 +1 -0
  91. data/scenarios/git_repositories/project.git/objects/06/13fe277280cbcdb2856e1eefc70bdaff011b20 +0 -0
  92. data/scenarios/git_repositories/project.git/objects/06/7aca89b86265eee211387434c3e50f37ccf009 +0 -0
  93. data/scenarios/git_repositories/project.git/objects/09/445dacc4822722612d60833c9948219ecdd8f5 +0 -0
  94. data/scenarios/git_repositories/project.git/objects/11/c4ec64326de35462f4e79d0f4229bf8e26e0c5 +0 -0
  95. data/scenarios/git_repositories/project.git/objects/20/1c7641c2e42b0b904e5c1f793489d8b858e4da +2 -0
  96. data/scenarios/git_repositories/project.git/objects/23/979639da60d2d31e9744468df1c1221b101e64 +0 -0
  97. data/scenarios/git_repositories/project.git/objects/27/a3fff2c4c45ab5513a405f694c0a042cb5d417 +1 -0
  98. data/scenarios/git_repositories/project.git/objects/2c/0c33cfba8e1af15df88522c0db2b10a6a94138 +2 -0
  99. data/scenarios/git_repositories/project.git/objects/38/b574660305ecb5fec6b2daa7ee1e0dbf1b6003 +0 -0
  100. data/scenarios/git_repositories/project.git/objects/4a/57abb5e4e426cfc9101b3af22ac83ccbd8e2ad +0 -0
  101. data/scenarios/git_repositories/project.git/objects/4c/77ebdd985e57afe7988480720c5dc77ec525c9 +0 -0
  102. data/scenarios/git_repositories/project.git/objects/51/c94da6f1b8aa9d2346088d3d362475b60c7f32 +0 -0
  103. data/scenarios/git_repositories/project.git/objects/5b/a96acf9cc9b87babe37c032676f53bf1ba9ae7 +2 -0
  104. data/scenarios/git_repositories/project.git/objects/5d/f555601d60f1c2a84d2364af0ad640612c3ba5 +0 -0
  105. data/scenarios/git_repositories/project.git/objects/71/03b5ac94940d596c2160a5cfcd55ca4ccac41f +0 -0
  106. data/scenarios/git_repositories/project.git/objects/73/3fc331098b03523f414f3509b9ae6e637c6866 +0 -0
  107. data/scenarios/git_repositories/project.git/objects/80/26076649ceccbe96a6292f2432652f08483035 +0 -0
  108. data/scenarios/git_repositories/project.git/objects/86/d1ef0976be4567de562224e1b51fbf9820c53a +1 -0
  109. data/scenarios/git_repositories/project.git/objects/87/a9d8b09b3401d21b23d90253332d6b28b47db2 +0 -0
  110. data/scenarios/git_repositories/project.git/objects/8b/030ba688255c917d189ae3f87d7c5ccd226bc2 +0 -0
  111. data/scenarios/git_repositories/project.git/objects/95/c9d5ad9b1c90e4c805516783105fc2037dedeb +2 -0
  112. data/scenarios/git_repositories/project.git/objects/95/d82d043af35a80eabfd56c0d705abfa3488787 +2 -0
  113. data/scenarios/git_repositories/project.git/objects/96/0bf34bb0b46d0aeb0be87f688f4ef06a4b35e1 +0 -0
  114. data/scenarios/git_repositories/project.git/objects/a3/860106dc1d148c7831cd45ae38829b4ed47702 +2 -0
  115. data/scenarios/git_repositories/project.git/objects/a8/506d6439b71784a72ac72d284b2ad53088f573 +0 -0
  116. data/scenarios/git_repositories/project.git/objects/ad/22ea6c7563777936ecfbe50d8e2cf8120fd525 +0 -0
  117. data/scenarios/git_repositories/project.git/objects/ae/3900de54aff557c61c81146d00f9d38e55a265 +1 -0
  118. data/scenarios/git_repositories/project.git/objects/bf/5e3740d52b80abb0378b3f85f93a53b1294521 +1 -0
  119. data/scenarios/git_repositories/project.git/objects/bf/b59811cdbc069418dee14b171e6e7e979784b7 +0 -0
  120. data/scenarios/git_repositories/project.git/objects/cc/5ac0afb24e727d5de344cc26a425f4fb7fd17d +3 -0
  121. data/scenarios/git_repositories/project.git/objects/d1/091aa2dd76885108461110c639e6b33a297fce +0 -0
  122. data/scenarios/git_repositories/project.git/objects/d8/913f6650eb2b7bf2a633732d8452008ca23dcb +0 -0
  123. data/scenarios/git_repositories/project.git/objects/db/d1b9667f1b26b13331ac0c321dced8be1aeab0 +3 -0
  124. data/scenarios/git_repositories/project.git/objects/e4/3b9107e9b1908ce415025e64eb83a493d329b7 +0 -0
  125. data/scenarios/git_repositories/project.git/objects/ef/2a88894d5421920b9dfe67a9a4d8043830e62e +0 -0
  126. data/scenarios/git_repositories/project.git/objects/f4/0123a1ff20c65d8dc15a38a83222647908e6f7 +0 -0
  127. data/scenarios/git_repositories/project.git/objects/f5/0af315b75ca0b12c720dec6d916b76b968c319 +0 -0
  128. data/scenarios/git_repositories/project.git/objects/f6/0215709b7b23f3738e9cbaf634b1c86bbd376a +0 -0
  129. data/scenarios/git_repositories/project.git/refs/heads/bad_rakefile +1 -0
  130. data/scenarios/git_repositories/project.git/refs/heads/hook_with_changed +1 -0
  131. data/scenarios/git_repositories/project.git/refs/heads/master +1 -0
  132. data/scenarios/git_repositories/project.git/refs/heads/no_rake_hooks +1 -0
  133. data/scenarios/git_repositories/project.git/refs/heads/post_rake_tasks +1 -0
  134. data/scenarios/invalid/deploy.yml +1 -0
  135. data/scenarios/local/deploy.yml.erb +17 -0
  136. data/scenarios/remote/deploy.yml +119 -0
  137. data/scenarios/setup/vagrant/.gitignore +3 -0
  138. data/scenarios/setup/vagrant/Vagrantfile +10 -0
  139. data/scenarios/setup/vagrant/manifests/integration.pp +32 -0
  140. data/scenarios/setup/vagrant/pids/.gitignore +1 -0
  141. data/spec/.bacon +0 -0
  142. data/spec/init_spec.rb +9 -0
  143. data/spec/install_spec.rb +43 -0
  144. data/spec/integration/branch_switching_spec.rb +41 -0
  145. data/spec/integration/deployment_failures_spec.rb +106 -0
  146. data/spec/integration/helper_spec.rb +90 -0
  147. data/spec/integration/invalid_configuration_spec.rb +39 -0
  148. data/spec/integration/local_deployments_spec.rb +230 -0
  149. data/spec/integration/post_rake_tasks_spec.rb +226 -0
  150. data/spec/integration/post_scripts_spec.rb +246 -0
  151. data/spec/integration/remote_deployments_spec.rb +166 -0
  152. data/spec/integration/staleness_checks_spec.rb +72 -0
  153. data/spec/spec_helper.rb +117 -0
  154. data/spec/wd_command_spec.rb +986 -0
  155. data/spec/wd_role_command_spec.rb +49 -0
  156. data/spec/whiskey_disk/config/filter_spec.rb +77 -0
  157. data/spec/whiskey_disk/config/filters/add_environment_name_filter_spec.rb +20 -0
  158. data/spec/whiskey_disk/config/filters/add_project_name_filter_spec.rb +19 -0
  159. data/spec/whiskey_disk/config/filters/check_for_duplicate_domains_filter_spec.rb +29 -0
  160. data/spec/whiskey_disk/config/filters/convert_role_strings_to_list_filter_spec.rb +48 -0
  161. data/spec/whiskey_disk/config/filters/default_config_target_filter_spec.rb +19 -0
  162. data/spec/whiskey_disk/config/filters/default_domain_filter_spec.rb +18 -0
  163. data/spec/whiskey_disk/config/filters/drop_empty_domain_roles_filter_spec.rb +60 -0
  164. data/spec/whiskey_disk/config/filters/environment_scope_filter_spec.rb +32 -0
  165. data/spec/whiskey_disk/config/filters/hashify_domain_entries_filter_spec.rb +41 -0
  166. data/spec/whiskey_disk/config/filters/localize_domains_filter_spec.rb +30 -0
  167. data/spec/whiskey_disk/config/filters/normalize_ssh_options_filter_spec.rb +56 -0
  168. data/spec/whiskey_disk/config/filters/project_scope_filter_spec.rb +75 -0
  169. data/spec/whiskey_disk/config/filters/select_project_and_environment_filter_spec.rb +30 -0
  170. data/spec/whiskey_disk/config/filters/stringify_hash_keys_filter_spec.rb +40 -0
  171. data/spec/whiskey_disk/config_spec.rb +754 -0
  172. data/spec/whiskey_disk/helpers_spec.rb +443 -0
  173. data/spec/whiskey_disk/rake_spec.rb +261 -0
  174. data/spec/whiskey_disk_spec.rb +1224 -0
  175. data/tasks/deploy.rake +2 -0
  176. data/whisk_deploy.gemspec +215 -0
  177. metadata +242 -0
@@ -0,0 +1,49 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ def run_command
4
+ eval File.read(File.join(File.dirname(__FILE__), *%w[.. bin wd_role]))
5
+ end
6
+
7
+ describe 'wd role command' do
8
+ before do
9
+ ENV['WD_ROLES'] = nil
10
+ end
11
+
12
+ describe 'when no command-line arguments are specified' do
13
+ before do
14
+ Object.send(:remove_const, :ARGV)
15
+ ARGV = []
16
+ end
17
+
18
+ it 'fails' do
19
+ lambda { run_command }.should.raise(SystemExit)
20
+ end
21
+ end
22
+
23
+ describe "when a role is specified on the command-line" do
24
+ before do
25
+ Object.send(:remove_const, :ARGV)
26
+ ARGV = ['app']
27
+ end
28
+
29
+ it 'fails when no WD_ROLES environment setting is present' do
30
+ ENV['WD_ROLES'] = nil
31
+ lambda { run_command }.should.raise(SystemExit)
32
+ end
33
+
34
+ it 'fails when an empty WD_ROLES environment setting is present' do
35
+ ENV['WD_ROLES'] = ''
36
+ lambda { run_command }.should.raise(SystemExit)
37
+ end
38
+
39
+ it 'fails when the WD_ROLES environment setting does not contain that role' do
40
+ ENV['WD_ROLES'] = 'web:nonapp:db'
41
+ lambda { run_command }.should.raise(SystemExit)
42
+ end
43
+
44
+ it 'succeeds when the WD_ROLES environment setting contains that role' do
45
+ ENV['WD_ROLES'] = 'web:app:db'
46
+ lambda { run_command }.should.not.raise
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,77 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filter'))
4
+
5
+ describe WhiskeyDisk::Config::Filter, 'filtering configuration data' do
6
+ before do
7
+ ENV['to'] = @env = 'foo:erl'
8
+
9
+ @config = WhiskeyDisk::Config.new
10
+ @filter = WhiskeyDisk::Config::Filter.new(@config)
11
+
12
+ @data = {
13
+ 'foo' => {
14
+ 'xyz' => { 'repository' => 'x' },
15
+ 'eee' => { 'repository' => 'x', 'domain' => '' },
16
+ 'abc' => { 'repository' => 'x', 'domain' => 'what@example.com' },
17
+ 'baz' => { 'repository' => 'x', 'domain' => [ 'bar@example.com', 'baz@domain.com' ]},
18
+ 'bar' => { 'repository' => 'x', 'domain' => [ 'user@example.com', nil, 'foo@domain.com' ]},
19
+ 'bat' => { 'repository' => 'x', 'domain' => [ 'user@example.com', 'foo@domain.com', '' ]},
20
+ 'hsh' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com' }, { 'name' => 'baz@domain.com' } ]},
21
+ 'mix' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com' }, 'baz@domain.com' ]},
22
+ 'erl' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com',
23
+ 'roles' => nil,
24
+ 'ssh_options' => ['-t', '-v' ] },
25
+ { 'name' => 'baz@domain.com',
26
+ 'ssh_options' => '-t',
27
+ 'roles' => '' },
28
+ { 'name' => 'aok@domain.com',
29
+ 'ssh_options' => [],
30
+ 'roles' => [] } ]},
31
+ 'rol' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com', 'roles' => [ 'web', 'db' ] },
32
+ { 'name' => 'baz@domain.com', 'roles' => [ 'db' ] },
33
+ { 'name' => 'aok@domain.com', 'roles' => 'app' } ]},
34
+ 'wow' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com', 'roles' => [ 'web', 'db' ] },
35
+ { 'name' => 'baz@domain.com', 'roles' => [ 'db' ] },
36
+ '', 'foo@bar.example.com',
37
+ { 'name' => 'aok@domain.com', 'roles' => 'app' } ]},
38
+ },
39
+
40
+ 'zyx' => {
41
+ 'xyz' => { 'repository' => 'x' },
42
+ 'eee' => { 'repository' => 'x', 'domain' => '' },
43
+ 'abc' => { 'repository' => 'x', 'domain' => 'what@example.com' },
44
+ 'hij' => { 'repository' => 'x', 'domain' => [ 'bar@example.com', 'baz@domain.com' ]},
45
+ 'def' => { 'repository' => 'x', 'domain' => [ 'user@example.com', nil, 'foo@domain.com' ]},
46
+ 'dex' => { 'repository' => 'x', 'domain' => [ 'user@example.com', 'foo@domain.com', '' ]},
47
+ 'hsh' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com' }, { 'name' => 'baz@domain.com' } ]},
48
+ 'mix' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com' }, 'baz@domain.com' ]},
49
+ 'erl' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com', 'roles' => nil },
50
+ { 'name' => 'baz@domain.com', 'roles' => '' },
51
+ { 'name' => 'aok@domain.com', 'roles' => [] } ]},
52
+ 'rol' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com', 'roles' => [ 'web', 'db' ] },
53
+ { 'name' => 'baz@domain.com', 'roles' => [ 'db' ] },
54
+ { 'name' => 'aok@domain.com', 'roles' => 'app' } ]},
55
+ 'wow' => { 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com', 'roles' => [ 'web', 'db' ] },
56
+ { 'name' => 'baz@domain.com', 'roles' => [ 'db' ] },
57
+ '', 'foo@bar.example.com',
58
+ { 'name' => 'aok@domain.com', 'roles' => 'app' } ]},
59
+ }
60
+ }
61
+ end
62
+
63
+ it 'should apply all available filters' do
64
+ @filter.filter_data(@data).should == {
65
+ 'repository' => "x",
66
+ 'project' => "foo",
67
+ 'config_target' => "erl",
68
+ 'environment' => "erl",
69
+ 'domain' => [
70
+ { 'name' => "bar@example.com", 'ssh_options' => [ '-t', '-v' ] },
71
+ { 'name' => "baz@domain.com", 'ssh_options' => [ '-t' ] },
72
+ { 'name' => "aok@domain.com" }
73
+ ]
74
+ }
75
+ end
76
+ end
77
+
@@ -0,0 +1,20 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'add_environment_name_filter'))
4
+
5
+ describe 'filtering configuration data by adding the environment name' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::AddEnvironmentNameFilter.new(@config)
9
+
10
+ ENV['to'] = 'project:environment'
11
+ end
12
+
13
+ it 'adds an environment value when none is present' do
14
+ @filter.filter('foo' => 'bar').should == { 'environment' => 'environment', 'foo' => 'bar' }
15
+ end
16
+
17
+ it 'overwrites an environment value when one is present' do
18
+ @filter.filter('environment' => 'baz', 'foo' => 'bar').should == { 'environment' => 'environment', 'foo' => 'bar' }
19
+ end
20
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'add_project_name_filter'))
4
+
5
+ describe 'filtering configuration data by adding the project name' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::AddProjectNameFilter.new(@config)
9
+ ENV['to'] = 'project:environment'
10
+ end
11
+
12
+ it 'adds an environment value when none is present' do
13
+ @filter.filter('foo' => 'bar').should == { 'project' => 'project', 'foo' => 'bar' }
14
+ end
15
+
16
+ it 'overwrites an environment value when one is present' do
17
+ @filter.filter('project' => 'baz', 'foo' => 'bar').should == { 'project' => 'project', 'foo' => 'bar' }
18
+ end
19
+ end
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'check_for_duplicate_domains_filter'))
4
+
5
+ describe 'filtering configuration data by normalizing domains' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::CheckForDuplicateDomainsFilter.new(@config)
9
+ end
10
+
11
+ it 'should return the suuplied data if no domains appear more than once in a target' do
12
+ @data = {
13
+ 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com', 'roles' => nil },
14
+ { 'name' => 'baz@domain.com', 'roles' => '' } ]
15
+ }
16
+
17
+ @filter.filter(@data).should == @data
18
+ end
19
+
20
+ it 'raises an exception if a domain appears more than once in a target' do
21
+ @data = {
22
+ 'repository' => 'x', 'domain' => [ { 'name' => 'bar@example.com', 'roles' => nil },
23
+ { 'name' => 'baz@domain.com', 'roles' => '' },
24
+ { 'name' => 'bar@example.com', 'roles' => [] } ]
25
+ }
26
+
27
+ lambda { @filter.filter(@data) }.should.raise
28
+ end
29
+ end
@@ -0,0 +1,48 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'convert_role_strings_to_list_filter'))
4
+
5
+ describe 'converting domain role strings into lists' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::ConvertRoleStringsToListFilter.new(@config)
9
+ end
10
+
11
+ it 'handles single strings' do
12
+ @data = {
13
+ 'domain' => [
14
+ { 'name' => 'foo', 'roles' => 'baz' },
15
+ { 'name' => 'bar', 'roles' => 'xyzzy' },
16
+ ]
17
+ }
18
+
19
+ @filter.filter(@data).should == {
20
+ 'domain' => [
21
+ { 'name' => 'foo', 'roles' => [ 'baz' ] },
22
+ { 'name' => 'bar', 'roles' => [ 'xyzzy' ] },
23
+ ]
24
+ }
25
+ end
26
+
27
+ it 'does not touch domains without roles' do
28
+ @data = {
29
+ 'domain' => [
30
+ { 'name' => 'foo' },
31
+ { 'name' => 'bar' }
32
+ ]
33
+ }
34
+
35
+ @filter.filter(@data).should == @data
36
+ end
37
+
38
+ it 'leaves existing role lists alone' do
39
+ @data = {
40
+ 'domain' => [
41
+ { 'name' => 'foo', 'roles' => [ 'baz' ] },
42
+ { 'name' => 'bar', 'roles' => [ 'xyzzy', 'quux' ] },
43
+ ]
44
+ }
45
+
46
+ @filter.filter(@data).should == @data
47
+ end
48
+ end
@@ -0,0 +1,19 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'default_config_target_filter'))
4
+
5
+ describe 'filtering configuration data by defaulting the config target' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::DefaultConfigTargetFilter.new(@config)
9
+ ENV['to'] = 'project:environment'
10
+ end
11
+
12
+ it 'adds a config_target value set to the environment name when none is present' do
13
+ @filter.filter('foo' => 'bar').should == { 'config_target' => 'environment', 'foo' => 'bar' }
14
+ end
15
+
16
+ it 'preserves the existing config_target when one is present' do
17
+ @filter.filter('config_target' => 'baz', 'foo' => 'bar').should == { 'config_target' => 'baz', 'foo' => 'bar' }
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'default_domain_filter'))
4
+
5
+ describe 'setting empty domain entries to "local"' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::DefaultDomainFilter.new(@config)
9
+ end
10
+
11
+ it 'leaves data intact if it has a domain' do
12
+ @filter.filter({ 'domain' => 'anything' }).should == { 'domain' => 'anything' }
13
+ end
14
+
15
+ it 'adds a local domain entry if data does not have a domain' do
16
+ @filter.filter({}).should == { 'domain' => [{ 'name' => 'local' }] }
17
+ end
18
+ end
@@ -0,0 +1,60 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'drop_empty_domain_roles_filter'))
4
+
5
+ describe 'converting domain role strings into lists' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::DropEmptyDomainRolesFilter.new(@config)
9
+ end
10
+
11
+ it 'drops roles with nil values' do
12
+ @data = {
13
+ 'domain' => [
14
+ { 'name' => 'foo', 'roles' => nil },
15
+ { 'name' => 'bar', 'roles' => nil }
16
+ ]
17
+ }
18
+
19
+ @filter.filter(@data).should == {
20
+ 'domain' => [
21
+ { 'name' => 'foo' },
22
+ { 'name' => 'bar' }
23
+ ]
24
+ }
25
+ end
26
+
27
+ it 'drops roles with empty list values' do
28
+ @data = {
29
+ 'domain' => [
30
+ { 'name' => 'foo', 'roles' => [] },
31
+ { 'name' => 'bar', 'roles' => [] }
32
+ ]
33
+ }
34
+
35
+ @filter.filter(@data).should == {
36
+ 'domain' => [
37
+ { 'name' => 'foo' },
38
+ { 'name' => 'bar' }
39
+ ]
40
+ }
41
+ end
42
+
43
+ it 'preserves non-empty roles' do
44
+ @data = {
45
+ 'domain' => [
46
+ { 'name' => 'foo', 'roles' => nil },
47
+ { 'name' => 'bar', 'roles' => [] },
48
+ { 'name' => 'baz', 'roles' => [ 'x', 'y', 'z' ] }
49
+ ]
50
+ }
51
+
52
+ @filter.filter(@data).should == {
53
+ 'domain' => [
54
+ { 'name' => 'foo' },
55
+ { 'name' => 'bar' },
56
+ { 'name' => 'baz', 'roles' => [ 'x', 'y', 'z' ] }
57
+ ]
58
+ }
59
+ end
60
+ end
@@ -0,0 +1,32 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'environment_scope_filter'))
4
+
5
+ describe 'filtering configuration data by adding environment scoping' do
6
+ before do
7
+ ENV['to'] = @env = 'foo:staging'
8
+
9
+ @config = WhiskeyDisk::Config.new
10
+ @filter = WhiskeyDisk::Config::EnvironmentScopeFilter.new(@config)
11
+
12
+ @bare_data = { 'repository' => 'git://foo/bar.git', 'domain' => [ { :name => 'ogc@ogtastic.com' } ] }
13
+ @env_data = { 'staging' => @bare_data }
14
+ @proj_data = { 'foo' => @env_data }
15
+ end
16
+
17
+ it 'fails if the configuration data is not a hash' do
18
+ lambda { @filter.filter([]) }.should.raise
19
+ end
20
+
21
+ it 'returns the original data if it has both project and environment scoping' do
22
+ @filter.filter(@proj_data).should == @proj_data
23
+ end
24
+
25
+ it 'returns the original data if it has environment scoping' do
26
+ @filter.filter(@env_data).should == @env_data
27
+ end
28
+
29
+ it 'returns the data wrapped in an environment scope if it has no environment scoping' do
30
+ @filter.filter(@bare_data).should == { 'staging' => @bare_data }
31
+ end
32
+ end
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'hashify_domain_entries_filter'))
4
+
5
+ describe 'setting empty domain entries to "local"' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::HashifyDomainEntriesFilter.new(@config)
9
+ end
10
+
11
+ it 'handles empty domain filtering among roles across all projects and targets' do
12
+ @data = {
13
+ 'domain' => [
14
+ 'x',
15
+ nil,
16
+ { 'name' => 'foo', 'roles' => ['x', 'y'] },
17
+ '',
18
+ 'local'
19
+ ]
20
+ }
21
+
22
+ @filter.filter(@data).should == {
23
+ 'domain' => [
24
+ { 'name' => 'x' },
25
+ { 'name' => nil },
26
+ { 'name' => 'foo', 'roles' => ['x', 'y'] },
27
+ { 'name' => '' },
28
+ { 'name' => 'local' }
29
+ ]
30
+ }
31
+ end
32
+
33
+ it 'handles the degenerate case of a single domain name' do
34
+ @data = { 'domain' => 'foo' }
35
+ @filter.filter(@data).should == { 'domain' => [ { 'name' => 'foo' } ] }
36
+ end
37
+
38
+ it 'handles the degenerate case of no domain specified' do
39
+ @filter.filter({}).should == { 'domain' => { 'name' => '' } }
40
+ end
41
+ end
@@ -0,0 +1,30 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'spec_helper.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config'))
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', '..', 'lib', 'whiskey_disk', 'config', 'filters', 'localize_domains_filter'))
4
+
5
+ describe 'setting empty domain entries to "local"' do
6
+ before do
7
+ @config = WhiskeyDisk::Config.new
8
+ @filter = WhiskeyDisk::Config::LocalizeDomainsFilter.new(@config)
9
+ end
10
+
11
+ it 'handles empty domain filtering among roles across all projects and targets' do
12
+ @data = {
13
+ 'domain' => [
14
+ { 'name' => nil },
15
+ { 'name' => '' },
16
+ { 'name' => 'local' },
17
+ { 'name' => 'x' }
18
+ ]
19
+ }
20
+
21
+ @filter.filter(@data).should == {
22
+ 'domain' => [
23
+ { 'name' => 'local' },
24
+ { 'name' => 'local' },
25
+ { 'name' => 'local' },
26
+ { 'name' => 'x' }
27
+ ]
28
+ }
29
+ end
30
+ end