berkshelf 8.0.5 → 8.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/berkshelf.gemspec +5 -1
- data/lib/berkshelf/validator.rb +11 -0
- data/lib/berkshelf/version.rb +1 -1
- data/spec/unit/berkshelf/validator_spec.rb +16 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b5a13a8ee09f56803846ad1bf3046802f231c30f80d75c89a3a7a372e779fb6
|
4
|
+
data.tar.gz: 5410164e53e455a48de4cae7721a8a58f46a80e74a954bb588b33e3c005f80da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 556d5c24a23c8926a51e68215db48679470aa91b0e5a11c89a61249a4ad527608dae6bea34516e5aa0847a561b1e41f57e27b88c77af9fdc78f1eb9ca6bc2da1
|
7
|
+
data.tar.gz: 65a853433f25465b79f9e3fda0ef52b62cc73a1149d11b4768d40779898960430859073654778b07a2ea3a0da8e81a8b08ddbfb4f51f39bbda67a1da30b6d683
|
data/berkshelf.gemspec
CHANGED
@@ -42,7 +42,11 @@ Gem::Specification.new do |s|
|
|
42
42
|
s.add_dependency "octokit", "~> 4.0"
|
43
43
|
s.add_dependency "mixlib-archive", ">= 1.1.4", "< 2.0" # needed for ruby 3.0 / Dir.chdir removal
|
44
44
|
s.add_dependency "concurrent-ruby", "~> 1.0"
|
45
|
-
|
45
|
+
if RUBY_VERSION.match?(/3.0/)
|
46
|
+
s.add_dependency "chef", "~> 17.0" # needed for --skip-syntax-check
|
47
|
+
elsif
|
48
|
+
s.add_dependency "chef", ">= 15.7.32"
|
49
|
+
end
|
46
50
|
s.add_dependency "chef-config"
|
47
51
|
# this is required for Mixlib::Config#from_json
|
48
52
|
s.add_dependency "mixlib-config", ">= 2.2.5"
|
data/lib/berkshelf/validator.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'chef/version_class'
|
2
|
+
|
1
3
|
module Berkshelf
|
2
4
|
module Validator
|
3
5
|
class << self
|
@@ -25,10 +27,19 @@ module Berkshelf
|
|
25
27
|
base, name = Pathname.new(cookbook.path.to_s).split
|
26
28
|
|
27
29
|
files = Dir.glob("#{name}/**/*.rb", base: base.to_s).select { |f| f =~ /[[:space:]]/ }
|
30
|
+
validate_versions(cookbook)
|
28
31
|
|
29
32
|
raise InvalidCookbookFiles.new(cookbook, files) unless files.empty?
|
30
33
|
end
|
31
34
|
end
|
35
|
+
|
36
|
+
def validate_versions(cookbook)
|
37
|
+
cookbook_dependencies = cookbook.dependencies
|
38
|
+
cookbook_dependencies.each do |cookbook_name, cookbook_version|
|
39
|
+
version = cookbook_version.gsub(/[^\d,\.]/, '')
|
40
|
+
Chef::Version.new(version)
|
41
|
+
end
|
42
|
+
end
|
32
43
|
end
|
33
44
|
end
|
34
45
|
end
|
data/lib/berkshelf/version.rb
CHANGED
@@ -6,6 +6,7 @@ describe Berkshelf::Validator do
|
|
6
6
|
|
7
7
|
it "raises an error when the cookbook has spaces in the files" do
|
8
8
|
allow(Dir).to receive(:glob).and_return(["/there are/spaces/in this/recipes/default.rb"])
|
9
|
+
allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1.0.0"})
|
9
10
|
expect do
|
10
11
|
subject.validate_files(cookbook)
|
11
12
|
end.to raise_error(Berkshelf::InvalidCookbookFiles)
|
@@ -13,6 +14,21 @@ describe Berkshelf::Validator do
|
|
13
14
|
|
14
15
|
it "does not raise an error when the cookbook is valid" do
|
15
16
|
allow(Dir).to receive(:glob).and_return(["/there-are/no-spaces/in-this/recipes/default.rb"])
|
17
|
+
allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1.0.0"})
|
18
|
+
expect do
|
19
|
+
subject.validate_files(cookbook)
|
20
|
+
end.to_not raise_error
|
21
|
+
end
|
22
|
+
|
23
|
+
it "raises an error when the cookbook version is not valid" do
|
24
|
+
allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1"})
|
25
|
+
expect do
|
26
|
+
subject.validate_files(cookbook)
|
27
|
+
end.to raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "does not raise an error when the cookbook version is valid" do
|
31
|
+
allow(cookbook).to receive(:dependencies).and_return({"cookbook" => "1.0"})
|
16
32
|
expect do
|
17
33
|
subject.validate_files(cookbook)
|
18
34
|
end.to_not raise_error
|
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: 8.0.
|
4
|
+
version: 8.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jamie Winsor
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date:
|
15
|
+
date: 2023-06-12 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: mixlib-shellout
|