spice 1.0.0.rc → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (109) hide show
  1. data/.gitignore +2 -0
  2. data/Gemfile +0 -14
  3. data/README.md +1 -1
  4. data/Rakefile +1 -1
  5. data/TODO.md +2 -1
  6. data/lib/spice.rb +47 -72
  7. data/lib/spice/authentication.rb +23 -45
  8. data/lib/spice/base.rb +104 -0
  9. data/lib/spice/client.rb +8 -48
  10. data/lib/spice/config.rb +37 -19
  11. data/lib/spice/connection.rb +33 -117
  12. data/lib/spice/connection/clients.rb +26 -6
  13. data/lib/spice/connection/cookbooks.rb +19 -14
  14. data/lib/spice/connection/data_bags.rb +31 -20
  15. data/lib/spice/connection/environments.rb +6 -7
  16. data/lib/spice/connection/nodes.rb +23 -6
  17. data/lib/spice/connection/roles.rb +5 -5
  18. data/lib/spice/connection/search.rb +12 -12
  19. data/lib/spice/cookbook.rb +3 -29
  20. data/lib/spice/cookbook_version.rb +9 -61
  21. data/lib/spice/core_ext/array.rb +7 -0
  22. data/lib/spice/core_ext/enumerable.rb +11 -0
  23. data/lib/spice/core_ext/hash.rb +49 -0
  24. data/lib/spice/core_ext/mash.rb +219 -0
  25. data/lib/spice/data_bag.rb +3 -37
  26. data/lib/spice/data_bag_item.rb +7 -47
  27. data/lib/spice/environment.rb +12 -27
  28. data/lib/spice/error.rb +22 -10
  29. data/lib/spice/identity_map.rb +8 -0
  30. data/lib/spice/node.rb +13 -34
  31. data/lib/spice/request.rb +73 -11
  32. data/lib/spice/response/parse_json.rb +8 -3
  33. data/lib/spice/role.rb +8 -33
  34. data/lib/spice/version.rb +1 -1
  35. data/spec/fixtures/client.pem +27 -0
  36. data/spec/fixtures/clients/create.json +4 -0
  37. data/spec/fixtures/clients/index.json +5 -0
  38. data/spec/fixtures/clients/reregister.json +5 -0
  39. data/spec/fixtures/clients/show.json +8 -0
  40. data/spec/fixtures/clients/update.json +5 -0
  41. data/spec/fixtures/cookbook_versions/show.json +108 -0
  42. data/spec/fixtures/cookbook_versions/update.json +62 -0
  43. data/spec/fixtures/cookbooks/index-0.10.json +28 -0
  44. data/spec/fixtures/cookbooks/index-0.9.json +4 -0
  45. data/spec/fixtures/cookbooks/show-0.10.json +15 -0
  46. data/spec/fixtures/cookbooks/show-apache2-0.9.json +5 -0
  47. data/spec/fixtures/cookbooks/show-unicorn-0.9.json +5 -0
  48. data/spec/fixtures/data_bag_items/create.json +1 -0
  49. data/spec/fixtures/data_bag_items/show.json +4 -0
  50. data/spec/fixtures/data_bag_items/update.json +4 -0
  51. data/spec/fixtures/data_bags/create.json +3 -0
  52. data/spec/fixtures/data_bags/index.json +3 -0
  53. data/spec/fixtures/data_bags/show.json +3 -0
  54. data/spec/fixtures/environments/cookbook.json +15 -0
  55. data/spec/fixtures/environments/cookbooks.json +28 -0
  56. data/spec/fixtures/environments/create.json +1 -0
  57. data/spec/fixtures/environments/delete.json +8 -0
  58. data/spec/fixtures/environments/index.json +3 -0
  59. data/spec/fixtures/environments/show.json +8 -0
  60. data/spec/fixtures/environments/update.json +8 -0
  61. data/spec/fixtures/nodes/cookbooks.json +41 -0
  62. data/spec/fixtures/nodes/create.json +1 -0
  63. data/spec/fixtures/nodes/delete.json +17 -0
  64. data/spec/fixtures/nodes/index.json +3 -0
  65. data/spec/fixtures/nodes/show.json +17 -0
  66. data/spec/fixtures/nodes/update.json +13 -0
  67. data/spec/fixtures/roles/create.json +1 -0
  68. data/spec/fixtures/roles/delete.json +11 -0
  69. data/spec/fixtures/roles/index.json +3 -0
  70. data/spec/fixtures/roles/show.json +12 -0
  71. data/spec/fixtures/roles/update.json +11 -0
  72. data/spec/fixtures/search/client.json +1 -0
  73. data/spec/fixtures/search/data_bag.json +1 -0
  74. data/spec/fixtures/search/environment.json +1 -0
  75. data/spec/fixtures/search/node.json +1 -0
  76. data/spec/fixtures/search/role.json +1 -0
  77. data/spec/spec_helper.rb +5 -4
  78. data/spec/spice/base_spec.rb +34 -0
  79. data/spec/spice/client_spec.rb +0 -61
  80. data/spec/spice/config_spec.rb +14 -0
  81. data/spec/spice/connection/clients_spec.rb +82 -0
  82. data/spec/spice/connection/cookbooks_spec.rb +86 -0
  83. data/spec/spice/connection/data_bags_spec.rb +126 -0
  84. data/spec/spice/connection_spec.rb +63 -0
  85. data/spec/spice/cookbook_spec.rb +0 -61
  86. data/spec/spice/data_bag_item_spec.rb +7 -0
  87. data/spec/spice/data_bag_spec.rb +0 -160
  88. data/spec/spice/environment_spec.rb +0 -89
  89. data/spec/spice/node_spec.rb +0 -74
  90. data/spec/spice/role_spec.rb +0 -61
  91. data/spec/spice_spec.rb +8 -116
  92. data/spec/support/helpers.rb +58 -0
  93. data/spice.gemspec +13 -15
  94. metadata +227 -87
  95. data/.watchr +0 -22
  96. data/lib/spice/connection/authentication.rb +0 -47
  97. data/lib/spice/mock.rb +0 -46
  98. data/lib/spice/persistence.rb +0 -62
  99. data/spec/spice/chef_spec.rb +0 -52
  100. data/spec/spice/search_spec.rb +0 -2
  101. data/spec/support/chef_requests.rb +0 -0
  102. data/spec/support/client_requests.rb +0 -95
  103. data/spec/support/cookbook_requests.rb +0 -95
  104. data/spec/support/data_bag_item_requests.rb +0 -138
  105. data/spec/support/data_bag_requests.rb +0 -95
  106. data/spec/support/environment_requests.rb +0 -221
  107. data/spec/support/node_requests.rb +0 -138
  108. data/spec/support/respond_with_matcher.rb +0 -53
  109. data/spec/support/role_requests.rb +0 -95
