chef-dk 1.6.11 → 2.0.26
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/Gemfile +25 -38
- data/Gemfile.lock +199 -199
- data/README.md +4 -2
- data/Rakefile +1 -2
- data/acceptance/Gemfile +1 -1
- data/acceptance/Gemfile.lock +23 -21
- data/chef-dk.gemspec +4 -6
- data/lib/chef-dk/builtin_commands.rb +1 -1
- data/lib/chef-dk/chef_runner.rb +1 -1
- data/lib/chef-dk/cli.rb +1 -0
- data/lib/chef-dk/command/generate.rb +5 -2
- data/lib/chef-dk/command/generator_commands/helpers.rb +36 -0
- data/lib/chef-dk/command/generator_commands/{lwrp.rb → resource.rb} +4 -4
- data/lib/chef-dk/command/update.rb +11 -18
- data/lib/chef-dk/command/verify.rb +1 -16
- data/lib/chef-dk/commands_map.rb +3 -3
- data/lib/chef-dk/policyfile/artifactory_cookbook_source.rb +102 -0
- data/lib/chef-dk/policyfile/cookbook_location_specification.rb +2 -2
- data/lib/chef-dk/policyfile/cookbook_sources.rb +1 -0
- data/lib/chef-dk/policyfile/dsl.rb +10 -0
- data/lib/chef-dk/policyfile/solution_dependencies.rb +15 -1
- data/lib/chef-dk/policyfile_lock.rb +1 -1
- data/lib/chef-dk/policyfile_services/install.rb +30 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/Berksfile +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/build_cookbook/test-fixture-recipe.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/cookbook_readmes/README.md +2 -2
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-config.json +3 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/delivery-project.toml +1 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/attributes/default.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/metadata.rb +2 -1
- data/lib/chef-dk/skeletons/code_generator/files/default/repo/cookbooks/example/recipes/default.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/files/default/spec_helper_policyfile.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/metadata.rb +3 -2
- data/lib/chef-dk/skeletons/code_generator/recipes/app.rb +1 -1
- data/lib/chef-dk/skeletons/code_generator/recipes/attribute.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/build_cookbook.rb +7 -12
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/cookbook_file.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/helpers.rb +21 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/policyfile.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/recipe.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/repo.rb +1 -0
- data/lib/chef-dk/skeletons/code_generator/recipes/{lwrp.rb → resource.rb} +1 -11
- data/lib/chef-dk/skeletons/code_generator/recipes/template.rb +3 -3
- data/lib/chef-dk/skeletons/code_generator/templates/default/helpers.rb.erb +39 -0
- data/lib/chef-dk/skeletons/code_generator/templates/default/metadata.rb.erb +1 -1
- data/lib/chef-dk/skeletons/code_generator/templates/default/resource.rb.erb +1 -0
- data/lib/chef-dk/version.rb +2 -2
- data/omnibus_overrides.rb +14 -12
- data/spec/unit/command/generator_commands/cookbook_spec.rb +7 -1
- data/spec/unit/command/generator_commands/helpers_spec.rb +31 -0
- data/spec/unit/command/generator_commands/{lwrp_spec.rb → resource_spec.rb} +5 -5
- data/spec/unit/command/install_spec.rb +2 -2
- data/spec/unit/command/update_spec.rb +11 -3
- data/spec/unit/command/verify_spec.rb +2 -1
- data/spec/unit/policyfile/artifactory_cookbook_source_spec.rb +59 -0
- data/spec/unit/policyfile/read_cookbook_for_compat_mode_upload_spec.rb +1 -1
- data/spec/unit/policyfile/solution_dependencies_spec.rb +25 -0
- data/spec/unit/policyfile_demands_spec.rb +2 -1
- data/spec/unit/policyfile_lock_build_spec.rb +23 -21
- data/spec/unit/policyfile_lock_install_spec.rb +2 -2
- data/spec/unit/policyfile_lock_validation_spec.rb +3 -3
- data/spec/unit/policyfile_services/export_repo_spec.rb +6 -6
- data/spec/unit/policyfile_services/install_spec.rb +1 -1
- data/spec/unit/policyfile_services/update_spec.rb +143 -0
- data/tasks/announce.rb +3 -2
- data/tasks/dependencies.rb +35 -111
- data/tasks/github_changelog_generator.rb +0 -3
- data/tasks/templates/prerelease.md.erb +1 -1
- data/tasks/templates/release.md.erb +1 -1
- metadata +20 -38
- data/lib/chef-dk/skeletons/code_generator/templates/default/provider.rb.erb +0 -0
- data/spec/unit/gemfile_util_spec.rb +0 -41
- data/spec/unit/helpers_spec.rb +0 -120
- data/spec/unit/tasks/helpers_spec.rb +0 -75
- data/tasks/bin/bundle-platform +0 -19
- data/tasks/bin/create-override-gemfile +0 -110
- data/tasks/bundle.rb +0 -96
- data/tasks/bundle_util.rb +0 -110
- data/tasks/gemfile_util.rb +0 -435
- data/tasks/helpers.rb +0 -47
- data/version_policy.rb +0 -142
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
context = ChefDK::Generator.context
|
|
3
3
|
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
|
4
4
|
|
|
5
5
|
resource_dir = File.join(cookbook_dir, 'resources')
|
|
6
6
|
resource_path = File.join(resource_dir, "#{context.new_file_basename}.rb")
|
|
7
7
|
|
|
8
|
-
provider_dir = File.join(cookbook_dir, 'providers')
|
|
9
|
-
provider_path = File.join(provider_dir, "#{context.new_file_basename}.rb")
|
|
10
|
-
|
|
11
8
|
directory resource_dir
|
|
12
9
|
|
|
13
10
|
template resource_path do
|
|
14
11
|
source 'resource.rb.erb'
|
|
15
12
|
helpers(ChefDK::Generator::TemplateHelper)
|
|
16
13
|
end
|
|
17
|
-
|
|
18
|
-
directory provider_dir
|
|
19
|
-
|
|
20
|
-
template provider_path do
|
|
21
|
-
source 'provider.rb.erb'
|
|
22
|
-
helpers(ChefDK::Generator::TemplateHelper)
|
|
23
|
-
end
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
2
|
context = ChefDK::Generator.context
|
|
3
3
|
cookbook_dir = File.join(context.cookbook_root, context.cookbook_name)
|
|
4
|
-
template_dir = File.join(cookbook_dir, 'templates'
|
|
4
|
+
template_dir = File.join(cookbook_dir, 'templates')
|
|
5
5
|
template_filename = context.new_file_basename
|
|
6
6
|
|
|
7
7
|
unless File.extname(template_filename) == '.erb'
|
|
@@ -19,7 +19,7 @@ end
|
|
|
19
19
|
if context.content_source
|
|
20
20
|
|
|
21
21
|
file template_path do
|
|
22
|
-
content(IO.read(context.
|
|
22
|
+
content(IO.read(context.content_source))
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
else
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Chef Documentation
|
|
3
|
+
# https://docs.chef.io/libraries.html
|
|
4
|
+
#
|
|
5
|
+
|
|
6
|
+
#
|
|
7
|
+
# This module name was auto-generated from the cookbook name. This name is a
|
|
8
|
+
# single word that starts with a capital letter and then continues to use
|
|
9
|
+
# camel-casing throughout the remainder of the name.
|
|
10
|
+
#
|
|
11
|
+
module <%= @cookbook_class_name %>
|
|
12
|
+
module <%= @helper_class_name %>
|
|
13
|
+
#
|
|
14
|
+
# Define the methods that you would like to assist the work you do in recipes,
|
|
15
|
+
# resources, or templates.
|
|
16
|
+
#
|
|
17
|
+
# def my_helper_method
|
|
18
|
+
# # help method implementation
|
|
19
|
+
# end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
#
|
|
24
|
+
# The module you have defined may be extended within the recipe to grant the
|
|
25
|
+
# recipe the helper methods you define.
|
|
26
|
+
#
|
|
27
|
+
# Within your recipe you would write:
|
|
28
|
+
#
|
|
29
|
+
# extend <%= @cookbook_class_name %>::<%= @helper_class_name %>
|
|
30
|
+
#
|
|
31
|
+
# my_helper_method
|
|
32
|
+
#
|
|
33
|
+
# You may also add this to a single resource within a recipe:
|
|
34
|
+
#
|
|
35
|
+
# template '/etc/app.conf' do
|
|
36
|
+
# extend <%= @cookbook_class_name %>::<%= @helper_class_name %>
|
|
37
|
+
# variables specific_key: my_helper_method
|
|
38
|
+
# end
|
|
39
|
+
#
|
|
@@ -13,7 +13,7 @@ chef_version '>= 12.1' if respond_to?(:chef_version)
|
|
|
13
13
|
#
|
|
14
14
|
# issues_url 'https://github.com/<insert_org_here>/<%= cookbook_name %>/issues'
|
|
15
15
|
|
|
16
|
-
# The `source_url` points to the development
|
|
16
|
+
# The `source_url` points to the development repository for this cookbook. A
|
|
17
17
|
# `View Source` link will be displayed on this cookbook's page when uploaded to
|
|
18
18
|
# a Supermarket.
|
|
19
19
|
#
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# To learn more about Custom Resources, see https://docs.chef.io/custom_resources.html
|
data/lib/chef-dk/version.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c) 2014
|
|
2
|
+
# Copyright:: Copyright (c) 2014 Chef Software Inc.
|
|
3
3
|
# License:: Apache License, Version 2.0
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -16,5 +16,5 @@
|
|
|
16
16
|
#
|
|
17
17
|
|
|
18
18
|
module ChefDK
|
|
19
|
-
VERSION = "
|
|
19
|
+
VERSION = "2.0.26"
|
|
20
20
|
end
|
data/omnibus_overrides.rb
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# THIS IS NOW HAND MANAGED, JUST EDIT THE THING
|
|
2
|
+
# .travis.yml and appveyor.yml consume this,
|
|
3
|
+
# try to keep it machine-parsable.
|
|
4
|
+
override :rubygems, version: "2.6.11"
|
|
5
|
+
override :bundler, version: "1.15.1"
|
|
4
6
|
override "libffi", version: "3.2.1"
|
|
5
|
-
override "libiconv", version: "1.
|
|
7
|
+
override "libiconv", version: "1.14"
|
|
6
8
|
override "liblzma", version: "5.2.3"
|
|
7
|
-
override "
|
|
8
|
-
override "
|
|
9
|
-
override "
|
|
9
|
+
override "libtool", version: "2.4.2"
|
|
10
|
+
override "libxml2", version: "2.9.4"
|
|
11
|
+
override "libxslt", version: "1.1.29"
|
|
12
|
+
override "libyaml", version: "0.1.6"
|
|
10
13
|
override "makedepend", version: "1.0.5"
|
|
11
14
|
override "ncurses", version: "5.9"
|
|
12
|
-
override "openssl", version: "1.0.2m"
|
|
13
15
|
override "pkg-config-lite", version: "0.28-1"
|
|
14
|
-
override "ruby", version: "2.
|
|
16
|
+
override "ruby", version: "2.4.1"
|
|
17
|
+
override "ruby-windows-devkit-bash", version: "3.1.23-4-msys-1.0.18"
|
|
15
18
|
override "util-macros", version: "1.19.0"
|
|
16
19
|
override "xproto", version: "7.0.28"
|
|
17
20
|
override "zlib", version: "1.2.11"
|
|
18
|
-
override "
|
|
19
|
-
override "
|
|
20
|
-
override "libzmq", version: "4.0.7"
|
|
21
|
+
override "libzmq", version: "4.0.5"
|
|
22
|
+
override "openssl", version: "1.0.2l"
|
|
@@ -198,7 +198,7 @@ lint = "chef exec cookstyle"
|
|
|
198
198
|
# uploaded to Supermarket. We turn off any rules tagged "supermarket"
|
|
199
199
|
# by default. If you plan to share this cookbook you should remove
|
|
200
200
|
# '-t ~supermarket' below to enable supermarket rules.
|
|
201
|
-
syntax = "chef exec foodcritic .
|
|
201
|
+
syntax = "chef exec foodcritic . -t ~supermarket"
|
|
202
202
|
provision = "chef exec kitchen create"
|
|
203
203
|
deploy = "chef exec kitchen converge"
|
|
204
204
|
smoke = "chef exec kitchen verify"
|
|
@@ -235,6 +235,9 @@ PROJECT_DOT_TOML
|
|
|
235
235
|
"name": "build_cookbook",
|
|
236
236
|
"path": ".delivery/build_cookbook"
|
|
237
237
|
},
|
|
238
|
+
"delivery-truck": {
|
|
239
|
+
"enable_cookstyle": true
|
|
240
|
+
},
|
|
238
241
|
"skip_phases": [],
|
|
239
242
|
"job_dispatch": {
|
|
240
243
|
"version": "v2"
|
|
@@ -589,6 +592,7 @@ KITCHEN_YML
|
|
|
589
592
|
|
|
590
593
|
let(:expected_chefspec_spec_helper_content) do
|
|
591
594
|
<<-SPEC_HELPER
|
|
595
|
+
# frozen_string_literal: true
|
|
592
596
|
require 'chefspec'
|
|
593
597
|
require 'chefspec/policyfile'
|
|
594
598
|
SPEC_HELPER
|
|
@@ -608,6 +612,7 @@ SPEC_HELPER
|
|
|
608
612
|
|
|
609
613
|
let(:expected_content) do
|
|
610
614
|
<<-POLICYFILE_RB
|
|
615
|
+
# frozen_string_literal: true
|
|
611
616
|
source 'https://supermarket.chef.io'
|
|
612
617
|
|
|
613
618
|
metadata
|
|
@@ -666,6 +671,7 @@ KITCHEN_YML
|
|
|
666
671
|
|
|
667
672
|
let(:expected_chefspec_spec_helper_content) do
|
|
668
673
|
<<-SPEC_HELPER
|
|
674
|
+
# frozen_string_literal: true
|
|
669
675
|
require 'chefspec'
|
|
670
676
|
require 'chefspec/berkshelf'
|
|
671
677
|
SPEC_HELPER
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) 2014 Chef Software Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require 'spec_helper'
|
|
19
|
+
require 'shared/a_file_generator'
|
|
20
|
+
require 'chef-dk/command/generator_commands/helpers'
|
|
21
|
+
|
|
22
|
+
describe ChefDK::Command::GeneratorCommands::Helpers do
|
|
23
|
+
|
|
24
|
+
include_examples "a file generator" do
|
|
25
|
+
|
|
26
|
+
let(:generator_name) { "helpers" }
|
|
27
|
+
let(:generated_files) { [ "libraries/new_helpers.rb" ] }
|
|
28
|
+
let(:new_file_name) { "new_helpers" }
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -17,15 +17,15 @@
|
|
|
17
17
|
|
|
18
18
|
require "spec_helper"
|
|
19
19
|
require "shared/a_file_generator"
|
|
20
|
-
require "chef-dk/command/generator_commands/
|
|
20
|
+
require "chef-dk/command/generator_commands/resource"
|
|
21
21
|
|
|
22
|
-
describe ChefDK::Command::GeneratorCommands::
|
|
22
|
+
describe ChefDK::Command::GeneratorCommands::Resource do
|
|
23
23
|
|
|
24
24
|
include_examples "a file generator" do
|
|
25
25
|
|
|
26
|
-
let(:generator_name) { "
|
|
27
|
-
let(:generated_files) { [ "resources/
|
|
28
|
-
let(:new_file_name) { "
|
|
26
|
+
let(:generator_name) { "resource" }
|
|
27
|
+
let(:generated_files) { [ "resources/new_resource.rb" ] }
|
|
28
|
+
let(:new_file_name) { "new_resource" }
|
|
29
29
|
|
|
30
30
|
end
|
|
31
31
|
end
|
|
@@ -78,7 +78,7 @@ describe ChefDK::Command::Install do
|
|
|
78
78
|
|
|
79
79
|
it "creates the installer service with a `nil` policyfile path" do
|
|
80
80
|
expect(ChefDK::PolicyfileServices::Install).to receive(:new).
|
|
81
|
-
with(hash_including(policyfile: nil, ui: command.ui, root_dir: Dir.pwd)).
|
|
81
|
+
with(hash_including(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, config: Chef::Config)).
|
|
82
82
|
and_return(install_service)
|
|
83
83
|
expect(command.installer).to eq(install_service)
|
|
84
84
|
end
|
|
@@ -95,7 +95,7 @@ describe ChefDK::Command::Install do
|
|
|
95
95
|
|
|
96
96
|
it "creates the installer service with the specified policyfile path" do
|
|
97
97
|
expect(ChefDK::PolicyfileServices::Install).to receive(:new).
|
|
98
|
-
with(hash_including(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd)).
|
|
98
|
+
with(hash_including(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd, config: Chef::Config)).
|
|
99
99
|
and_return(install_service)
|
|
100
100
|
expect(command.installer).to eq(install_service)
|
|
101
101
|
end
|
|
@@ -77,7 +77,7 @@ describe ChefDK::Command::Update do
|
|
|
77
77
|
let(:params) { ["-a"] }
|
|
78
78
|
|
|
79
79
|
it "enables attributes update mode" do
|
|
80
|
-
expect(command.
|
|
80
|
+
expect(command.update_attributes_only?).to be(true)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
it "creates an attributes update service object" do
|
|
@@ -96,7 +96,7 @@ describe ChefDK::Command::Update do
|
|
|
96
96
|
|
|
97
97
|
it "creates the installer service with a `nil` policyfile path" do
|
|
98
98
|
expect(ChefDK::PolicyfileServices::Install).to receive(:new).
|
|
99
|
-
with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, overwrite: true).
|
|
99
|
+
with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd, config: Chef::Config, overwrite: true).
|
|
100
100
|
and_return(install_service)
|
|
101
101
|
expect(command.installer).to eq(install_service)
|
|
102
102
|
end
|
|
@@ -113,7 +113,7 @@ describe ChefDK::Command::Update do
|
|
|
113
113
|
|
|
114
114
|
it "creates the installer service with the specified policyfile path" do
|
|
115
115
|
expect(ChefDK::PolicyfileServices::Install).to receive(:new).
|
|
116
|
-
with(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd, overwrite: true).
|
|
116
|
+
with(policyfile: "MyPolicy.rb", ui: command.ui, root_dir: Dir.pwd, config: Chef::Config, overwrite: true).
|
|
117
117
|
and_return(install_service)
|
|
118
118
|
expect(command.installer).to eq(install_service)
|
|
119
119
|
end
|
|
@@ -132,6 +132,10 @@ describe ChefDK::Command::Update do
|
|
|
132
132
|
context "when the command is successful" do
|
|
133
133
|
before do
|
|
134
134
|
expect(install_service).to receive(:run)
|
|
135
|
+
expect(ChefDK::PolicyfileServices::UpdateAttributes).to receive(:new).
|
|
136
|
+
with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd).
|
|
137
|
+
and_return(update_attrs_service)
|
|
138
|
+
expect(update_attrs_service).to receive(:run)
|
|
135
139
|
end
|
|
136
140
|
|
|
137
141
|
it "returns 0" do
|
|
@@ -155,6 +159,10 @@ describe ChefDK::Command::Update do
|
|
|
155
159
|
|
|
156
160
|
before do
|
|
157
161
|
expect(install_service).to receive(:run).and_raise(exception)
|
|
162
|
+
expect(ChefDK::PolicyfileServices::UpdateAttributes).to receive(:new).
|
|
163
|
+
with(policyfile: nil, ui: command.ui, root_dir: Dir.pwd).
|
|
164
|
+
and_return(update_attrs_service)
|
|
165
|
+
expect(update_attrs_service).to receive(:run)
|
|
158
166
|
end
|
|
159
167
|
|
|
160
168
|
it "returns 1" do
|
|
@@ -45,7 +45,6 @@ describe ChefDK::Command::Verify do
|
|
|
45
45
|
"chef-provisioning",
|
|
46
46
|
"chefspec",
|
|
47
47
|
"generated-cookbooks-pass-chefspec",
|
|
48
|
-
"rubocop",
|
|
49
48
|
"fauxhai",
|
|
50
49
|
"knife-spork",
|
|
51
50
|
"kitchen-vagrant",
|
|
@@ -106,6 +105,7 @@ describe ChefDK::Command::Verify do
|
|
|
106
105
|
|
|
107
106
|
describe "when running verify command" do
|
|
108
107
|
let(:stdout_io) { StringIO.new }
|
|
108
|
+
let(:stderr_io) { StringIO.new }
|
|
109
109
|
let(:ruby_path) { File.join(fixtures_path, "eg_omnibus_dir/valid/embedded/bin/ruby") }
|
|
110
110
|
|
|
111
111
|
def run_unit_test
|
|
@@ -170,6 +170,7 @@ describe ChefDK::Command::Verify do
|
|
|
170
170
|
before do
|
|
171
171
|
allow(Gem).to receive(:ruby).and_return(ruby_path)
|
|
172
172
|
allow(command_instance).to receive(:stdout).and_return(stdout_io)
|
|
173
|
+
allow(command_instance).to receive(:stderr).and_return(stderr_io)
|
|
173
174
|
allow(command_instance).to receive(:components).and_return(components)
|
|
174
175
|
end
|
|
175
176
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Copyright:: Copyright (c) 2014 Chef Software Inc.
|
|
3
|
+
# License:: Apache License, Version 2.0
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
#
|
|
17
|
+
|
|
18
|
+
require "spec_helper"
|
|
19
|
+
require "chef-dk/policyfile/source_uri"
|
|
20
|
+
require "chef-dk/policyfile/artifactory_cookbook_source"
|
|
21
|
+
|
|
22
|
+
describe ChefDK::Policyfile::ArtifactoryCookbookSource do
|
|
23
|
+
subject { described_class.new(cookbook_source) }
|
|
24
|
+
|
|
25
|
+
let(:cookbook_source) { "https://supermarket.chef.io/api/v1" }
|
|
26
|
+
|
|
27
|
+
let(:http_connection) { double("Chef::HTTP::Simple") }
|
|
28
|
+
|
|
29
|
+
let(:universe_response_encoded) { IO.read(File.join(fixtures_path, "cookbooks_api/small_universe.json")) }
|
|
30
|
+
|
|
31
|
+
let(:pruned_universe) { JSON.parse(IO.read(File.join(fixtures_path, "cookbooks_api/pruned_small_universe.json"))) }
|
|
32
|
+
|
|
33
|
+
describe "fetching the Universe graph" do
|
|
34
|
+
|
|
35
|
+
before do
|
|
36
|
+
expect(subject).to receive(:http_connection_for).with(cookbook_source).and_return(http_connection)
|
|
37
|
+
allow(http_connection).to receive(:get).with("/universe").and_return(universe_response_encoded)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it "fetches the universe graph" do
|
|
41
|
+
expect(http_connection).to receive(:get).with("/universe").and_return(universe_response_encoded)
|
|
42
|
+
actual_universe = subject.universe_graph
|
|
43
|
+
expect(actual_universe).to have_key("apt")
|
|
44
|
+
expect(actual_universe["apt"]).to eq(pruned_universe["apt"])
|
|
45
|
+
expect(subject.universe_graph).to eq(pruned_universe)
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "generates location options for a cookbook from the given graph" do
|
|
49
|
+
cookbook_url = "https://supermarket.chef.io/api/v1/cookbooks/apache2/versions/1.10.4/download"
|
|
50
|
+
expect(subject).to receive(:http_connection_for).with(cookbook_url).and_return(http_connection)
|
|
51
|
+
expected_opts = {
|
|
52
|
+
artifactory: cookbook_url,
|
|
53
|
+
http_client: http_connection,
|
|
54
|
+
version: "1.10.4",
|
|
55
|
+
}
|
|
56
|
+
expect(subject.source_options_for("apache2", "1.10.4")).to eq(expected_opts)
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
end
|
|
@@ -85,7 +85,7 @@ describe ChefDK::Policyfile::ReadCookbookForCompatModeUpload do
|
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
it "excludes ignored files from the list of cookbook files" do
|
|
88
|
-
expect(reader_with_ignored_files.cookbook_version.
|
|
88
|
+
expect(reader_with_ignored_files.cookbook_version.files_for("root_files")).to_not include(chefignored_file)
|
|
89
89
|
end
|
|
90
90
|
|
|
91
91
|
end
|
|
@@ -69,6 +69,31 @@ describe ChefDK::Policyfile::SolutionDependencies do
|
|
|
69
69
|
|
|
70
70
|
end
|
|
71
71
|
|
|
72
|
+
context 'when populated with dependency data from a complex lockfile' do
|
|
73
|
+
let(:dependency_data) do
|
|
74
|
+
{
|
|
75
|
+
"Policyfile" => [
|
|
76
|
+
[ "a", ">= 0.0.0"], ["b", ">= 0.0.0" ]
|
|
77
|
+
],
|
|
78
|
+
"dependencies" => {
|
|
79
|
+
"a (0.1.0)" => [ ["c", "~> 1.0.0"], ["d", "~> 0.0.0"] ],
|
|
80
|
+
"b (1.0.0)" => [ ["f", ">= 0.0.1"] ],
|
|
81
|
+
"c (1.0.1)" => [ ["e", ">= 0.0.1"] ],
|
|
82
|
+
"d (0.0.1)" => [],
|
|
83
|
+
"e (0.0.1)" => [],
|
|
84
|
+
"f (0.0.1)" => [],
|
|
85
|
+
},
|
|
86
|
+
}
|
|
87
|
+
end
|
|
88
|
+
it "can compute list of transitive dependencies" do
|
|
89
|
+
|
|
90
|
+
expect(solution_dependencies.transitive_deps(["e"])).to eq(["e"])
|
|
91
|
+
expect(solution_dependencies.transitive_deps(["c"])).to eq(["c", "e"])
|
|
92
|
+
expect(solution_dependencies.transitive_deps(["c", "d"])).to eq(["c", "d", "e"])
|
|
93
|
+
expect(solution_dependencies.transitive_deps(["a"])).to eq(["a", "c", "d", "e"])
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
72
97
|
context "when populated with dependency data" do
|
|
73
98
|
|
|
74
99
|
let(:expected_deps_for_lock) do
|
|
@@ -861,12 +861,13 @@ MESSAGE
|
|
|
861
861
|
|
|
862
862
|
it "includes the policyfile constraint in the solution dependencies" do
|
|
863
863
|
expected_solution_deps = {
|
|
864
|
-
"Policyfile" => [ [ "
|
|
864
|
+
"Policyfile" => [ [ "local-cookbook", ">= 0.0.0" ], [ "remote-cb", "~> 0.1" ] ],
|
|
865
865
|
"dependencies" => {
|
|
866
866
|
"local-cookbook (2.3.4)" => [],
|
|
867
867
|
"remote-cb (0.1.0)" => [],
|
|
868
868
|
},
|
|
869
869
|
|
|
870
|
+
|
|
870
871
|
}
|
|
871
872
|
expect(policyfile.solution_dependencies.to_lock).to eq(expected_solution_deps)
|
|
872
873
|
end
|