berkshelf 2.0.0.beta → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (92) hide show
  1. data/CHANGELOG.md +19 -1
  2. data/CONTRIBUTING.md +1 -3
  3. data/Gemfile +0 -20
  4. data/Guardfile +3 -3
  5. data/LICENSE +6 -5
  6. data/README.md +1 -0
  7. data/Thorfile +48 -67
  8. data/berkshelf.gemspec +48 -37
  9. data/features/apply_command.feature +17 -11
  10. data/features/config.feature +11 -11
  11. data/features/configure_command.feature +8 -8
  12. data/features/contingent_command.feature +37 -8
  13. data/features/cookbook_command.feature +17 -14
  14. data/features/groups_install.feature +24 -20
  15. data/features/install_command.feature +24 -33
  16. data/features/licenses.feature +112 -0
  17. data/features/list_command.feature +17 -5
  18. data/features/lockfile.feature +307 -188
  19. data/features/outdated_command.feature +1 -4
  20. data/features/package_command.feature +41 -19
  21. data/features/shelf/list.feature +39 -0
  22. data/features/shelf/show.feature +152 -0
  23. data/features/shelf/uninstall.feature +103 -0
  24. data/features/show_command.feature +49 -17
  25. data/features/step_definitions/filesystem_steps.rb +12 -3
  26. data/features/step_definitions/utility_steps.rb +0 -1
  27. data/features/support/env.rb +11 -4
  28. data/features/update_command.feature +22 -10
  29. data/features/upload_command.feature +174 -127
  30. data/features/vendor_install.feature +6 -6
  31. data/generator_files/Berksfile.erb +1 -1
  32. data/generator_files/metadata.rb.erb +7 -7
  33. data/lib/berkshelf.rb +39 -27
  34. data/lib/berkshelf/base_generator.rb +2 -3
  35. data/lib/berkshelf/berksfile.rb +69 -17
  36. data/lib/berkshelf/cached_cookbook.rb +17 -1
  37. data/lib/berkshelf/chef.rb +2 -4
  38. data/lib/berkshelf/chef/config.rb +51 -75
  39. data/lib/berkshelf/chef/cookbook.rb +1 -2
  40. data/lib/berkshelf/chef/cookbook/chefignore.rb +1 -1
  41. data/lib/berkshelf/cli.rb +144 -194
  42. data/lib/berkshelf/command.rb +11 -12
  43. data/lib/berkshelf/commands/shelf.rb +130 -0
  44. data/lib/berkshelf/commands/test_command.rb +11 -0
  45. data/lib/berkshelf/community_rest.rb +1 -2
  46. data/lib/berkshelf/config.rb +14 -10
  47. data/lib/berkshelf/cookbook_generator.rb +30 -24
  48. data/lib/berkshelf/cookbook_source.rb +1 -1
  49. data/lib/berkshelf/cookbook_store.rb +0 -1
  50. data/lib/berkshelf/core_ext.rb +1 -1
  51. data/lib/berkshelf/core_ext/file.rb +1 -1
  52. data/lib/berkshelf/downloader.rb +3 -1
  53. data/lib/berkshelf/errors.rb +128 -53
  54. data/lib/berkshelf/formatters.rb +2 -6
  55. data/lib/berkshelf/formatters/human_readable.rb +8 -2
  56. data/lib/berkshelf/formatters/json.rb +7 -1
  57. data/lib/berkshelf/formatters/null.rb +0 -1
  58. data/lib/berkshelf/git.rb +16 -16
  59. data/lib/berkshelf/init_generator.rb +28 -26
  60. data/lib/berkshelf/location.rb +12 -11
  61. data/lib/berkshelf/locations/chef_api_location.rb +2 -2
  62. data/lib/berkshelf/locations/git_location.rb +0 -1
  63. data/lib/berkshelf/locations/github_location.rb +0 -1
  64. data/lib/berkshelf/locations/path_location.rb +1 -2
  65. data/lib/berkshelf/locations/site_location.rb +3 -2
  66. data/lib/berkshelf/lockfile.rb +29 -10
  67. data/lib/berkshelf/mixin/config.rb +155 -0
  68. data/lib/berkshelf/mixin/logging.rb +0 -1
  69. data/lib/berkshelf/mixin/shellout.rb +71 -0
  70. data/lib/berkshelf/resolver.rb +7 -4
  71. data/lib/berkshelf/test.rb +1 -3
  72. data/lib/berkshelf/ui.rb +8 -4
  73. data/lib/berkshelf/version.rb +1 -1
  74. data/lib/thor/monkies/shell.rb +0 -1
  75. data/spec/config/berkshelf.pem +27 -0
  76. data/spec/config/knife.rb +12 -0
  77. data/spec/config/validator.pem +27 -0
  78. data/spec/spec_helper.rb +4 -8
  79. data/spec/support/chef_api.rb +14 -9
  80. data/spec/support/chef_server.rb +3 -4
  81. data/spec/unit/berkshelf/berksfile_spec.rb +1 -1
  82. data/spec/unit/berkshelf/cookbook_generator_spec.rb +12 -6
  83. data/spec/unit/berkshelf/cookbook_source_spec.rb +13 -1
  84. data/spec/unit/berkshelf/init_generator_spec.rb +5 -0
  85. data/spec/unit/chef/config_spec.rb +9 -10
  86. metadata +216 -93
  87. data/features/info_command.feature +0 -39
  88. data/features/open_command.feature +0 -36
  89. data/lib/berkshelf/cli_commands/test_command.rb +0 -11
  90. data/lib/berkshelf/mixin.rb +0 -10
  91. data/lib/berkshelf/mixin/path_helpers.rb +0 -30
  92. data/spec/support/knife.rb +0 -18
