berkshelf 0.6.0.beta4 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/berkshelf.gemspec +1 -1
- data/features/config.feature +10 -10
- data/features/configure_command.feature +60 -0
- data/features/install.feature +6 -6
- data/features/step_definitions/cli_steps.rb +2 -2
- data/features/step_definitions/configure_cli_steps.rb +6 -0
- data/features/step_definitions/filesystem_steps.rb +6 -10
- data/features/support/env.rb +1 -0
- data/generator_files/Vagrantfile.erb +18 -38
- data/lib/berkshelf.rb +0 -19
- data/lib/berkshelf/cli.rb +82 -17
- data/lib/berkshelf/config.rb +77 -28
- data/lib/berkshelf/errors.rb +5 -2
- data/lib/berkshelf/locations/chef_api_location.rb +16 -11
- data/lib/berkshelf/vagrant/action/install.rb +4 -8
- data/lib/berkshelf/vagrant/action/upload.rb +5 -11
- data/lib/berkshelf/vagrant/config.rb +4 -28
- data/lib/berkshelf/version.rb +1 -1
- data/spec/unit/berkshelf/config_spec.rb +28 -68
- data/spec/unit/berkshelf/locations/chef_api_location_spec.rb +0 -6
- data/spec/unit/berkshelf_spec.rb +0 -20
- metadata +7 -10
- data/features/config_command.feature +0 -10
- data/generator_files/config.json +0 -22
- data/lib/berkshelf/config_generator.rb +0 -8
- data/lib/berkshelf/config_validator.rb +0 -78
- data/spec/unit/berkshelf/config_validator_spec.rb +0 -68
@@ -77,12 +77,6 @@ module Berkshelf
|
|
77
77
|
it "uses the value of Chef::Config[:client_key] for the client_key attribute" do
|
78
78
|
@loc.client_key.should eql(Chef::Config[:client_key])
|
79
79
|
end
|
80
|
-
|
81
|
-
it "attempts to load the config file with no arguments" do
|
82
|
-
Berkshelf.should_receive(:load_config).with(no_args)
|
83
|
-
|
84
|
-
subject.new("nginx", constraint, chef_api: :knife)
|
85
|
-
end
|
86
80
|
end
|
87
81
|
end
|
88
82
|
|
data/spec/unit/berkshelf_spec.rb
CHANGED
@@ -26,26 +26,6 @@ describe Berkshelf do
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
describe "::config_path" do
|
30
|
-
it "returns a default value if nothing is specified" do
|
31
|
-
subject.config_path.should eql(Berkshelf::DEFAULT_CONFIG)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns the value assigned if specified" do
|
35
|
-
subject.config_path = value = "/Users/reset/.chef/knife.rb"
|
36
|
-
|
37
|
-
subject.config_path.should eql(value)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe "::load_config" do
|
42
|
-
it "loads the path specified by config_path if no parameter given" do
|
43
|
-
Chef::Config.should_receive(:from_file).with(Berkshelf.config_path)
|
44
|
-
|
45
|
-
subject.load_config
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
29
|
describe "::formatter" do
|
50
30
|
context "with default formatter" do
|
51
31
|
it "should be human readable" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: berkshelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.rc1
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
requirements:
|
22
22
|
- - ! '>='
|
23
23
|
- !ruby/object:Gem::Version
|
24
|
-
version: 0.1
|
24
|
+
version: 0.2.1
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: 0.1
|
32
|
+
version: 0.2.1
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: ridley
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -212,7 +212,7 @@ files:
|
|
212
212
|
- berkshelf.gemspec
|
213
213
|
- bin/berks
|
214
214
|
- features/config.feature
|
215
|
-
- features/
|
215
|
+
- features/configure_command.feature
|
216
216
|
- features/cookbook_command.feature
|
217
217
|
- features/default_locations.feature
|
218
218
|
- features/groups_install.feature
|
@@ -223,6 +223,7 @@ files:
|
|
223
223
|
- features/step_definitions/berksfile_steps.rb
|
224
224
|
- features/step_definitions/chef_server_steps.rb
|
225
225
|
- features/step_definitions/cli_steps.rb
|
226
|
+
- features/step_definitions/configure_cli_steps.rb
|
226
227
|
- features/step_definitions/filesystem_steps.rb
|
227
228
|
- features/step_definitions/json_steps.rb
|
228
229
|
- features/support/env.rb
|
@@ -235,7 +236,6 @@ files:
|
|
235
236
|
- generator_files/Thorfile.erb
|
236
237
|
- generator_files/Vagrantfile.erb
|
237
238
|
- generator_files/chefignore
|
238
|
-
- generator_files/config.json
|
239
239
|
- generator_files/default_recipe.erb
|
240
240
|
- generator_files/gitignore.erb
|
241
241
|
- generator_files/licenses/apachev2.erb
|
@@ -250,8 +250,6 @@ files:
|
|
250
250
|
- lib/berkshelf/cached_cookbook.rb
|
251
251
|
- lib/berkshelf/cli.rb
|
252
252
|
- lib/berkshelf/config.rb
|
253
|
-
- lib/berkshelf/config_generator.rb
|
254
|
-
- lib/berkshelf/config_validator.rb
|
255
253
|
- lib/berkshelf/cookbook_generator.rb
|
256
254
|
- lib/berkshelf/cookbook_source.rb
|
257
255
|
- lib/berkshelf/cookbook_store.rb
|
@@ -323,7 +321,6 @@ files:
|
|
323
321
|
- spec/unit/berkshelf/berksfile_spec.rb
|
324
322
|
- spec/unit/berkshelf/cached_cookbook_spec.rb
|
325
323
|
- spec/unit/berkshelf/config_spec.rb
|
326
|
-
- spec/unit/berkshelf/config_validator_spec.rb
|
327
324
|
- spec/unit/berkshelf/cookbook_generator_spec.rb
|
328
325
|
- spec/unit/berkshelf/cookbook_source_spec.rb
|
329
326
|
- spec/unit/berkshelf/cookbook_store_spec.rb
|
@@ -367,7 +364,7 @@ specification_version: 3
|
|
367
364
|
summary: Manages a Cookbook's, or an Application's, Cookbook dependencies
|
368
365
|
test_files:
|
369
366
|
- features/config.feature
|
370
|
-
- features/
|
367
|
+
- features/configure_command.feature
|
371
368
|
- features/cookbook_command.feature
|
372
369
|
- features/default_locations.feature
|
373
370
|
- features/groups_install.feature
|
@@ -378,6 +375,7 @@ test_files:
|
|
378
375
|
- features/step_definitions/berksfile_steps.rb
|
379
376
|
- features/step_definitions/chef_server_steps.rb
|
380
377
|
- features/step_definitions/cli_steps.rb
|
378
|
+
- features/step_definitions/configure_cli_steps.rb
|
381
379
|
- features/step_definitions/filesystem_steps.rb
|
382
380
|
- features/step_definitions/json_steps.rb
|
383
381
|
- features/support/env.rb
|
@@ -419,7 +417,6 @@ test_files:
|
|
419
417
|
- spec/unit/berkshelf/berksfile_spec.rb
|
420
418
|
- spec/unit/berkshelf/cached_cookbook_spec.rb
|
421
419
|
- spec/unit/berkshelf/config_spec.rb
|
422
|
-
- spec/unit/berkshelf/config_validator_spec.rb
|
423
420
|
- spec/unit/berkshelf/cookbook_generator_spec.rb
|
424
421
|
- spec/unit/berkshelf/cookbook_source_spec.rb
|
425
422
|
- spec/unit/berkshelf/cookbook_store_spec.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
Feature: config command
|
2
|
-
As a Cookbook author
|
3
|
-
I want to quickly generate a Berkshelf config
|
4
|
-
So I can easily tell which options are available to me
|
5
|
-
|
6
|
-
Scenario: creating a new config
|
7
|
-
Given I do not have a Berkshelf config file
|
8
|
-
When I run the config command
|
9
|
-
Then I should have a Berkshelf config file
|
10
|
-
And the exit status should be 0
|
data/generator_files/config.json
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
{
|
2
|
-
"vagrant": {
|
3
|
-
"chef": {
|
4
|
-
"chef_server_url": "https://api.opscode.com/organizations/ORGNAME",
|
5
|
-
"validation_client_name": "ORGNAME-validator",
|
6
|
-
"validation_key_path": "~/validation.pem"
|
7
|
-
},
|
8
|
-
"vm": {
|
9
|
-
"box": "base",
|
10
|
-
"box_url": "http://files.vagrantup.com/lucid64.box",
|
11
|
-
"forward_port": {
|
12
|
-
"80": "8080"
|
13
|
-
},
|
14
|
-
"host_name": "berkshelf-cookbook",
|
15
|
-
"network": {
|
16
|
-
"bridged": true,
|
17
|
-
"hostonly": "192.168.33.10"
|
18
|
-
},
|
19
|
-
"provision": "chef_solo"
|
20
|
-
}
|
21
|
-
}
|
22
|
-
}
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module Berkshelf
|
2
|
-
# @author Justin Campbell <justin@justincampbell.me>
|
3
|
-
class ConfigValidator < ActiveModel::Validator
|
4
|
-
DEFAULT_STRUCTURE = {
|
5
|
-
vagrant: {
|
6
|
-
chef: {
|
7
|
-
chef_server_url: String,
|
8
|
-
validation_client_name: String,
|
9
|
-
validation_key_path: String
|
10
|
-
},
|
11
|
-
vm: {
|
12
|
-
box: String,
|
13
|
-
box_url: String,
|
14
|
-
forward_port: Hash,
|
15
|
-
host_name: String,
|
16
|
-
network: {
|
17
|
-
bridged: Object,
|
18
|
-
hostonly: String
|
19
|
-
},
|
20
|
-
provision: String
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
24
|
-
|
25
|
-
# Recursively validate the structure of a hash with another hash. If
|
26
|
-
# invalid, the actual_hash will have errors added to it.
|
27
|
-
#
|
28
|
-
# @param [Hash] actual_hash
|
29
|
-
# The hash to validate
|
30
|
-
#
|
31
|
-
# @param [Hash] expected_hash
|
32
|
-
# The expected structure of actual_hash
|
33
|
-
#
|
34
|
-
# @param [Config] config
|
35
|
-
# The config object to add errors to. This is only used recursively.
|
36
|
-
#
|
37
|
-
# @return [Boolean]
|
38
|
-
def assert_in_structure(actual_hash, expected_hash, config = nil)
|
39
|
-
config ||= actual_hash
|
40
|
-
|
41
|
-
actual_hash.keys.each do |key|
|
42
|
-
unless expected_hash.keys.include? key.to_sym
|
43
|
-
config.errors.add key, "is not a valid key"
|
44
|
-
return
|
45
|
-
end
|
46
|
-
|
47
|
-
actual = actual_hash[key]
|
48
|
-
expected = expected_hash[key.to_sym]
|
49
|
-
|
50
|
-
if actual.is_a?(Hash) && expected.is_a?(Hash)
|
51
|
-
return unless assert_in_structure actual, expected, config
|
52
|
-
else
|
53
|
-
unless actual.is_a? expected
|
54
|
-
config.errors.add key, "should be an instance of #{expected}"
|
55
|
-
return
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
true
|
61
|
-
end
|
62
|
-
|
63
|
-
# @see DEFAULT_STRUCTURE
|
64
|
-
# @return [Hash]
|
65
|
-
def structure
|
66
|
-
@structure ||= DEFAULT_STRUCTURE
|
67
|
-
end
|
68
|
-
|
69
|
-
# @param [Config] config
|
70
|
-
# The config to validate
|
71
|
-
#
|
72
|
-
# @return [Boolean]
|
73
|
-
def validate(config)
|
74
|
-
assert_in_structure config, structure
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Berkshelf::ConfigValidator do
|
4
|
-
let(:config) { Berkshelf::Config.from_json json }
|
5
|
-
let(:config_validator) { klass.new Hash.new }
|
6
|
-
let(:json) { '{}' }
|
7
|
-
let(:klass) { described_class }
|
8
|
-
let(:structure) { Hash.new }
|
9
|
-
|
10
|
-
before :each do
|
11
|
-
klass.any_instance.stub structure: structure
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "#validate" do
|
15
|
-
subject { config_validator.validate config }
|
16
|
-
|
17
|
-
it { should be_true }
|
18
|
-
it { config.should be_valid }
|
19
|
-
|
20
|
-
context "with a top-level key" do
|
21
|
-
let(:json) { '{ "a": 1 }' }
|
22
|
-
let(:structure) { { a: Object } }
|
23
|
-
|
24
|
-
it { should be_true }
|
25
|
-
it { config.should be_valid }
|
26
|
-
end
|
27
|
-
|
28
|
-
context "with a nested key" do
|
29
|
-
let(:json) { '{ "a": { "b": 1 } }' }
|
30
|
-
let(:structure) { { a: { b: Object } } }
|
31
|
-
|
32
|
-
it { should be_true }
|
33
|
-
it { config.should be_valid }
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with a top-level nonsense key" do
|
37
|
-
let(:json) { '{ "nonsense": null }' }
|
38
|
-
let(:structure) { { a: Object } }
|
39
|
-
|
40
|
-
it { should be_false }
|
41
|
-
it { config.should_not be_valid }
|
42
|
-
end
|
43
|
-
|
44
|
-
context "with a nested nonsense key" do
|
45
|
-
let(:json) { '{ "a": { "nonsense": 1 } }' }
|
46
|
-
let(:structure) { { a: { b: Object } } }
|
47
|
-
|
48
|
-
it { should be_false }
|
49
|
-
it { config.should_not be_valid }
|
50
|
-
end
|
51
|
-
|
52
|
-
context "with a top-level key that doesn't match the expected type" do
|
53
|
-
let(:json) { '{ "a": 1 }' }
|
54
|
-
let(:structure) { { a: String } }
|
55
|
-
|
56
|
-
it { should be_false }
|
57
|
-
it { config.should_not be_valid }
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with a nested key that doesn't match the expected type" do
|
61
|
-
let(:json) { '{ "a": { "b": 1 } }' }
|
62
|
-
let(:structure) { { a: { b: String } } }
|
63
|
-
|
64
|
-
it { should be_false }
|
65
|
-
it { config.should_not be_valid }
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|