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
|
@@ -480,8 +480,8 @@ REVISION_STRING
|
|
|
480
480
|
<<-REVISION_STRING
|
|
481
481
|
name:custom_identifier
|
|
482
482
|
run-list-item:recipe[foo]
|
|
483
|
-
cookbook:foo;id:1.0.0
|
|
484
483
|
cookbook:bar;id:0.1.0
|
|
484
|
+
cookbook:foo;id:1.0.0
|
|
485
485
|
default_attributes:{}
|
|
486
486
|
override_attributes:{}
|
|
487
487
|
REVISION_STRING
|
|
@@ -502,15 +502,6 @@ REVISION_STRING
|
|
|
502
502
|
|
|
503
503
|
"cookbook_locks" => {
|
|
504
504
|
|
|
505
|
-
"foo" => {
|
|
506
|
-
"version" => "1.0.0",
|
|
507
|
-
"identifier" => "1.0.0",
|
|
508
|
-
"dotted_decimal_identifier" => "1.0.0",
|
|
509
|
-
"cache_key" => "foo-1.0.0",
|
|
510
|
-
"origin" => nil,
|
|
511
|
-
"source_options" => nil,
|
|
512
|
-
},
|
|
513
|
-
|
|
514
505
|
"bar" => {
|
|
515
506
|
"version" => "0.1.0",
|
|
516
507
|
"identifier" => "0.1.0",
|
|
@@ -528,6 +519,16 @@ REVISION_STRING
|
|
|
528
519
|
},
|
|
529
520
|
"source_options" => nil,
|
|
530
521
|
},
|
|
522
|
+
|
|
523
|
+
"foo" => {
|
|
524
|
+
"version" => "1.0.0",
|
|
525
|
+
"identifier" => "1.0.0",
|
|
526
|
+
"dotted_decimal_identifier" => "1.0.0",
|
|
527
|
+
"cache_key" => "foo-1.0.0",
|
|
528
|
+
"origin" => nil,
|
|
529
|
+
"source_options" => nil,
|
|
530
|
+
},
|
|
531
|
+
|
|
531
532
|
},
|
|
532
533
|
|
|
533
534
|
"default_attributes" => {},
|
|
@@ -603,10 +604,10 @@ name:basic_example
|
|
|
603
604
|
run-list-item:recipe[foo]
|
|
604
605
|
run-list-item:recipe[bar]
|
|
605
606
|
run-list-item:recipe[baz::non_default]
|
|
606
|
-
cookbook:foo;id:#{cookbook_foo_cksum}
|
|
607
607
|
cookbook:bar;id:#{cookbook_bar_cksum}
|
|
608
608
|
cookbook:baz;id:#{cookbook_baz_cksum}
|
|
609
609
|
cookbook:dep_of_bar;id:#{cookbook_dep_of_bar_cksum}
|
|
610
|
+
cookbook:foo;id:#{cookbook_foo_cksum}
|
|
610
611
|
default_attributes:{}
|
|
611
612
|
override_attributes:{}
|
|
612
613
|
REVISION_STRING
|
|
@@ -627,15 +628,6 @@ REVISION_STRING
|
|
|
627
628
|
|
|
628
629
|
"cookbook_locks" => {
|
|
629
630
|
|
|
630
|
-
"foo" => {
|
|
631
|
-
"version" => "1.0.0",
|
|
632
|
-
"identifier" => cookbook_foo_cksum,
|
|
633
|
-
"dotted_decimal_identifier" => cookbook_foo_cksum_dotted,
|
|
634
|
-
"origin" => "https://community.chef.io/api/cookbooks/foo/1.0.0",
|
|
635
|
-
"cache_key" => "foo-1.0.0",
|
|
636
|
-
"source_options" => nil,
|
|
637
|
-
},
|
|
638
|
-
|
|
639
631
|
"bar" => {
|
|
640
632
|
"version" => "0.1.0",
|
|
641
633
|
"identifier" => cookbook_bar_cksum,
|
|
@@ -673,6 +665,16 @@ REVISION_STRING
|
|
|
673
665
|
|
|
674
666
|
},
|
|
675
667
|
|
|
668
|
+
"foo" => {
|
|
669
|
+
"version" => "1.0.0",
|
|
670
|
+
"identifier" => cookbook_foo_cksum,
|
|
671
|
+
"dotted_decimal_identifier" => cookbook_foo_cksum_dotted,
|
|
672
|
+
"origin" => "https://community.chef.io/api/cookbooks/foo/1.0.0",
|
|
673
|
+
"cache_key" => "foo-1.0.0",
|
|
674
|
+
"source_options" => nil,
|
|
675
|
+
},
|
|
676
|
+
|
|
677
|
+
|
|
676
678
|
},
|
|
677
679
|
|
|
678
680
|
"default_attributes" => {},
|
|
@@ -945,8 +947,8 @@ name:my-policyfile
|
|
|
945
947
|
run-list-item:recipe[foo::default]
|
|
946
948
|
run-list-item:recipe[bar::default]
|
|
947
949
|
named-run-list:rl2;run-list-item:recipe[bar::default]
|
|
948
|
-
cookbook:foo;id:#{cookbook_foo_cksum}
|
|
949
950
|
cookbook:bar;id:#{cookbook_bar_cksum}
|
|
951
|
+
cookbook:foo;id:#{cookbook_foo_cksum}
|
|
950
952
|
default_attributes:#{canonicalized_default_attrs}
|
|
951
953
|
override_attributes:#{canonicalized_override_attrs}
|
|
952
954
|
REVISION_STRING
|
|
@@ -96,8 +96,8 @@ describe ChefDK::PolicyfileLock, "installing cookbooks from a lockfile" do
|
|
|
96
96
|
cookbook_lock = policyfile_lock.cookbook_locks["local-cookbook"]
|
|
97
97
|
expect(cookbook_lock.name).to eq("local-cookbook")
|
|
98
98
|
expect(cookbook_lock.version).to eq("2.3.4")
|
|
99
|
-
expect(cookbook_lock.identifier).to eq("
|
|
100
|
-
expect(cookbook_lock.dotted_decimal_identifier).to eq("
|
|
99
|
+
expect(cookbook_lock.identifier).to eq("1e9dfd1134735385b425c056cb5decef9081b92c")
|
|
100
|
+
expect(cookbook_lock.dotted_decimal_identifier).to eq("8617959542256467.37634246136220509.260513665759532")
|
|
101
101
|
expect(cookbook_lock.source).to eq("local-cookbook")
|
|
102
102
|
expect(cookbook_lock.source_options).to eq({ path: "local-cookbook" })
|
|
103
103
|
expect(cookbook_lock.cookbook_location_spec.version_constraint).to eq(Semverse::Constraint.new("= 2.3.4"))
|
|
@@ -199,7 +199,7 @@ E
|
|
|
199
199
|
it "updates the content identifier" do
|
|
200
200
|
old_id = lock_generator.lock_data_for("local-cookbook").identifier
|
|
201
201
|
expect(cookbook_lock_data.identifier).to_not eq(old_id)
|
|
202
|
-
expect(cookbook_lock_data.identifier).to eq("
|
|
202
|
+
expect(cookbook_lock_data.identifier).to eq("5a2b09f9d5e6e8a1a2d811c41d58ed200599adbe")
|
|
203
203
|
end
|
|
204
204
|
|
|
205
205
|
it "has an updated version and identifier" do
|
|
@@ -267,7 +267,7 @@ E
|
|
|
267
267
|
old_id = lock_generator.lock_data_for("local-cookbook").identifier
|
|
268
268
|
|
|
269
269
|
expect(cookbook_lock_data.identifier).to_not eq(old_id)
|
|
270
|
-
expect(cookbook_lock_data.identifier).to eq("
|
|
270
|
+
expect(cookbook_lock_data.identifier).to eq("0f62422f744d173c35a3e74f1a8c76c8b92908c2")
|
|
271
271
|
end
|
|
272
272
|
|
|
273
273
|
it "has an updated identifier but not an updated version" do
|
|
@@ -305,7 +305,7 @@ E
|
|
|
305
305
|
old_id = lock_generator.lock_data_for("local-cookbook").identifier
|
|
306
306
|
|
|
307
307
|
expect(cookbook_lock_data.identifier).to_not eq(old_id)
|
|
308
|
-
expect(cookbook_lock_data.identifier).to eq("
|
|
308
|
+
expect(cookbook_lock_data.identifier).to eq("af5e1252307bdf99b878ca5ede3c40e24ee9e45a")
|
|
309
309
|
end
|
|
310
310
|
|
|
311
311
|
it "has an updated identifier but not an updated version" do
|
|
@@ -106,7 +106,7 @@ describe ChefDK::PolicyfileServices::ExportRepo do
|
|
|
106
106
|
|
|
107
107
|
let(:local_cookbook_path) { File.join(fixtures_path, "local_path_cookbooks/local-cookbook") }
|
|
108
108
|
|
|
109
|
-
let(:revision_id) { "
|
|
109
|
+
let(:revision_id) { "7da81d2c7bb97f904637f97e7f8b487fa4bb1ed682edea7087743dec84c254ec" }
|
|
110
110
|
|
|
111
111
|
let(:lockfile_content) do
|
|
112
112
|
<<-E
|
|
@@ -119,8 +119,8 @@ describe ChefDK::PolicyfileServices::ExportRepo do
|
|
|
119
119
|
"cookbook_locks": {
|
|
120
120
|
"local-cookbook": {
|
|
121
121
|
"version": "2.3.4",
|
|
122
|
-
"identifier": "
|
|
123
|
-
"dotted_decimal_identifier": "
|
|
122
|
+
"identifier": "1e9dfd1134735385b425c056cb5decef9081b92c",
|
|
123
|
+
"dotted_decimal_identifier": "42704157235437826.6970356709321892.63549625984142",
|
|
124
124
|
"source": "#{local_cookbook_path}",
|
|
125
125
|
"cache_key": null,
|
|
126
126
|
"scm_info": null,
|
|
@@ -168,7 +168,7 @@ E
|
|
|
168
168
|
context "when the given 'export_dir' is a directory" do
|
|
169
169
|
|
|
170
170
|
it "sets the archive file location to $policy_name-$revision.tgz" do
|
|
171
|
-
expected = File.join(export_dir, "install-example-
|
|
171
|
+
expected = File.join(export_dir, "install-example-7da81d2c7bb97f904637f97e7f8b487fa4bb1ed682edea7087743dec84c254ec.tgz")
|
|
172
172
|
expect(export_service.archive_file_location).to eq(expected)
|
|
173
173
|
end
|
|
174
174
|
|
|
@@ -215,7 +215,7 @@ E
|
|
|
215
215
|
expected << Pathname.new("metadata.json")
|
|
216
216
|
end
|
|
217
217
|
|
|
218
|
-
let(:cookbook_with_version) { "local-cookbook-
|
|
218
|
+
let(:cookbook_with_version) { "local-cookbook-1e9dfd1134735385b425c056cb5decef9081b92c" }
|
|
219
219
|
|
|
220
220
|
let(:exported_cookbook_root) { Pathname.new(File.join(export_dir, "cookbook_artifacts", cookbook_with_version)) }
|
|
221
221
|
|
|
@@ -422,7 +422,7 @@ CONFIG
|
|
|
422
422
|
let(:archive) { true }
|
|
423
423
|
|
|
424
424
|
let(:expected_archive_path) do
|
|
425
|
-
File.join(export_dir, "install-example-
|
|
425
|
+
File.join(export_dir, "install-example-7da81d2c7bb97f904637f97e7f8b487fa4bb1ed682edea7087743dec84c254ec.tgz")
|
|
426
426
|
end
|
|
427
427
|
|
|
428
428
|
it "exports the repo as a tgz archive" do
|
|
@@ -128,7 +128,7 @@ E
|
|
|
128
128
|
|
|
129
129
|
it "prints the lockfile's revision id" do
|
|
130
130
|
install_service.run
|
|
131
|
-
expect(ui.output).to include("Policy revision id:
|
|
131
|
+
expect(ui.output).to include("Policy revision id: 7da81d2c7bb97f904637f97e7f8b487fa4bb1ed682edea7087743dec84c254ec")
|
|
132
132
|
end
|
|
133
133
|
|
|
134
134
|
end
|
|
@@ -0,0 +1,143 @@
|
|
|
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_services/install"
|
|
20
|
+
require "chef-dk/policyfile/cookbook_sources"
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
describe ChefDK::PolicyfileServices::Install do
|
|
24
|
+
|
|
25
|
+
include ChefDK::Helpers
|
|
26
|
+
|
|
27
|
+
let(:working_dir) do
|
|
28
|
+
path = File.join(tempdir, "policyfile_services_test_working_dir")
|
|
29
|
+
Dir.mkdir(path)
|
|
30
|
+
path
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
let(:policyfile_rb_explicit_name) { nil }
|
|
34
|
+
|
|
35
|
+
let(:policyfile_rb_name) { policyfile_rb_explicit_name || "Policyfile.rb" }
|
|
36
|
+
|
|
37
|
+
let(:policyfile_rb_path) { File.join(working_dir, policyfile_rb_name) }
|
|
38
|
+
|
|
39
|
+
let(:policyfile_lock_name) { "Policyfile.lock.json" }
|
|
40
|
+
|
|
41
|
+
let(:policyfile_lock_path) { File.join(working_dir, policyfile_lock_name) }
|
|
42
|
+
|
|
43
|
+
let(:ui) { TestHelpers::TestUI.new }
|
|
44
|
+
|
|
45
|
+
let(:install_service) { described_class.new(policyfile: policyfile_rb_name, ui: ui, root_dir: working_dir, overwrite: true) }
|
|
46
|
+
|
|
47
|
+
let(:storage_config) do
|
|
48
|
+
ChefDK::Policyfile::StorageConfig.new( cache_path: nil, relative_paths_root: local_cookbooks_root )
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
let(:policyfile_content) do
|
|
52
|
+
<<-EOH
|
|
53
|
+
default_source :community
|
|
54
|
+
name 'install-example'
|
|
55
|
+
|
|
56
|
+
run_list 'top-level'
|
|
57
|
+
|
|
58
|
+
cookbook 'top-level'
|
|
59
|
+
cookbook 'top-level-bis'
|
|
60
|
+
cookbook 'b', '>= 1.2.3'
|
|
61
|
+
EOH
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def cookbook_lock(name, version)
|
|
65
|
+
{
|
|
66
|
+
"version" => version,
|
|
67
|
+
"identifier" => Digest::SHA256.new.hexdigest(version),
|
|
68
|
+
"dotted_decimal_identifier" => "55385045718000942.66835911167097593.12604218968062",
|
|
69
|
+
"cache_key" => "#{name}-#{version}-supermarket.chef.io",
|
|
70
|
+
"origin" => "https://supermarket.chef.io:443/api/v1/cookbooks/#{name}/versions/#{version}/download",
|
|
71
|
+
"source_options" => {
|
|
72
|
+
"artifactserver" => "https://supermarket.chef.io:443/api/v1/cookbooks/#{name}/versions/#{version}/download",
|
|
73
|
+
"version" => version
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
let(:policyfile_lock_content) do
|
|
79
|
+
{
|
|
80
|
+
"revision_id" => "b33cb73a52bee7254eb53138ee44",
|
|
81
|
+
"name" => "install-example",
|
|
82
|
+
"run_list" => [ "recipe[top-level::default]" ],
|
|
83
|
+
"cookbook_locks" => {
|
|
84
|
+
"top-level" => cookbook_lock("top-level", "1.2.0"),
|
|
85
|
+
"a" => cookbook_lock("a", "2.1.0"),
|
|
86
|
+
"b" => cookbook_lock("b", "1.2.3"),
|
|
87
|
+
"top-level-bis" => cookbook_lock("top-level-bis", "1.0.0")
|
|
88
|
+
},
|
|
89
|
+
"default_attributes" => {},
|
|
90
|
+
"override_attributes" => {},
|
|
91
|
+
"solution_dependencies" => {
|
|
92
|
+
"Policyfile" => [
|
|
93
|
+
[ "top-level", "= 1.2.0" ],
|
|
94
|
+
[ "a", "= 2.1.0" ],
|
|
95
|
+
[ "b", "= 1.2.3" ],
|
|
96
|
+
[ "top-level-bis", "= 1.0.0" ],
|
|
97
|
+
],
|
|
98
|
+
"dependencies" => {
|
|
99
|
+
"top-level (1.2.0)" => [ [ "a", "~> 2.1" ], [ "b", "~> 1.0" ] ],
|
|
100
|
+
"a (2.1.0)" => [],
|
|
101
|
+
"b (1.2.3)" => [],
|
|
102
|
+
"top-level-bis (1.0.0)" => []
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}.to_json
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
context "when given one cookbook to update" do
|
|
110
|
+
before(:each) do
|
|
111
|
+
# stub access to Policyfile.rb and Policyfile.lock.json
|
|
112
|
+
expect(File).to receive(:exist?).at_least(:once).with(policyfile_rb_path).and_return(true)
|
|
113
|
+
expect(File).to receive(:exist?).at_least(:once).with(policyfile_lock_path).and_return(true)
|
|
114
|
+
|
|
115
|
+
expect(IO).to receive(:read).with(policyfile_rb_path).and_return(policyfile_content)
|
|
116
|
+
expect(IO).to receive(:read).with(policyfile_lock_path).and_return(policyfile_lock_content)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
# lock generation is a no-op. Its behavior is already tested
|
|
120
|
+
# elsewhere. We only check constraints changes
|
|
121
|
+
expect(install_service).to receive(:generate_lock_and_install)
|
|
122
|
+
|
|
123
|
+
expect { install_service.run(["top-level"]) }.not_to raise_error
|
|
124
|
+
end
|
|
125
|
+
it "allows update on cookbook to update" do
|
|
126
|
+
expect(install_service.policyfile_compiler.dsl.cookbook_location_specs["top-level"].version_constraint.to_s).to eq(">= 0.0.0")
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
it "does not update unrelated cookbooks" do
|
|
130
|
+
expect(install_service.policyfile_compiler.dsl.cookbook_location_specs["top-level-bis"].version_constraint.to_s).to eq("= 1.0.0")
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
it "allows update on dependencies" do
|
|
134
|
+
expect(install_service.policyfile_compiler.dsl.cookbook_location_specs["a"]).to be_nil
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "preserves existing constraints from Policyfile" do
|
|
138
|
+
expect(install_service.policyfile_compiler.dsl.cookbook_location_specs["b"].version_constraint.to_s).to eq(">= 1.2.3")
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
end
|
data/tasks/announce.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c) 2016
|
|
2
|
+
# Copyright:: Copyright (c) 2016 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");
|
|
@@ -24,6 +24,7 @@ class ReleaseAnnouncement
|
|
|
24
24
|
|
|
25
25
|
def initialize(version, date, type)
|
|
26
26
|
@version = version
|
|
27
|
+
@maj_minor = version.split(".")[0..1].join(".")
|
|
27
28
|
@date = Date.parse(date) unless date.nil?
|
|
28
29
|
@release_notes = release_notes_from_file
|
|
29
30
|
@type = type
|
|
@@ -40,7 +41,7 @@ class ReleaseAnnouncement
|
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
def release_notes_from_file
|
|
43
|
-
File.read("RELEASE_NOTES.md").match(/^# ChefDK #{@
|
|
44
|
+
File.read("RELEASE_NOTES.md").match(/^# ChefDK #{@maj_minor} Release Notes\n\n(.*)/m)[1]
|
|
44
45
|
end
|
|
45
46
|
end
|
|
46
47
|
|
data/tasks/dependencies.rb
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#
|
|
2
|
-
# Copyright:: Copyright (c) 2016 Chef Software Inc.
|
|
2
|
+
# Copyright:: Copyright (c) 2016-2017, 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");
|
|
@@ -15,151 +15,75 @@
|
|
|
15
15
|
# limitations under the License.
|
|
16
16
|
#
|
|
17
17
|
|
|
18
|
-
require_relative "bundle_util"
|
|
19
|
-
require_relative "bundle"
|
|
20
|
-
require_relative "../version_policy"
|
|
21
|
-
require_relative "helpers"
|
|
22
|
-
|
|
23
18
|
desc "Tasks to update and check dependencies"
|
|
24
19
|
namespace :dependencies do
|
|
25
20
|
|
|
26
21
|
# Running update_ci on your local system wont' work. The best way to update
|
|
27
22
|
# dependencies locally is by running the dependency update script.
|
|
28
|
-
desc "Update all dependencies."
|
|
23
|
+
desc "Update all dependencies. dependencies:update to update as little as possible."
|
|
29
24
|
task :update do |t, rake_args|
|
|
25
|
+
# FIXME: probably broken, and needs less indirection
|
|
30
26
|
system("#{File.join(Dir.pwd, "ci", "dependency_update.sh")}")
|
|
31
27
|
end
|
|
32
28
|
|
|
33
29
|
desc "Force update (when adding new gems to Gemfiles)"
|
|
34
30
|
task :force_update do |t, rake_args|
|
|
31
|
+
# FIXME: probably broken, and needs less indirection
|
|
35
32
|
FileUtils.rm_f(File.join(Dir.pwd, ".bundle", "config"))
|
|
36
33
|
system("#{File.join(Dir.pwd, "ci", "dependency_update.sh")}")
|
|
37
34
|
end
|
|
38
35
|
|
|
39
36
|
# Update all dependencies to the latest constraint-matching version
|
|
40
|
-
desc "Update all dependencies. (CI
|
|
37
|
+
desc "Update all dependencies. dependencies:update to update as little as possible (CI-only)."
|
|
41
38
|
task :update_ci => %w{
|
|
42
|
-
dependencies:update_stable_channel_gems
|
|
43
39
|
dependencies:update_gemfile_lock
|
|
44
|
-
dependencies:update_omnibus_overrides
|
|
45
40
|
dependencies:update_omnibus_gemfile_lock
|
|
46
41
|
dependencies:update_acceptance_gemfile_lock
|
|
47
42
|
}
|
|
48
43
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
extend BundleUtil
|
|
59
|
-
puts ""
|
|
60
|
-
puts "-------------------------------------------------------------------"
|
|
61
|
-
puts "Updating #{dir}/Gemfile.lock ..."
|
|
62
|
-
puts "-------------------------------------------------------------------"
|
|
63
|
-
with_bundle_unfrozen(cwd: dir, leave_frozen: leave_frozen) do
|
|
64
|
-
bundle "install", cwd: dir, delete_gemfile_lock: true
|
|
65
|
-
if other_platforms
|
|
66
|
-
# Include all other supported platforms into the lockfile as well
|
|
67
|
-
platforms.each do |platform|
|
|
68
|
-
bundle "lock", cwd: dir, platform: platform
|
|
69
|
-
end
|
|
70
|
-
end
|
|
44
|
+
def bundle_update_locked_multiplatform_task(task_name, dir)
|
|
45
|
+
desc "Update #{dir}/Gemfile.lock."
|
|
46
|
+
task task_name do
|
|
47
|
+
Dir.chdir(dir) do
|
|
48
|
+
Bundler.with_clean_env do
|
|
49
|
+
rm_f "#{dir}/Gemfile.lock"
|
|
50
|
+
sh "bundle lock --update --add-platform ruby"
|
|
51
|
+
sh "bundle lock --update --add-platform x64-mingw32"
|
|
52
|
+
sh "bundle lock --update --add-platform x86-mingw32"
|
|
71
53
|
end
|
|
72
54
|
end
|
|
73
55
|
end
|
|
74
56
|
end
|
|
75
57
|
|
|
76
|
-
def
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
puts "-------------------------------------------------------------------"
|
|
83
|
-
puts "Updating #{dir}/Berksfile.lock ..."
|
|
84
|
-
puts "-------------------------------------------------------------------"
|
|
85
|
-
if File.exist?("#{project_root}/#{dir}/Berksfile.lock")
|
|
86
|
-
File.delete("#{project_root}/#{dir}/Berksfile.lock")
|
|
87
|
-
end
|
|
88
|
-
Dir.chdir("#{project_root}/#{dir}") do
|
|
89
|
-
Bundler.with_clean_env do
|
|
90
|
-
sh "bundle exec berks install"
|
|
91
|
-
end
|
|
58
|
+
def bundle_update_task(task_name, dir)
|
|
59
|
+
desc "Update #{dir}/Gemfile.lock."
|
|
60
|
+
task task_name do
|
|
61
|
+
Dir.chdir(dir) do
|
|
62
|
+
Bundler.with_clean_env do
|
|
63
|
+
sh "bundle update"
|
|
92
64
|
end
|
|
93
65
|
end
|
|
94
66
|
end
|
|
95
67
|
end
|
|
96
68
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
extend BundleUtil
|
|
106
|
-
puts ""
|
|
107
|
-
puts "-------------------------------------------------------------------"
|
|
108
|
-
puts "Updating Gemfile ..."
|
|
109
|
-
puts "-------------------------------------------------------------------"
|
|
110
|
-
|
|
111
|
-
# Modify the gemfile to pin to stable chef
|
|
112
|
-
gemfile_path = File.join(project_root, "Gemfile")
|
|
113
|
-
gemfile = IO.read(gemfile_path)
|
|
114
|
-
update_gemfile_from_stable(gemfile, "chef", "chef", "v")
|
|
115
|
-
update_gemfile_from_stable(gemfile, "push-jobs-client", "opscode-pushy-client")
|
|
116
|
-
|
|
117
|
-
if gemfile != IO.read(gemfile_path)
|
|
118
|
-
puts "Writing modified #{gemfile_path} ..."
|
|
119
|
-
IO.write(gemfile_path, gemfile)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
desc "Update omnibus overrides, including versions in version_policy.rb and latest version of gems: #{OMNIBUS_RUBYGEMS_AT_LATEST_VERSION.keys}."
|
|
124
|
-
task :update_omnibus_overrides do |t, rake_args|
|
|
125
|
-
puts ""
|
|
126
|
-
puts "-------------------------------------------------------------------"
|
|
127
|
-
puts "Updating omnibus_overrides.rb ..."
|
|
128
|
-
puts "-------------------------------------------------------------------"
|
|
129
|
-
|
|
130
|
-
# Generate the new overrides file
|
|
131
|
-
overrides = "# DO NOT EDIT. Generated by \"rake dependencies\". Edit version_policy.rb instead.\n"
|
|
132
|
-
|
|
133
|
-
# Replace the bundler and rubygems versions
|
|
134
|
-
OMNIBUS_RUBYGEMS_AT_LATEST_VERSION.each do |override_name, gem_name|
|
|
135
|
-
# Get the latest bundler version
|
|
136
|
-
puts "Running gem list -r #{gem_name} ..."
|
|
137
|
-
gem_list = `gem list -r #{gem_name}`
|
|
138
|
-
unless gem_list =~ /^#{gem_name}\s*\(([^)]*)\)$/
|
|
139
|
-
raise "gem list -r #{gem_name} failed with output:\n#{gem_list}"
|
|
69
|
+
def berks_update_task(task_name, dir)
|
|
70
|
+
desc "Update #{dir}/Berksfile.lock."
|
|
71
|
+
task task_name do
|
|
72
|
+
FileUtils.rm_f("#{dir}/Berksfile.lock")
|
|
73
|
+
Dir.chdir(dir) do
|
|
74
|
+
Bundler.with_clean_env do
|
|
75
|
+
sh "bundle exec berks install"
|
|
76
|
+
end
|
|
140
77
|
end
|
|
141
|
-
|
|
142
|
-
# Emit it
|
|
143
|
-
puts "Latest version of #{gem_name} is #{$1}"
|
|
144
|
-
overrides << "override #{override_name.inspect}, version: #{$1.inspect}\n"
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
# Add explicit overrides
|
|
148
|
-
OMNIBUS_OVERRIDES.each do |override_name, version|
|
|
149
|
-
overrides << "override #{override_name.inspect}, version: #{version.inspect}\n"
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# Write the file out (if changed)
|
|
153
|
-
overrides_path = File.expand_path("../../omnibus_overrides.rb", __FILE__)
|
|
154
|
-
if overrides != IO.read(overrides_path)
|
|
155
|
-
puts "Overrides changed!"
|
|
156
|
-
puts `git diff #{overrides_path}`
|
|
157
|
-
puts "Writing modified #{overrides_path} ..."
|
|
158
|
-
IO.write(overrides_path, overrides)
|
|
159
78
|
end
|
|
160
79
|
end
|
|
80
|
+
|
|
81
|
+
bundle_update_locked_multiplatform_task :update_gemfile_lock, "."
|
|
82
|
+
bundle_update_locked_multiplatform_task :update_omnibus_gemfile_lock, "omnibus"
|
|
83
|
+
bundle_update_task :update_acceptance_gemfile_lock, "acceptance"
|
|
161
84
|
end
|
|
85
|
+
|
|
162
86
|
desc "Update all dependencies and check for outdated gems."
|
|
163
|
-
task :dependencies_ci => [ "dependencies:update_ci"
|
|
87
|
+
task :dependencies_ci => [ "dependencies:update_ci" ]
|
|
164
88
|
task :dependencies => [ "dependencies:update" ]
|
|
165
|
-
task :update => [ "dependencies:update"
|
|
89
|
+
task :update => [ "dependencies:update" ]
|