@@ -1,4 +1,4 @@
1
- Feature: outdated command
1
+ Feature: Displaying outdated cookbooks
2
2
  As a user
3
3
  I want to know what cookbooks are outdated before I run update
4
4
  So that I can decide whether to update everything at once
@@ -7,7 +7,6 @@ Feature: outdated command
7
7
  Given I write to "Berksfile" with:
8
8
  """
9
9
  site :opscode
10
-
11
10
  cookbook 'berkshelf-cookbook-fixture'
12
11
  """
13
12
  When I successfully run `berks outdated`
@@ -24,7 +23,6 @@ Feature: outdated command
24
23
  Given I write to "Berksfile" with:
25
24
  """
26
25
  site :opscode
27
-
28
26
  cookbook 'berkshelf-cookbook-fixture', '>= 0.1'
29
27
  """
30
28
  When I run `berks outdated`
@@ -41,7 +39,6 @@ Feature: outdated command
41
39
  Given I write to "Berksfile" with:
42
40
  """
43
41
  site :opscode
44
-
45
42
  cookbook 'berkshelf-cookbook-fixture', '~> 0.1'
46
43
  """
47
44
  When I run `berks outdated`
@@ -1,39 +1,61 @@
1
- Feature: package command
1
+ Feature: Packaging a cookbook as a tarball for distribution
2
2
  As a user
3
3
  I want to be able to package a cookbook
4
4
  So that I can use it outside of Berkshelf
5
5
 
6
- Scenario: Running the package command
7
- Given I write to "Berksfile" with:
6
+ Scenario: When no options are passed
7
+ Given the cookbook store has the cookbooks:
8
+ | fake | 1.0.0 |
9
+ And I write to "Berksfile" with:
8
10
  """
9
11
  site :opscode
10
- cookbook 'berkshelf-cookbook-fixture', '~> 1.0.0'
12
+ cookbook 'fake', '~> 1.0.0'
13
+ """
14
+ When I successfully run `berks package fake`
15
+ Then a file named "fake.tar.gz" should exist
16
+ And the output should contain:
17
+ """
18
+ Cookbook(s) packaged to
11
19
  """
12
- And I successfully run `berks install`
13
- When I successfully run `berks package berkshelf-cookbook-fixture`
14
- Then a file named "berkshelf-cookbook-fixture.tar.gz" should exist
15
- And the output should contain "Cookbook 'berkshelf-cookbook-fixture' saved to "
16
20
  And the exit status should be 0
17
21
 
