vagrant-berkshelf 4.0.0 → 4.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/lib/vagrant-berkshelf/action/base.rb +1 -0
- data/lib/vagrant-berkshelf/action/load.rb +0 -11
- data/lib/vagrant-berkshelf/action/save.rb +27 -0
- data/lib/vagrant-berkshelf/action/share.rb +0 -5
- data/lib/vagrant-berkshelf/config.rb +39 -19
- data/lib/vagrant-berkshelf/plugin.rb +1 -0
- data/lib/vagrant-berkshelf/version.rb +1 -1
- data/spec/unit/vagrant-berkshelf/config_spec.rb +92 -53
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c61e87ce0b69fd6674f2b48dce071d01c1496656
|
4
|
+
data.tar.gz: a6785183831c2affa91f1072f605c883f64c2aac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 96a14944bb147f7efa91ef76297f6e755fe1787e67c4baa4a5159f6a2f5b22ae437f3ba34471ce4c0d224f8967cb939d244f6f03e3d32064aa6fe9d59869d3c7
|
7
|
+
data.tar.gz: 8838114aef207fe47db28da4650141baa9f6451be9c5d1717a87315e3506aef001fc1b714dcb8dae5b52eb636b3e244d1d597f831a8517cdf4691fbf9d856d5a
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,20 @@
|
|
1
|
+
# 4.0.1
|
2
|
+
|
3
|
+
* Bug Fixes
|
4
|
+
* Improved ability to find a Berksfile within a project
|
5
|
+
|
6
|
+
# 4.0.0
|
7
|
+
|
8
|
+
* Enhancements
|
9
|
+
* Add support for chef-client local mode
|
10
|
+
|
11
|
+
* Bug Fixes
|
12
|
+
* Chef Client provider configuration attributes are now properly read from a Berkshelf configuration file
|
13
|
+
* Shared folder is no longer deleted and recreated on each provision
|
14
|
+
* `berksfile_path` config option now defaults to CWD of Vagrantfile
|
15
|
+
* Non-colored terminal output will be used when not available
|
16
|
+
* VM's Berkshelf share will be cleaned up after destroying a VM
|
17
|
+
|
1
18
|
# 3.0.1
|
2
19
|
|
3
20
|
* Bug Fixes
|
@@ -19,23 +19,12 @@ module VagrantPlugins
|
|
19
19
|
env[:berkshelf].shelf = shelf
|
20
20
|
end
|
21
21
|
|
22
|
-
if !provision_enabled?(env)
|
23
|
-
@logger.info "Provisioning disabled, skipping"
|
24
|
-
return @app.call(env)
|
25
|
-
end
|
26
|
-
|
27
22
|
if !env[:berkshelf].shelf
|
28
23
|
shelf = mkshelf(env)
|
29
24
|
env[:machine].ui.detail "The Berkshelf shelf is at #{shelf.inspect}"
|
30
25
|
|
31
26
|
@logger.debug "Persisting datafile share to memory"
|
32
27
|
env[:berkshelf].shelf = shelf
|
33
|
-
|
34
|
-
@logger.debug "Saving datafile to disk"
|
35
|
-
FileUtils.mkdir_p(datafile_path(env).dirname)
|
36
|
-
datafile_path(env).open("w+") do |f|
|
37
|
-
f.write(env[:berkshelf].shelf)
|
38
|
-
end
|
39
28
|
end
|
40
29
|
|
41
30
|
@app.call(env)
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require_relative 'base'
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Berkshelf
|
5
|
+
module Action
|
6
|
+
class Save < Base
|
7
|
+
def call(env)
|
8
|
+
if !berkshelf_enabled?(env)
|
9
|
+
@logger.info "Berkshelf disabled, skipping"
|
10
|
+
return @app.call(env)
|
11
|
+
end
|
12
|
+
|
13
|
+
if env[:berkshelf].shelf
|
14
|
+
@logger.debug "Saving datafile to disk"
|
15
|
+
FileUtils.mkdir_p(datafile_path(env).dirname)
|
16
|
+
datafile_path(env).open("w+") do |f|
|
17
|
+
f.write(env[:berkshelf].shelf)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
@app.call(env)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
@@ -10,11 +10,6 @@ module VagrantPlugins
|
|
10
10
|
return @app.call(env)
|
11
11
|
end
|
12
12
|
|
13
|
-
if !provision_enabled?(env)
|
14
|
-
@logger.info "Provisioning disabled, skipping"
|
15
|
-
return @app.call(env)
|
16
|
-
end
|
17
|
-
|
18
13
|
if !chef_solo?(env) && !chef_zero?(env)
|
19
14
|
@logger.info "Provisioner does not need a share"
|
20
15
|
return @app.call(env)
|
@@ -4,6 +4,8 @@ require 'vagrant/util/hash_with_indifferent_access'
|
|
4
4
|
module VagrantPlugins
|
5
5
|
module Berkshelf
|
6
6
|
class Config < Vagrant.plugin("2", :config)
|
7
|
+
MAYBE = Object.new.freeze
|
8
|
+
|
7
9
|
# The path to the Berksfile to use.
|
8
10
|
# @return [String]
|
9
11
|
attr_accessor :berksfile_path
|
@@ -38,19 +40,7 @@ module VagrantPlugins
|
|
38
40
|
|
39
41
|
def finalize!
|
40
42
|
@berksfile_path = nil if @berksfile_path == UNSET_VALUE
|
41
|
-
|
42
|
-
if @enabled == UNSET_VALUE
|
43
|
-
if @berksfile_path
|
44
|
-
# Automatically enable if a Berksfile path was given
|
45
|
-
@enabled = true
|
46
|
-
elsif File.exist?("Berksfile")
|
47
|
-
# Automatically enable when a Berksfile is persent
|
48
|
-
@berksfile_path = "Berksfile"
|
49
|
-
@enabled = true
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
@enabled = false if @enabled == UNSET_VALUE
|
43
|
+
@enabled = MAYBE if @enabled == UNSET_VALUE
|
54
44
|
|
55
45
|
@__finalized = true
|
56
46
|
end
|
@@ -58,12 +48,38 @@ module VagrantPlugins
|
|
58
48
|
def validate(machine)
|
59
49
|
errors = _detected_errors
|
60
50
|
|
61
|
-
if @enabled
|
62
|
-
if
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
51
|
+
if @enabled || @enabled == MAYBE
|
52
|
+
# If no Berksfile path was given, check if one is in the working
|
53
|
+
# directory
|
54
|
+
if !@berksfile_path
|
55
|
+
path = File.expand_path("Berksfile", machine.env.root_path)
|
56
|
+
|
57
|
+
if File.exist?(path)
|
58
|
+
@enabled = true
|
59
|
+
@berksfile_path = path
|
60
|
+
else
|
61
|
+
# Disable the plugin unless it was specifically set to "true". If
|
62
|
+
# the user set the value, we want to return an error, but if the
|
63
|
+
# user did not explicitly enable the plugin, we should just
|
64
|
+
# disable it automatically.
|
65
|
+
@enabled = false unless @enabled == true
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
if @enabled
|
70
|
+
# Berksfile_path validations
|
71
|
+
if missing?(@berksfile_path)
|
72
|
+
errors << "berksfile_path must be set"
|
73
|
+
else
|
74
|
+
# Expand the path unless it is absolute
|
75
|
+
if !Pathname.new(@berksfile_path).absolute?
|
76
|
+
@berksfile_path = File.expand_path(@berksfile_path, machine.env.root_path)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Ensure the path exists
|
80
|
+
if !File.exist?(@berksfile_path)
|
81
|
+
errors << "Berksfile at '#{@berksfile_path}' does not exist"
|
82
|
+
end
|
67
83
|
end
|
68
84
|
end
|
69
85
|
end
|
@@ -82,6 +98,10 @@ module VagrantPlugins
|
|
82
98
|
args: @args,
|
83
99
|
}
|
84
100
|
end
|
101
|
+
|
102
|
+
def missing?(obj)
|
103
|
+
obj.to_s.strip.empty?
|
104
|
+
end
|
85
105
|
end
|
86
106
|
end
|
87
107
|
end
|
@@ -10,53 +10,12 @@ describe VagrantPlugins::Berkshelf::Config do
|
|
10
10
|
subject.finalize!
|
11
11
|
expect(subject.berksfile_path).to be(nil)
|
12
12
|
end
|
13
|
-
|
14
|
-
it "sets the value if it exists" do
|
15
|
-
allow(File).to receive(:exist?)
|
16
|
-
.with("Berksfile")
|
17
|
-
.and_return(true)
|
18
|
-
subject.finalize!
|
19
|
-
expect(subject.berksfile_path).to eq("Berksfile")
|
20
|
-
end
|
21
13
|
end
|
22
14
|
|
23
15
|
describe "#enabled" do
|
24
|
-
it "
|
25
|
-
allow(File).to receive(:exist?)
|
26
|
-
.with("Berksfile")
|
27
|
-
.and_return(true)
|
16
|
+
it "defaults to MAYBE" do
|
28
17
|
subject.finalize!
|
29
|
-
expect(subject.enabled).to be(
|
30
|
-
end
|
31
|
-
|
32
|
-
it "is false when there is a Berksfile present but it is disabled" do
|
33
|
-
allow(File).to receive(:exist?)
|
34
|
-
.with("Berksfile")
|
35
|
-
.and_return(true)
|
36
|
-
subject.enabled = false
|
37
|
-
subject.finalize!
|
38
|
-
expect(subject.enabled).to be(false)
|
39
|
-
end
|
40
|
-
|
41
|
-
it "is true when a berksfile_path is given" do
|
42
|
-
subject.berksfile_path = "Berksfile"
|
43
|
-
subject.finalize!
|
44
|
-
expect(subject.enabled).to be(true)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "is false when the berksfile_path is given but it is disabled" do
|
48
|
-
subject.berksfile_path = "Berksfile"
|
49
|
-
subject.enabled = false
|
50
|
-
subject.finalize!
|
51
|
-
expect(subject.enabled).to be(false)
|
52
|
-
end
|
53
|
-
|
54
|
-
it "defaults to false" do
|
55
|
-
allow(File).to receive(:exist?)
|
56
|
-
.with("Berksfile")
|
57
|
-
.and_return(false)
|
58
|
-
subject.finalize!
|
59
|
-
expect(subject.enabled).to be(false)
|
18
|
+
expect(subject.enabled).to be(VagrantPlugins::Berkshelf::Config::MAYBE)
|
60
19
|
end
|
61
20
|
end
|
62
21
|
|
@@ -88,7 +47,7 @@ describe VagrantPlugins::Berkshelf::Config do
|
|
88
47
|
before do
|
89
48
|
allow(machine).to receive(:env)
|
90
49
|
.and_return(double("env",
|
91
|
-
root_path: "",
|
50
|
+
root_path: File.expand_path("..", __FILE__),
|
92
51
|
))
|
93
52
|
|
94
53
|
subject.berksfile_path = "Berksfile"
|
@@ -98,21 +57,101 @@ describe VagrantPlugins::Berkshelf::Config do
|
|
98
57
|
subject.args = []
|
99
58
|
end
|
100
59
|
|
101
|
-
let(:result)
|
60
|
+
let(:result) do
|
61
|
+
subject.finalize!
|
62
|
+
subject.validate(machine)
|
63
|
+
end
|
64
|
+
|
102
65
|
let(:errors) { result["Berkshelf"] }
|
103
66
|
|
104
|
-
context "when
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
expect(errors).to
|
67
|
+
context "when enabled is false" do
|
68
|
+
before { subject.enabled = false }
|
69
|
+
|
70
|
+
it "returns no errors" do
|
71
|
+
expect(errors).to be_empty
|
109
72
|
end
|
110
73
|
|
111
|
-
it "
|
74
|
+
it "remains disabled even if a Berksfile is present" do
|
75
|
+
allow(File).to receive(:exist?).and_return(true)
|
76
|
+
expect(errors).to be_empty
|
77
|
+
expect(subject.enabled).to be(false)
|
78
|
+
end
|
79
|
+
|
80
|
+
it "remains disabled even if a berksfile_path is given" do
|
81
|
+
subject.berksfile_path = "Custom.Berksfile"
|
82
|
+
expect(errors).to be_empty
|
83
|
+
expect(subject.enabled).to be(false)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
context "when no berksfile_path is given" do
|
88
|
+
before { subject.berksfile_path = nil }
|
89
|
+
|
90
|
+
context "when a Berksfile is present" do
|
91
|
+
before { allow(File).to receive(:exist?).and_return(true) }
|
92
|
+
|
93
|
+
it "sets the berksfile_path" do
|
94
|
+
expect(errors).to be_empty
|
95
|
+
expect(subject.berksfile_path).to eq(File.expand_path("../Berksfile", __FILE__))
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context "when a Berksfile is not present" do
|
100
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
101
|
+
|
102
|
+
context "when the plugin is enabled" do
|
103
|
+
it "returns an error" do
|
104
|
+
subject.enabled = true
|
105
|
+
expect(errors).to include("berksfile_path must be set")
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when the plugin is in MAYBE state" do
|
110
|
+
it "disables the plugin" do
|
111
|
+
subject.enabled = VagrantPlugins::Berkshelf::Config::MAYBE
|
112
|
+
expect(errors).to be_empty
|
113
|
+
expect(subject.enabled).to be(false)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
context "when a berksfile_path is given" do
|
120
|
+
before { subject.berksfile_path = "Custom.Berksfile" }
|
121
|
+
|
122
|
+
let(:expanded_path) { File.expand_path("../Custom.Berksfile", __FILE__) }
|
123
|
+
|
124
|
+
context "when another Berksfile is present" do
|
125
|
+
before { allow(File).to receive(:exist?).and_return(true) }
|
126
|
+
|
127
|
+
it "does not change the berksfile_path" do
|
128
|
+
expect(errors).to be_empty
|
129
|
+
expect(subject.berksfile_path).to eq(expanded_path)
|
130
|
+
end
|
131
|
+
|
132
|
+
it "expands the path relative to the machine root" do
|
133
|
+
subject.finalize!
|
134
|
+
subject.validate(machine)
|
135
|
+
expect(subject.berksfile_path).to eq(expanded_path)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
context "when the given berksfile_path does not exist" do
|
140
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
141
|
+
|
142
|
+
it "returns an error" do
|
143
|
+
expect(errors).to include("Berksfile at '#{expanded_path}' does not exist")
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context "when the berksfile_path is nil and no Berksfile exists" do
|
149
|
+
before { allow(File).to receive(:exist?).and_return(false) }
|
150
|
+
|
151
|
+
it "returns an error if enabled" do
|
112
152
|
subject.berksfile_path = ""
|
113
|
-
subject.enabled = false
|
114
153
|
subject.finalize!
|
115
|
-
expect(errors).to
|
154
|
+
expect(errors).to include("berksfile_path must be set")
|
116
155
|
end
|
117
156
|
end
|
118
157
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vagrant-berkshelf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: spork
|
@@ -78,6 +78,7 @@ files:
|
|
78
78
|
- lib/vagrant-berkshelf/action/clean.rb
|
79
79
|
- lib/vagrant-berkshelf/action/install.rb
|
80
80
|
- lib/vagrant-berkshelf/action/load.rb
|
81
|
+
- lib/vagrant-berkshelf/action/save.rb
|
81
82
|
- lib/vagrant-berkshelf/action/share.rb
|
82
83
|
- lib/vagrant-berkshelf/action/upload.rb
|
83
84
|
- lib/vagrant-berkshelf/config.rb
|