@@ -0,0 +1,4 @@
1
+ {
2
+ "uri": "http://localhost:4000/clients/monkeypants",
3
+ "private_key": "RSA PRIVATE KEY"
4
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "chef-webui": "http://localhost:4000/clients/chef-webui",
3
+ "chef-validator": "http://localhost:4000/clients/chef-validator",
4
+ "adam": "http://localhost:4000/clients/adam"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "monkeypants",
3
+ "private_key": "RSA PRIVATE KEY",
4
+ "admin": false
5
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "monkeypants",
3
+ "chef_type": "client",
4
+ "json_class": "Chef::ApiClient",
5
+ "public_key": "RSA PUBLIC KEY",
6
+ "_rev": "1-68532bf2122a54464db6ad65a24e2225",
7
+ "admin": true
8
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "name": "monkeypants",
3
+ "private_key": "RSA PRIVATE KEY",
4
+ "admin": false
5
+ }
@@ -0,0 +1,108 @@
1
+ {
2
+ "definitions": [
3
+ {
4
+ "name": "unicorn_config.rb",
5
+ "url": "https://s3.amazonaws.com/opscode-platform-production-data/organization-(...)",
6
+ "checksum": "c92b659171552e896074caa58dada0c2",
7
+ "path": "definitions/unicorn_config.rb",
8
+ "specificity": "default"
9
+ }
10
+ ],
11
+ "name": "unicorn-0.1.2",
12
+ "attributes": [
13
+
14
+ ],
15
+ "files": [
16
+
17
+ ],
18
+ "json_class": "Chef::CookbookVersion",
19
+ "providers": [
20
+
21
+ ],
22
+ "metadata": {
23
+ "dependencies": {
24
+ "ruby": [
25
+
26
+ ],
27
+ "rubygems": [
28
+
29
+ ]
30
+ },
31
+ "name": "unicorn",
32
+ "maintainer_email": "ops@opscode.com",
33
+ "attributes": {
34
+ },
35
+ "license": "Apache 2.0",
36
+ "suggestions": {
37
+ },
38
+ "platforms": {
39
+ },
40
+ "maintainer": "Opscode, Inc",
41
+ "long_description": "= LICENSE AND AUTHOR:\n\nAuthor:: Adam Jacob <adam@opscode.com>\n\nCopyright 2009-2010, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (...)",
42
+ "recommendations": {
43
+ },
44
+ "version": "0.1.2",
45
+ "conflicting": {
46
+ },
47
+ "recipes": {
48
+ "unicorn": "Installs unicorn rubygem"
49
+ },
50
+ "groupings": {
51
+ },
52
+ "replacing": {
53
+ },
54
+ "description": "Installs/Configures unicorn",
55
+ "providing": {
56
+ }
57
+ },
58
+ "libraries": [
59
+
60
+ ],
61
+ "templates": [
62
+ {
63
+ "name": "unicorn.rb.erb",
64
+ "url": "https://s3.amazonaws.com/opscode-platform-production-data/organization-(...)",
65
+ "checksum": "36a1cc1b225708db96d48026c3f624b2",
66
+ "path": "templates/default/unicorn.rb.erb",
67
+ "specificity": "default"
68
+ }
69
+ ],
70
+ "resources": [
71
+
72
+ ],
73
+ "cookbook_name": "unicorn",
74
+ "version": "0.1.2",
75
+ "recipes": [
76
+ {
77
+ "name": "default.rb",
78
+ "url": "https://s3.amazonaws.com/opscode-platform-production-data/organization-(...)",
79
+ "checksum": "ba0dadcbca26710a521e0e3160cc5e20",
80
+ "path": "recipes/default.rb",
81
+ "specificity": "default"
82
+ }
83
+ ],
84
+ "root_files": [
85
+ {
86
+ "name": "README.rdoc",
87
+ "url": "https://s3.amazonaws.com/opscode-platform-production-data/organization-(...)",
88
+ "checksum": "d18c630c8a68ffa4852d13214d0525a6",
89
+ "path": "README.rdoc",
90
+ "specificity": "default"
91
+ },
92
+ {
93
+ "name": "metadata.rb",
94
+ "url": "https://s3.amazonaws.com/opscode-platform-production-data/organization-(...)",
95
+ "checksum": "967087a09f48f234028d3aa27a094882",
96
+ "path": "metadata.rb",
97
+ "specificity": "default"
98
+ },
99
+ {
100
+ "name": "metadata.json",
101
+ "url": "https://s3.amazonaws.com/opscode-platform-production-data/organization-(...)",
102
+ "checksum": "45b27c78955f6a738d2d42d88056c57c",
103
+ "path": "metadata.json",
104
+ "specificity": "default"
105
+ }
106
+ ],
107
+ "chef_type": "cookbook_version"
108
+ }
@@ -0,0 +1,62 @@
1
+ { "attributes" : [ ],
2
+ "chef_type" : "cookbook_version",
3
+ "cookbook_name" : "unicorn",
4
+ "definitions" : [ { "checksum" : "c92b659171552e896074caa58dada0c2",
5
+ "name" : "unicorn_config.rb",
6
+ "path" : "definitions/unicorn_config.rb",
7
+ "specificity" : "default"
8
+ } ],
9
+ "files" : [ ],
10
+ "json_class" : "Chef::CookbookVersion",
11
+ "libraries" : [ ],
12
+ "metadata" : { "attributes" : { },
13
+ "conflicting" : { },
14
+ "dependencies" : { "ruby" : [ ],
15
+ "rubygems" : [ ]
16
+ },
17
+ "description" : "Installs/Configures unicorn",
18
+ "groupings" : { },
19
+ "license" : "Apache 2.0",
20
+ "long_description" : "= LICENSE AND AUTHOR:\n\nAuthor:: Adam Jacob <adam@opscode.com>\n\nCopyright 2009-2010, Opscode, Inc.\n\nLicensed under the Apache License, Version 2.0 (...)",
21
+ "maintainer" : "Opscode, Inc",
22
+ "maintainer_email" : "ops@opscode.com",
23
+ "name" : "unicorn",
24
+ "platforms" : { },
25
+ "providing" : { },
26
+ "recipes" : { "unicorn" : "Installs unicorn rubygem" },
27
+ "recommendations" : { },
28
+ "replacing" : { },
29
+ "suggestions" : { },
30
+ "version" : "0.1.2"
31
+ },
32
+ "name" : "unicorn-0.1.2",
33
+ "providers" : [ ],
34
+ "recipes" : [ { "checksum" : "ba0dadcbca26710a521e0e3160cc5e20",
35
+ "name" : "default.rb",
36
+ "path" : "recipes/default.rb",
37
+ "specificity" : "default"
38
+ } ],
39
+ "resources" : [ ],
40
+ "root_files" : [ { "checksum" : "d18c630c8a68ffa4852d13214d0525a6",
41
+ "name" : "README.rdoc",
42
+ "path" : "README.rdoc",
43
+ "specificity" : "default"
44
+ },
45
+ { "checksum" : "967087a09f48f234028d3aa27a094882",
46
+ "name" : "metadata.rb",
47
+ "path" : "metadata.rb",
48
+ "specificity" : "default"
49
+ },
50
+ { "checksum" : "45b27c78955f6a738d2d42d88056c57c",
51
+ "name" : "metadata.json",
52
+ "path" : "metadata.json",
53
+ "specificity" : "default"
54
+ }
55
+ ],
56
+ "templates" : [ { "checksum" : "36a1cc1b225708db96d48026c3f624b2",
57
+ "name" : "unicorn.rb.erb",
58
+ "path" : "templates/default/unicorn.rb.erb",
59
+ "specificity" : "default"
60
+ } ],
61
+ "version" : "0.1.2"
62
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "apache2": {
3
+ "url": "http://localhost:4000/cookbooks/apache2",
4
+ "versions": [
5
+ {
6
+ "url": "http://localhost:4000/cookbooks/apache2/5.1.0",
7
+ "version": "5.1.0"
8
+ },
9
+ {
10
+ "url": "http://localhost:4000/cookbooks/apache2/4.2.0",
11
+ "version": "4.2.0"
12
+ }
13
+ ]
14
+ },
15
+ "nginx": {
16
+ "url": "http://localhost:4000/cookbooks/nginx",
17
+ "versions": [
18
+ {
19
+ "url": "http://localhost:4000/cookbooks/nginx/1.0.0",
20
+ "version": "1.0.0"
21
+ },
22
+ {
23
+ "url": "http://localhost:4000/cookbooks/nginx/0.3.0",
24
+ "version": "0.3.0"
25
+ }
26
+ ]
27
+ }
28
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "unicorn": "http://localhost:4000/cookbooks/unicorn",
3
+ "apache2": "http://localhost:4000/cookbooks/apache2"
4
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "apache2": {
3
+ "url": "http://localhost:4000/cookbooks/apache2",
4
+ "versions": [
5
+ {
6
+ "url": "http://localhost:4000/cookbooks/apache2/5.1.0",
7
+ "version": "5.1.0"
8
+ },
9
+ {
10
+ "url": "http://localhost:4000/cookbooks/apache2/4.2.0",
11
+ "version": "4.2.0"
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "apache": [
3
+ "1.3.0"
4
+ ]
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "unicorn": [
3
+ "0.1.2"
4
+ ]
5
+ }
@@ -0,0 +1 @@
1
+ {"chef_type":"data_bag_item", "id":"adam", "real_name":"Adam Jacob", "data_bag":"users"}
@@ -0,0 +1,4 @@
1
+ {
2
+ "real_name": "Adam Jacob",
3
+ "id": "adam"
4
+ }
@@ -0,0 +1,4 @@
1
+ {
2
+ "real_name": "Adam Brent Jacob",
3
+ "id": "adam"
4
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "uri": "http://localhost:4000/data/users"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "users": "http://localhost:4000/data/users"
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "adam": "http://localhost:4000/data/users/adam"
3
+ }
@@ -0,0 +1,15 @@
1
+ {
2
+ "apache2": {
3
+ "url": "http://localhost:4000/cookbooks/apache2",
4
+ "versions": [
5
+ {
6
+ "url": "http://localhost:4000/cookbooks/apache2/5.1.0",
7
+ "version": "5.1.0"
8
+ },
9
+ {
10
+ "url": "http://localhost:4000/cookbooks/apache2/4.2.0",
11
+ "version": "4.2.0"
12
+ }
13
+ ]
14
+ }
15
+ }
@@ -0,0 +1,28 @@
1
+ {
2
+ "apache2": {
3
+ "url": "http://localhost:4000/cookbooks/apache2",
4
+ "versions": [
5
+ {
6
+ "url": "http://localhost:4000/cookbooks/apache2/5.1.0",
7
+ "version": "5.1.0"
8
+ },
9
+ {
10
+ "url": "http://localhost:4000/cookbooks/apache2/4.2.0",
11
+ "version": "4.2.0"
12
+ }
13
+ ]
14
+ },
15
+ "nginx": {
16
+ "url": "http://localhost:4000/cookbooks/nginx",
17
+ "versions": [
18
+ {
19
+ "url": "http://localhost:4000/cookbooks/nginx/1.0.0",
20
+ "version": "1.0.0"
21
+ },
22
+ {
23
+ "url": "http://localhost:4000/cookbooks/nginx/0.3.0",
24
+ "version": "0.3.0"
25
+ }
26
+ ]
27
+ }
28
+ }
@@ -0,0 +1 @@
1
+ { "uri": "http://localhost:4000/environments/dev" }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "dev",
3
+ "attributes": {},
4
+ "json_class": "Chef::Environment",
5
+ "description": "The Dev Environment",
6
+ "cookbook_versions": {},
7
+ "chef_type": "environment"
8
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "webserver": "http://localhost:4000/environments/webserver"
3
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "dev",
3
+ "attributes": {},
4
+ "json_class": "Chef::Environment",
5
+ "description": "",
6
+ "cookbook_versions": {},
7
+ "chef_type": "environment"
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "dev",
3
+ "attributes": {},
4
+ "json_class": "Chef::Environment",
5
+ "description": "The Dev Environment",
6
+ "cookbook_versions": {},
7
+ "chef_type": "environment"
8
+ }
@@ -0,0 +1,41 @@
1
+ {
2
+ "unicorn": {
3
+ "definitions": [
4
+ {
5
+ "name": "unicorn_config.rb",
6
+ "uri": "http://localhost:4000/cookbooks/unicorn/definitions?id=unicorn_config.rb",
7
+ "checksum": "72074229598611d7a6cdcc8176ffb76748adb4127be3a9651c89bb0afab6498f"
8
+ }
9
+ ],
10
+ "files": [
11
+
12
+ ],
13
+ "providers": [
14
+
15
+ ],
16
+ "templates": [
17
+ {
18
+ "name": "unicorn.rb.erb",
19
+ "uri": "http://localhost:4000/cookbooks/unicorn/templates?id=unicorn.rb.erb",
20
+ "checksum": "c1df9c8ec2bda7b14ecadc1c5a56802442cd8d7503f2524d4fa3f73dba1a1250",
21
+ "specificity": "default"
22
+ }
23
+ ],
24
+ "libraries": [
25
+
26
+ ],
27
+ "resources": [
28
+
29
+ ],
30
+ "attributes": [
31
+
32
+ ],
33
+ "recipes": [
34
+ {
35
+ "name": "default.rb",
36
+ "uri": "http://localhost:4000/cookbooks/unicorn/recipes?id=default.rb",
37
+ "checksum": "87a3f720bf5bbd9227228ba22946436db6598a59f8aedff37515ebd4e1157644"
38
+ }
39
+ ]
40
+ }
41
+ }
@@ -0,0 +1 @@
1
+ { "uri": "http://localhost:4000/nodes/latte" }
@@ -0,0 +1,17 @@
1
+ {
2
+ "overrides": {
3
+
4
+ },
5
+ "name": "latte",
6
+ "chef_type": "node",
7
+ "json_class": "Chef::Node",
8
+ "attributes": {
9
+ "hardware_type": "laptop"
10
+ },
11
+ "run_list": [
12
+ "recipe[apache2]"
13
+ ],
14
+ "defaults": {
15
+
16
+ }
17
+ }