18
- Scenario: Running the package command with the --output option
19
- Given I write to "Berksfile" with:
22
+ Scenario: With the --output option
23
+ Given the cookbook store has the cookbooks:
24
+ | fake | 1.0.0 |
25
+ And I write to "Berksfile" with:
20
26
  """
21
27
  site :opscode
22
- cookbook 'berkshelf-cookbook-fixture', '~> 1.0.0'
28
+ cookbook 'fake', '~> 1.0.0'
23
29
  """
24
- And I successfully run `berks install`
25
- When I successfully run `berks package berkshelf-cookbook-fixture --output foo/bar`
26
- Then a file named "foo/bar/berkshelf-cookbook-fixture.tar.gz" should exist
30
+ When I successfully run `berks package fake --output foo/bar`
31
+ Then a file named "foo/bar/fake.tar.gz" should exist
27
32
  And the exit status should be 0
28
33
 
29
- Scenario: Running the package command with an installed cookbook name
30
- Given I write to "Berksfile" with:
34
+ Scenario: With an installed cookbook name
35
+ Given the cookbook store has the cookbooks:
36
+ | fake | 1.0.0 |
37
+ And I write to "Berksfile" with:
31
38
  """
32
39
  site :opscode
33
- cookbook 'berkshelf-cookbook-fixture', '~> 1.0.0'
40
+ cookbook 'fake', '~> 1.0.0'
34
41
  """
35
- And I successfully run `berks install`
36
42
  When I run `berks package non-existent`
37
43
  Then a file named "non-existent.tar.gz" should not exist
38
- And the output should contain "Cookbook 'non-existent' is not in your Berksfile"
44
+ And the output should contain:
45
+ """
46
+ Cookbook 'non-existent' is not in your Berksfile
47
+ """
39
48
  And the CLI should exit with the status code for error "CookbookNotFound"
49
+
50
+ Scenario: With an invalid cookbook
51
+ Given a cookbook named "cookbook with spaces"
52
+ And I write to "Berksfile" with:
53
+ """
54
+ cookbook 'cookbook with spaces', path: './cookbook with spaces'
55
+ """
56
+ When I run `berks package`
57
+ Then the output should contain:
58
+ """
59
+ The cookbook 'cookbook with spaces' has invalid filenames:
60
+ """
61
+ And the CLI should exit with the status code for error "InvalidCookbookFiles"
@@ -0,0 +1,39 @@
1
+ Feature: Listing all cookbooks in the Berkshelf shelf
2
+ As a user with a cookbook store
3
+ I want to show all the cookbooks I have installed
4
+ So that I can be well informed
5
+
6
+ Scenario: With no cookbooks in the store
7
+ When I successfully run `berks shelf list`
8
+ Then the output should contain:
9
+ """
10
+ There are no cookbooks in the Berkshelf shelf
11
+ """
12
+ And the exit status should be 0
13
+
14
+ Scenario: With two cookbooks in the store
15
+ Given the cookbook store has the cookbooks:
16
+ | fake | 1.0.0 |
17
+ | ekaf | 2.3.4 |
18
+ When I successfully run `berks shelf list`
19
+ Then the output should contain:
20
+ """
21
+ Cookbooks in the Berkshelf shelf:
22
+ * ekaf (2.3.4)
23
+ * fake (1.0.0)
24
+ """
25
+ And the exit status should be 0
26
+
27
+ Scenario: With multiple cookbook versions installed
28
+ Given the cookbook store has the cookbooks:
29
+ | fake | 1.0.0 |
30
+ | fake | 1.1.0 |
31
+ | fake | 1.2.0 |
32
+ | fake | 2.0.0 |
33
+ When I successfully run `berks shelf list`
34
+ Then the output should contain:
35
+ """
36
+ Cookbooks in the Berkshelf shelf:
37
+ * fake (1.0.0, 1.1.0, 1.2.0, 2.0.0)
38
+ """
39
+ And the exit status should be 0
@@ -0,0 +1,152 @@
1
+ Feature: Displaying information about a cookbook in the Berkshelf shelf
2
+ As a user with a cookbook store
3
+ I want to show information about a specific cookbook in my cookbook store
4
+ So that I can be well informed
5
+
6
+ Scenario: With a cookbook that is not in the store
7
+ When I run `berks shelf show fake`
8
+ Then the output should contain:
9
+ """
10
+ Cookbook 'fake' is not in the Berkshelf shelf
11
+ """
12
+ And the CLI should exit with the status code for error "CookbookNotFound"
13
+
14
+ Scenario: With cookbooks in the store
15
+ Given the cookbook store has the cookbooks:
16
+ | fake | 1.0.0 |
17
+ | ekaf | 2.3.4 |
18
+ When I successfully run `berks shelf show fake`
19
+ Then the output should contain:
20
+ """
21
+ Displaying all versions of 'fake' in the Berkshelf shelf:
22
+ Name: fake
23
+ Version: 1.0.0
24
+ Description: A fabulous new cookbook
25
+ Author: YOUR_COMPANY_NAME
26
+ Email: YOUR_EMAIL
27
+ License: none
28
+ """
29
+ And the output should not contain:
30
+ """
31
+ Name: ekaf
32
+ """
33
+ And the exit status should be 0
34
+
35
+
36
+ Scenario: With cookbooks in the store and the --version option
37
+ Given the cookbook store has the cookbooks:
38
+ | fake | 1.0.0 |
39
+ | ekaf | 2.3.4 |
40
+ When I successfully run `berks shelf show fake --version 1.0.0`
41
+ Then the output should contain:
42
+ """
43
+ Displaying 'fake' (1.0.0) in the Berkshelf shelf:
44
+ Name: fake
45
+ Version: 1.0.0
46
+ Description: A fabulous new cookbook
47
+ Author: YOUR_COMPANY_NAME
48
+ Email: YOUR_EMAIL
49
+ License: none
50
+ """
51
+ And the output should not contain:
52
+ """
53
+ Name: ekaf
54
+ """
55
+ And the exit status should be 0
56
+
57
+ Scenario: With cookbooks in the store and the --version option doesn't exist
58
+ Given the cookbook store has the cookbooks:
59
+ | fake | 1.0.0 |
60
+ | ekaf | 2.3.4 |
61
+ When I run `berks shelf show fake --version 1.2.3`
62
+ Then the output should contain:
63
+ """
64
+ Cookbook 'fake' (1.2.3) is not in the Berkshelf shelf
65
+ """
66
+ And the CLI should exit with the status code for error "CookbookNotFound"
67
+
68
+ Scenario: With multiple cookbook versions installed
69
+ Given the cookbook store has the cookbooks:
70
+ | fake | 1.0.0 |
71
+ | fake | 1.1.0 |
72
+ | fake | 1.2.0 |
73
+ | fake | 2.0.0 |
74
+ When I successfully run `berks shelf show fake`
75
+ Then the output should contain:
76
+ """
77
+ Displaying all versions of 'fake' in the Berkshelf shelf:
78
+ Name: fake
79
+ Version: 1.0.0
80
+ Description: A fabulous new cookbook
81
+ Author: YOUR_COMPANY_NAME
82
+ Email: YOUR_EMAIL
83
+ License: none
84
+
85
+ Name: fake
86
+ Version: 1.1.0
87
+ Description: A fabulous new cookbook
88
+ Author: YOUR_COMPANY_NAME
89
+ Email: YOUR_EMAIL
90
+ License: none
91
+
92
+ Name: fake
93
+ Version: 1.2.0
94
+ Description: A fabulous new cookbook
95
+ Author: YOUR_COMPANY_NAME
96
+ Email: YOUR_EMAIL
97
+ License: none
98
+
99
+ Name: fake
100
+ Version: 2.0.0
101
+ Description: A fabulous new cookbook
102
+ Author: YOUR_COMPANY_NAME
103
+ Email: YOUR_EMAIL
104
+ License: none
105
+ """
106
+ And the exit status should be 0
107
+
108
+ Scenario: With multiple cookbook versions installed and the --version flag
109
+ Given the cookbook store has the cookbooks:
110
+ | fake | 1.0.0 |
111
+ | fake | 1.1.0 |
112
+ | fake | 1.2.0 |
113
+ | fake | 2.0.0 |
114
+ When I successfully run `berks shelf show fake --version 1.0.0`
115
+ Then the output should contain:
116
+ """
117
+ Displaying 'fake' (1.0.0) in the Berkshelf shelf:
118
+ Name: fake
119
+ Version: 1.0.0
120
+ Description: A fabulous new cookbook
121
+ Author: YOUR_COMPANY_NAME
122
+ Email: YOUR_EMAIL
123
+ License: none
124
+ """
125
+ And the output should not contain:
126
+ """
127
+ Name: fake
128
+ Version: 1.1.0
129
+ Description: A fabulous new cookbook
130
+ Author: YOUR_COMPANY_NAME
131
+ Email: YOUR_EMAIL
132
+ License: none
133
+ """
134
+ And the output should not contain:
135
+ """
136
+ Name: fake
137
+ Version: 1.2.0
138
+ Description: A fabulous new cookbook
139
+ Author: YOUR_COMPANY_NAME
140
+ Email: YOUR_EMAIL
141
+ License: none
142
+ """
143
+ And the output should not contain:
144
+ """
145
+ Name: fake
146
+ Version: 2.0.0
147
+ Description: A fabulous new cookbook
148
+ Author: YOUR_COMPANY_NAME
149
+ Email: YOUR_EMAIL
150
+ License: none
151
+ """
152
+ And the exit status should be 0
@@ -0,0 +1,103 @@
1
+ Feature: Removing a cookbook from the Berkshelf shelf
2
+ As a user with a cookbook store
3
+ I want to remove a cookbook because it's a bad version
4
+ So that I don't have to manually touch things in the ~/.berkshelf directory
5
+
6
+ Scenario: With no cookbooks in the store
7
+ When I run `berks shelf uninstall fake`
8
+ Then the output should contain:
9
+ """
10
+ Cookbook 'fake' is not in the Berkshelf shelf
11
+ """
12
+ And the CLI should exit with the status code for error "CookbookNotFound"
13
+
14
+ Scenario: With two cookbooks in the store
15
+ Given the cookbook store has the cookbooks:
16
+ | fake | 1.0.0 |
17
+ | ekaf | 2.3.4 |
18
+ When I successfully run `berks shelf uninstall fake`
19
+ Then the output should contain:
20
+ """
21
+ Successfully uninstalled fake (1.0.0)
22
+ """
23
+ And the cookbook store should not have the cookbooks:
24
+ | fake | 1.0.0 |
25
+ And the cookbook store should have the cookbooks:
26
+ | ekaf | 2.3.4 |
27
+ And the exit status should be 0
28
+
29
+
30
+ Scenario: With multiple cookbook versions installed
31
+ Given the cookbook store has the cookbooks:
32
+ | fake | 1.0.0 |
33
+ | fake | 1.1.0 |
34
+ | fake | 1.2.0 |
35
+ | fake | 2.0.0 |
36
+ When I successfully run `berks shelf uninstall fake`
37
+ Then the output should contain:
38
+ """
39
+ Successfully uninstalled fake (1.0.0)
40
+ Successfully uninstalled fake (1.1.0)
41
+ Successfully uninstalled fake (1.2.0)
42
+ Successfully uninstalled fake (2.0.0)
43
+ """
44
+ And the cookbook store should not have the cookbooks:
45
+ | fake | 1.0.0 |
46
+ | fake | 1.1.0 |
47
+ | fake | 1.2.0 |
48
+ | fake | 2.0.0 |
49
+ And the exit status should be 0
50
+
51
+ Scenario: When specifying a version
52
+ Given the cookbook store has the cookbooks:
53
+ | fake | 1.0.0 |
54
+ | fake | 1.1.0 |
55
+ | fake | 1.2.0 |
56
+ | fake | 2.0.0 |
57
+ When I successfully run `berks shelf uninstall fake --version 1.0.0`
58
+ Then the output should contain:
59
+ """
60
+ Successfully uninstalled fake (1.0.0)
61
+ """
62
+ And the cookbook store should not have the cookbooks:
63
+ | fake | 1.0.0 |
64
+ And the cookbook store should have the cookbooks:
65
+ | fake | 1.1.0 |
66
+ | fake | 1.2.0 |
67
+ | fake | 2.0.0 |
68
+ And the exit status should be 0
69
+
70
+ Scenario: With contingencies
71
+ Given the cookbook store contains a cookbook "fake" "1.0.0" with dependencies:
72
+ | ekaf | 2.3.4 |
73
+ And the cookbook store has the cookbooks:
74
+ | ekaf | 2.3.4 |
75
+ When I run `berks shelf uninstall ekaf` interactively
76
+ And I type "yes"
77
+ Then the output should contain:
78
+ """
79
+ [fake (1.0.0)] depend on ekaf.
80
+
81
+ Are you sure you want to continue? (y/N)
82
+ """
83
+ And the output should contain:
84
+ """
85
+ Successfully uninstalled ekaf (2.3.4)
86
+ """
87
+ And the cookbook store should not have the cookbooks:
88
+ | ekaf | 2.3.4 |
89
+ And the exit status should be 0
90
+
91
+ Scenario: With contingencies and the --force flag
92
+ Given the cookbook store contains a cookbook "fake" "1.0.0" with dependencies:
93
+ | ekaf | 2.3.4 |
94
+ And the cookbook store has the cookbooks:
95
+ | ekaf | 2.3.4 |
96
+ When I run `berks shelf uninstall ekaf --force`
97
+ Then the output should contain:
98
+ """
99
+ Successfully uninstalled ekaf (2.3.4)
100
+ """
101
+ And the cookbook store should not have the cookbooks:
102
+ | ekaf | 2.3.4 |
103
+ And the exit status should be 0
@@ -1,26 +1,58 @@
1
- Feature: show command
2
- As a user with a Berksfile
3
- I want a way to show the path to a cookbooks on my local file system
4
- So that I can view the source and debug
1
+ Feature: Displaying information about a cookbook defined by a Berksfile
2
+ As a user
3
+ I want to be able to view the metadata information of a cached cookbook
4
+ So that I can troubleshoot bugs or satisfy my own curiosity
5
5
 
6
- Scenario: Running the show command with an installed cookbook name
6
+ Scenario: With no options
7
7
  Given the cookbook store has the cookbooks:
8
- | berkshelf-cookbook-fixture | 1.0.0 |
8
+ | fake | 1.0.0 |
9
9
  And I write to "Berksfile" with:
10
10
  """
11
- site :opscode
12
- cookbook 'berkshelf-cookbook-fixture', '1.0.0'
11
+ cookbook 'fake', '1.0.0'
12
+ """
13
+ When I successfully run `berks show fake`
14
+ Then the output should contain:
15
+ """
16
+ Name: fake
17
+ Version: 1.0.0
18
+ Description: A fabulous new cookbook
19
+ Author: YOUR_COMPANY_NAME
20
+ Email: YOUR_EMAIL
21
+ License: none
13
22
  """
14
- When I successfully run `berks show berkshelf-cookbook-fixture`
15
- Then the output should contain "berkshelf/tmp/berkshelf/cookbooks/berkshelf-cookbook-fixture-1.0.0"
16
- And the exit status should be 0
17
23
 
18
- Scenario: Running the show command with a not installed cookbook name
19
- Given I write to "Berksfile" with:
24
+ Scenario: When JSON is requested
25
+ Given the cookbook store has the cookbooks:
26
+ | fake | 1.0.0 |
27
+ And I write to "Berksfile" with:
28
+ """
29
+ cookbook 'fake', '1.0.0'
20
30
  """
21
- site :opscode
22
- cookbook 'berkshelf-cookbook-fixture', '1.0.0'
31
+ When I successfully run `berks show fake --format json`
32
+ Then the output should contain:
23
33
  """
24
- When I run `berks show build-essential`
25
- Then the output should contain "Cookbook 'build-essential' was not installed by your Berksfile"
34
+ {
35
+ "cookbooks": [
36
+ {
37
+ "name": "fake",
38
+ "version": "1.0.0",
39
+ "description": "A fabulous new cookbook",
40
+ "author": "YOUR_COMPANY_NAME",
41
+ "email": "YOUR_EMAIL",
42
+ "license": "none"
43
+ }
44
+ ],
45
+ "errors": [
46
+
47
+ ],
48
+ "messages": [
49
+
50
+ ]
51
+ }
52
+ """
53
+
54
+ Scenario: When the cookbook is not in the Berksfile
55
+ Given an empty file named "Berksfile"
56
+ When I run `berks show fake`
57
+ Then the output should contain "Cookbook 'fake' is not installed by your Berksfile"
26
58
  And the CLI should exit with the status code for error "CookbookNotFound"