chef 12.9.41-universal-mingw32 → 12.10.24-universal-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +52 -13
  3. data/README.md +145 -0
  4. data/Rakefile +4 -14
  5. data/VERSION +1 -1
  6. data/acceptance/.gitignore +0 -1
  7. data/acceptance/Gemfile +2 -2
  8. data/acceptance/Gemfile.lock +235 -0
  9. data/acceptance/fips/.kitchen.yml +5 -1
  10. data/acceptance/fips/test/integration/{fips → fips-integration}/serverspec/Gemfile +0 -0
  11. data/acceptance/fips/test/integration/fips-integration/serverspec/fips-integration_spec.rb +51 -0
  12. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/Gemfile +3 -0
  13. data/acceptance/fips/test/integration/fips-unit-functional/serverspec/fips-unit-functional_spec.rb +56 -0
  14. data/{chef-windows.gemspec → chef-universal-mingw32.gemspec} +0 -0
  15. data/chef.gemspec +0 -6
  16. data/{lib → lib-backcompat}/chef/chef_fs/file_system/already_exists_error.rb +0 -0
  17. data/{lib → lib-backcompat}/chef/chef_fs/file_system/cookbook_frozen_error.rb +0 -0
  18. data/{lib → lib-backcompat}/chef/chef_fs/file_system/default_environment_cannot_be_modified_error.rb +0 -0
  19. data/{lib → lib-backcompat}/chef/chef_fs/file_system/file_system_error.rb +0 -0
  20. data/{lib → lib-backcompat}/chef/chef_fs/file_system/must_delete_recursively_error.rb +0 -0
  21. data/{lib → lib-backcompat}/chef/chef_fs/file_system/not_found_error.rb +0 -0
  22. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_failed_error.rb +0 -0
  23. data/{lib → lib-backcompat}/chef/chef_fs/file_system/operation_not_allowed_error.rb +0 -0
  24. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_acls_dir.rb +5 -0
  25. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_client_keys_dir.rb +5 -0
  26. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +6 -0
  27. data/lib-backcompat/chef/chef_fs/file_system/repository/chef_repository_file_system_policies_dir.rb +5 -0
  28. data/{lib → lib-backcompat}/chef/chef_fs/file_system/repository/file_system_root_dir.rb +1 -0
  29. data/lib/chef/chef_fs/file_system/repository/acl.rb +38 -0
  30. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_acls_dir.rb → acls_dir.rb} +14 -5
  31. data/lib/chef/chef_fs/file_system/repository/acls_sub_dir.rb +42 -0
  32. data/lib/chef/chef_fs/file_system/repository/base_file.rb +120 -0
  33. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_cookbook_entry.rb +1 -1
  34. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_root_dir.rb +36 -32
  35. data/lib/chef/chef_fs/file_system/repository/client.rb +38 -0
  36. data/lib/chef/chef_fs/file_system/repository/client_key.rb +38 -0
  37. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_client_keys_dir.rb → client_keys_dir.rb} +9 -5
  38. data/lib/chef/chef_fs/file_system/repository/client_keys_sub_dir.rb +42 -0
  39. data/lib/chef/chef_fs/file_system/repository/clients_dir.rb +40 -0
  40. data/lib/chef/chef_fs/file_system/repository/container.rb +38 -0
  41. data/lib/chef/chef_fs/file_system/repository/containers_dir.rb +41 -0
  42. data/lib/chef/chef_fs/file_system/repository/cookbooks_dir.rb +0 -1
  43. data/lib/chef/chef_fs/file_system/repository/data_bag_item.rb +3 -79
  44. data/lib/chef/chef_fs/file_system/repository/directory.rb +15 -2
  45. data/lib/chef/chef_fs/file_system/repository/environment.rb +38 -0
  46. data/lib/chef/chef_fs/file_system/repository/environments_dir.rb +41 -0
  47. data/lib/chef/chef_fs/file_system/repository/file_system_entry.rb +66 -30
  48. data/lib/chef/chef_fs/file_system/repository/group.rb +38 -0
  49. data/lib/chef/chef_fs/file_system/repository/groups_dir.rb +41 -0
  50. data/lib/chef/chef_fs/file_system/repository/node.rb +38 -0
  51. data/lib/chef/chef_fs/file_system/repository/nodes_dir.rb +41 -0
  52. data/lib/chef/chef_fs/file_system/repository/{chef_repository_file_system_policies_dir.rb → policies_dir.rb} +9 -5
  53. data/lib/chef/chef_fs/file_system/repository/policy.rb +38 -0
  54. data/lib/chef/chef_fs/file_system/repository/policy_group.rb +38 -0
  55. data/lib/chef/chef_fs/file_system/repository/policy_groups_dir.rb +41 -0
  56. data/lib/chef/chef_fs/file_system/repository/role.rb +38 -0
  57. data/lib/chef/chef_fs/file_system/repository/roles_dir.rb +41 -0
  58. data/lib/chef/chef_fs/file_system/repository/user.rb +38 -0
  59. data/lib/chef/chef_fs/file_system/repository/users_dir.rb +41 -0
  60. data/lib/chef/dsl/declare_resource.rb +182 -7
  61. data/lib/chef/http/json_input.rb +2 -2
  62. data/lib/chef/knife.rb +1 -1
  63. data/lib/chef/mixin/shell_out.rb +10 -21
  64. data/lib/chef/property.rb +9 -2
  65. data/lib/chef/provider.rb +8 -7
  66. data/lib/chef/provider/apt_repository.rb +8 -6
  67. data/lib/chef/provider/directory.rb +15 -1
  68. data/lib/chef/provider/env/windows.rb +1 -1
  69. data/lib/chef/provider/mdadm.rb +1 -0
  70. data/lib/chef/provider/package/easy_install.rb +2 -0
  71. data/lib/chef/provider/package/rubygems.rb +4 -1
  72. data/lib/chef/provider/package/windows.rb +1 -1
  73. data/lib/chef/recipe.rb +1 -2
  74. data/lib/chef/resource/apt_repository.rb +6 -6
  75. data/lib/chef/resource/mdadm.rb +9 -0
  76. data/lib/chef/resource_collection.rb +5 -0
  77. data/lib/chef/resource_collection/resource_list.rb +10 -0
  78. data/lib/chef/resource_collection/resource_set.rb +14 -11
  79. data/lib/chef/version.rb +1 -1
  80. data/spec/functional/resource/git_spec.rb +1 -3
  81. data/spec/functional/resource/group_spec.rb +5 -5
  82. data/spec/functional/tiny_server_spec.rb +1 -1
  83. data/spec/functional/util/powershell/cmdlet_spec.rb +1 -1
  84. data/spec/functional/win32/registry_spec.rb +3 -3
  85. data/spec/integration/solo/solo_spec.rb +2 -2
  86. data/spec/support/shared/functional/securable_resource.rb +1 -1
  87. data/spec/support/shared/unit/provider/file.rb +3 -3
  88. data/spec/support/shared/unit/windows_script_resource.rb +1 -1
  89. data/spec/unit/application/apply_spec.rb +1 -0
  90. data/spec/unit/chef_fs/file_system/repository/base_file_spec.rb +128 -0
  91. data/spec/unit/chef_fs/file_system/repository/directory_spec.rb +174 -0
  92. data/spec/unit/cookbook/metadata_spec.rb +1 -1
  93. data/spec/unit/dsl/declare_resource_spec.rb +335 -0
  94. data/spec/unit/knife/bootstrap_spec.rb +2 -2
  95. data/spec/unit/mixin/shell_out_spec.rb +4 -0
  96. data/spec/unit/node/attribute_spec.rb +1 -1
  97. data/spec/unit/node/immutable_collections_spec.rb +2 -2
  98. data/spec/unit/node_map_spec.rb +1 -1
  99. data/spec/unit/property/validation_spec.rb +23 -7
  100. data/spec/unit/provider/apt_repository_spec.rb +5 -0
  101. data/spec/unit/provider/apt_update_spec.rb +1 -0
  102. data/spec/unit/provider/directory_spec.rb +0 -7
  103. data/spec/unit/provider/file/content_spec.rb +1 -1
  104. data/spec/unit/provider/mdadm_spec.rb +9 -0
  105. data/spec/unit/provider/package/easy_install_spec.rb +6 -0
  106. data/spec/unit/provider/package/rubygems_spec.rb +8 -4
  107. data/spec/unit/provider/package/yum_spec.rb +1 -1
  108. data/spec/unit/provider/powershell_script_spec.rb +1 -1
  109. data/spec/unit/provider/user/dscl_spec.rb +6 -6
  110. data/spec/unit/recipe_spec.rb +1 -0
  111. data/spec/unit/resource/apt_repository_spec.rb +4 -0
  112. data/spec/unit/resource/file/verification_spec.rb +1 -1
  113. data/spec/unit/resource/file_spec.rb +2 -2
  114. data/spec/unit/resource/mdadm_spec.rb +7 -2
  115. data/spec/unit/resource_collection_spec.rb +30 -0
  116. data/spec/unit/resource_spec.rb +1 -1
  117. data/tasks/bin/bundle-platform +15 -0
  118. data/tasks/bin/bundle-platform.bat +2 -0
  119. data/tasks/bin/create-override-gemfile +110 -0
  120. data/tasks/bin/run_chef_tests +17 -0
  121. data/tasks/bin/run_external_test +47 -0
  122. data/tasks/bundle.rb +97 -0
  123. data/tasks/bundle_util.rb +94 -0
  124. data/tasks/changelog.rb +12 -0
  125. data/tasks/dependencies.rb +147 -0
  126. data/tasks/gemfile_util.rb +390 -0
  127. data/tasks/maintainers.rb +2 -1
  128. data/tasks/rspec.rb +2 -1
  129. metadata +61 -83
  130. data/acceptance/fips/test/integration/fips/serverspec/fips_spec.rb +0 -39
  131. data/lib/chef/chef_fs/file_system/repository/chef_repository_file_system_entry.rb +0 -83
  132. data/tasks/external_tests.rb +0 -64
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ platforms = ARGV.shift
4
+ old_platforms = Gem.platforms
5
+ Gem.platforms = platforms.split(" ").map { |p| Gem::Platform.new(p) }
6
+ puts "bundle-platform set Gem.platforms to #{Gem.platforms.map { |p| p.to_s }} (was #{old_platforms.map { |p| p.to_s } })"
7
+
8
+ # The rest of this is a normal bundler binstub
9
+ require "pathname"
10
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../../Gemfile",
11
+ Pathname.new(__FILE__).realpath)
12
+
13
+ require "rubygems"
14
+
15
+ load Gem.bin_path("bundler", "bundle")
@@ -0,0 +1,2 @@
1
+ @ECHO OFF
2
+ ruby "%~dpn0" %*
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "rubygems"
4
+ require "bundler"
5
+
6
+ Bundler.with_clean_env do
7
+ require_relative "../gemfile_util"
8
+
9
+ options = {}
10
+ opts = OptionParser.new do |opts|
11
+ opts.banner = "Usage: create-override-gemfile [OPTIONS]"
12
+
13
+ opts.on("--gemfile GEMFILE", "The Gemfile to read (default: Gemfile).") { |path| options[:gemfile_path] = path }
14
+ opts.on("--lockfile GEMFILE", "The lockfile to read (default: <gemfile>.lock).") { |path| options[:lockfile_path] = path }
15
+
16
+ opts.on("--group GROUP", "Groups to include (whitelist).") do |group|
17
+ options[:groups] ||= []
18
+ options[:groups] << group.to_sym
19
+ end
20
+
21
+ opts.on("--without GROUP", "Groups to exclude.") do |group|
22
+ options[:without_groups] ||= []
23
+ options[:without_groups] << group.to_sym
24
+ end
25
+
26
+ opts.on("--gem GEM", "Gems to include regardless of groups.") do |name|
27
+ options[:gems] ||= []
28
+ options[:gems] << name
29
+ end
30
+
31
+ opts.on("--relative-to PATH", "A path to prepend to any relative paths in the Gemfile.") do |path|
32
+ unless Pathname.new(path).absolute?
33
+ puts opts
34
+ raise "--relative-to #{path} was not an absolute path!"
35
+ end
36
+ options[:relative_to] = path
37
+ end
38
+
39
+ opts.on("--[no-]copy-groups", "Whether to copy groups over from the original Gemfile or not (default: false).") { |val| options[:copy_groups] = val }
40
+
41
+ opts.on("--[no-]override", "Whether to emit override: true on each gem line (default: false).") { |val| options[:override] = val }
42
+
43
+ opts.on("-h", "--help", "Print this message.") do
44
+ puts opts
45
+ exit(0)
46
+ end
47
+ end
48
+
49
+ args = opts.parse(ARGV)
50
+
51
+ if args.size > 0
52
+ puts opts
53
+ raise "Invalid arguments #{args}"
54
+ end
55
+
56
+ def create_override_gemfile(gemfile_path: "Gemfile", lockfile_path: "#{gemfile_path}.lock", groups: nil, without_groups: nil, gems: [], copy_groups: false, relative_to: ".", override: false)
57
+ relative_to = Pathname.new(relative_to).realpath
58
+ # Select the gems we want
59
+ bundle = GemfileUtil::Bundle.parse(gemfile_path, lockfile_path)
60
+ gems_to_include = bundle.select_gems(groups: groups, without_groups: without_groups)
61
+ gems.each do |name|
62
+ raise "Requested gem #{name} is not in #{gemfile_path}.lock!" if !bundle.gems[name]
63
+ gems_to_include[name] ||= bundle.gems[name]
64
+ gems_to_include[name][:dependencies].each do |dep|
65
+ gems_to_include[name] ||= bundle.gems[dep]
66
+ end
67
+ end
68
+
69
+ # Add the gems to the Gemfile
70
+ gem_root = Pathname.new(gemfile_path).dirname.realpath
71
+ gems_to_include.sort_by { |name, options| options[:declared_groups].empty? ? 1 : 0 }.each do |name, options|
72
+ comment = nil
73
+ options = options.dup
74
+ version = options.delete(:version)
75
+ if copy_groups
76
+ # Some dependencies have no groups (are not in the Gemfile--just runtime
77
+ # dependencies). If we actually record that they have no groups, they
78
+ # will *always* be installed (or perhaps never). We only want them to
79
+ # install if their other deps do, so we mark them with the groups of the
80
+ # things that brought them in (the gems that depended on them). To do
81
+ # this, we just leave :groups intact.
82
+ if options[:declared_groups].empty?
83
+ options.delete(:declared_groups)
84
+ comment = " # Transitive dependency, not actually in original Gemfile"
85
+ else
86
+ # For other things, we want to copy the actual declared_groups--the
87
+ # ones that were in the Gemfile. We want the same --with and --without
88
+ # options to include and exclude them as worked with the original
89
+ # Gemfile.
90
+ options[:groups] = options.delete(:declared_groups)
91
+ end
92
+ else
93
+ options.delete(:groups)
94
+ options.delete(:declared_groups)
95
+ end
96
+ options.delete(:dependencies)
97
+ options.delete(:development_dependencies)
98
+ options[:override] = true if override
99
+ options[:path] = Pathname.new(options[:path]).expand_path(gem_root).relative_path_from(relative_to).to_s if options[:path]
100
+ line = "gem #{name.inspect}, #{version.inspect}"
101
+ options.each do |name, value|
102
+ line << ", #{name}: #{value.inspect}"
103
+ end
104
+ line << comment if comment
105
+ puts line
106
+ end
107
+ end
108
+
109
+ create_override_gemfile(options)
110
+ end
@@ -0,0 +1,17 @@
1
+ #!/bin/bash
2
+
3
+ # Fail fast (e) and echo commands (vx)
4
+ set -evx
5
+
6
+ echo --color > .rspec
7
+ echo -fp >> .rspec
8
+
9
+ sudo sed -i -e 's/^Defaults\tsecure_path.*$//' /etc/sudoers;
10
+ # If we have any args, just run the given command
11
+ if [ -n "$1" ]; then
12
+ sudo -E $(which bundle) exec $@;
13
+ else
14
+ sudo -E $(which bundle) exec rake spec;
15
+ bundle exec rake style;
16
+ bundle exec bundle-audit check --update;
17
+ fi
@@ -0,0 +1,47 @@
1
+ #!/bin/bash
2
+
3
+ # Fail fast (e) and echo commands (vx)
4
+ set -evx
5
+
6
+ # Arguments
7
+ TEST_GEM=$1
8
+ shift
9
+
10
+ PROJECT_ROOT=$(pwd)
11
+ PROJECT_BUNDLE_PATH=${BUNDLE_PATH:-$(grep BUNDLE_PATH: $PROJECT_ROOT/.bundle/config | cut -d' ' -f2-)}
12
+ if [ -n "$PROJECT_BUNDLE_PATH" ]; then
13
+ PROJECT_BUNDLE_PATH=$PROJECT_ROOT/$PROJECT_BUNDLE_PATH
14
+ fi
15
+
16
+ TEST_GEM_ROOT=$(bundle show $TEST_GEM)
17
+
18
+ # Make a copy of the original Gemfile and stitch in our Gemfile.lock
19
+ TEST_GEMFILE=$TEST_GEM_ROOT/Gemfile
20
+ MODIFIED_TEST_GEMFILE=$TEST_GEMFILE.externaltest
21
+ cat <<EOM > $MODIFIED_TEST_GEMFILE
22
+ require_relative "$PROJECT_ROOT/tasks/gemfile_util"
23
+ GemfileUtil.include_locked_gemfile(self, "$PROJECT_ROOT/Gemfile", gems: ["$TEST_GEM"] + "$TEST_WITH_GEMS".split(/\s+/))
24
+ $TEST_GEM_OVERRIDES
25
+ EOM
26
+ cat $TEST_GEMFILE >> $MODIFIED_TEST_GEMFILE
27
+ if [ -f $TEST_GEMFILE.lock ]; then
28
+ cp $TEST_GEMFILE.lock $MODIFIED_TEST_GEMFILE.lock
29
+ elif [ -f $MODIFIED_TEST_GEMFILE.lock ]; then
30
+ rm -f $MODIFIED_TEST_GEMFILE.lock
31
+ fi
32
+
33
+ # Run the bundle install
34
+ cd $TEST_GEM_ROOT
35
+ export BUNDLE_GEMFILE=$MODIFIED_TEST_GEMFILE
36
+ # Don't read from the project .bundle/config, just our env vars
37
+ export BUNDLE_IGNORE_CONFIG=true
38
+ # Use the top level bundle cache so we don't have to reinstall their packages
39
+ if [ -n "$PROJECT_BUNDLE_PATH" ]; then
40
+ export BUNDLE_PATH=$PROJECT_BUNDLE_PATH
41
+ fi
42
+ export BUNDLE_FROZEN=
43
+ bundle install
44
+ export BUNDLE_FROZEN=true
45
+
46
+ bundle config
47
+ bundle exec $@
@@ -0,0 +1,97 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2016 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_relative "bundle_util"
19
+ require_relative "../version_policy"
20
+ require "fileutils"
21
+
22
+ desc "Tasks to work with the main Gemfile and Gemfile.<platform>"
23
+ namespace :bundle do
24
+ desc "Update Gemfile.lock and all Gemfile.<platform>.locks (or one or more gems via bundle:update gem1 gem2 ...)."
25
+ task :update, [:args] do |t, rake_args|
26
+ extend BundleUtil
27
+ args = rake_args[:args] || ""
28
+ with_bundle_unfrozen do
29
+ puts ""
30
+ puts "-------------------------------------------------------------------"
31
+ puts "Updating Gemfile.lock ..."
32
+ puts "-------------------------------------------------------------------"
33
+ bundle "install #{args}", delete_gemfile_lock: true
34
+ platforms.each do |platform|
35
+ bundle "lock", platform: platform
36
+ end
37
+ end
38
+ end
39
+
40
+ desc "Conservatively update Gemfile.lock and all Gemfile.<platform>.locks"
41
+ task :install, [:args] do |t, rake_args|
42
+ extend BundleUtil
43
+ args = rake_args[:args] || ""
44
+ with_bundle_unfrozen do
45
+ puts ""
46
+ puts "-------------------------------------------------------------------"
47
+ puts "Updating Gemfile.lock ..."
48
+ puts "-------------------------------------------------------------------"
49
+ bundle "install #{args}"
50
+ platforms.each do |platform|
51
+ bundle "lock", platform: platform
52
+ end
53
+ end
54
+ end
55
+
56
+ # Find out if we're using the latest gems we can (so we don't regress versions)
57
+ desc "Check for gems that are not at the latest released version, and report if anything not in ACCEPTABLE_OUTDATED_GEMS (version_policy.rb) is out of date."
58
+ task :outdated do
59
+ extend BundleUtil
60
+ puts ""
61
+ puts "-------------------------------------------------------------------"
62
+ puts "Checking for outdated gems ..."
63
+ puts "-------------------------------------------------------------------"
64
+ # TODO check for outdated windows gems too
65
+ with_bundle_unfrozen do
66
+ bundle_outdated = bundle("outdated", extract_output: true)
67
+ puts bundle_outdated
68
+ outdated_gems = parse_bundle_outdated(bundle_outdated).map { |line, gem_name| gem_name }
69
+ # Weed out the acceptable ones
70
+ outdated_gems = outdated_gems.reject { |gem_name| ACCEPTABLE_OUTDATED_GEMS.include?(gem_name) }
71
+ if outdated_gems.empty?
72
+ puts ""
73
+ puts "SUCCESS!"
74
+ else
75
+ raise "ERROR: outdated gems: #{outdated_gems.join(", ")}. Either fix them or add them to ACCEPTABLE_OUTDATED_GEMS in #{__FILE__}."
76
+ end
77
+ end
78
+ end
79
+ end
80
+
81
+ desc "Run bundle with arbitrary args against the given platform; e.g. rake bundle[show]. No platform to run against the main bundle; bundle[show,windows] to run the windows one; bundle[show,*] to run against all non-default platforms."
82
+ task :bundle, [:args, :platform] do |t, rake_args|
83
+ extend BundleUtil
84
+ args = rake_args[:args] || ""
85
+ platform = rake_args[:platform]
86
+ with_bundle_unfrozen do
87
+ if platform == "*"
88
+ platforms.each do |platform|
89
+ bundle args, platform: platform
90
+ end
91
+ elsif platform
92
+ bundle args, platform: platform
93
+ else
94
+ bundle args
95
+ end
96
+ end
97
+ end
@@ -0,0 +1,94 @@
1
+ require "bundler"
2
+ require "shellwords"
3
+
4
+ module BundleUtil
5
+ PLATFORMS = { "windows" => %w{ruby x86-mingw32} }
6
+
7
+ def project_root
8
+ File.expand_path("../..", __FILE__)
9
+ end
10
+
11
+ def bundle_platform
12
+ File.join(project_root, "tasks", "bin", "bundle-platform")
13
+ end
14
+
15
+ # Parse the output of "bundle outdated" and get the list of gems that
16
+ # were outdated
17
+ def parse_bundle_outdated(bundle_outdated_output)
18
+ result = []
19
+ bundle_outdated_output.each_line do |line|
20
+ if line =~ /^\s*\* (.+) \(newest ([^,]+), installed ([^,)])*/
21
+ gem_name, newest_version, installed_version = $1, $2, $3
22
+ result << [ line, gem_name ]
23
+ end
24
+ end
25
+ result
26
+ end
27
+
28
+ def with_bundle_unfrozen(cwd: nil, leave_frozen: false)
29
+ bundle "config --delete frozen", cwd: cwd
30
+ begin
31
+ yield
32
+ ensure
33
+ bundle "config --local frozen 1", cwd: cwd unless leave_frozen
34
+ end
35
+ end
36
+
37
+ # Run bundle-platform with the given ruby platform(s)
38
+ def bundle(args, gemfile: nil, platform: nil, cwd: nil, extract_output: false, delete_gemfile_lock: false)
39
+ args = args.split(/\s+/)
40
+ if cwd
41
+ prefix = "[#{cwd}] "
42
+ end
43
+ cwd = File.expand_path(cwd || ".", project_root)
44
+ Bundler.with_clean_env do
45
+ Dir.chdir(cwd) do
46
+ gemfile ||= "Gemfile"
47
+ gemfile = File.expand_path(gemfile, cwd)
48
+ raise "No platform #{platform} (supported: #{PLATFORMS.keys.join(", ")})" if platform && !PLATFORMS[platform]
49
+
50
+ # First delete the gemfile.lock
51
+ if delete_gemfile_lock
52
+ if File.exist?("#{gemfile}.lock")
53
+ puts "Deleting #{gemfile}.lock ..."
54
+ File.delete("#{gemfile}.lock")
55
+ end
56
+ end
57
+
58
+ # Run the bundle command
59
+ ruby_platforms = platform ? PLATFORMS[platform].join(" ") : "ruby"
60
+ cmd = Shellwords.join([Gem.ruby, "-S", bundle_platform, ruby_platforms, *args])
61
+ puts "#{prefix}#{Shellwords.join(["bundle", *args])}#{platform ? " for #{platform} platform" : ""}:"
62
+ with_gemfile(gemfile) do
63
+ puts "#{prefix}BUNDLE_GEMFILE=#{gemfile}"
64
+ puts "#{prefix}> #{cmd}"
65
+ if extract_output
66
+ `#{cmd}`
67
+ else
68
+ unless system(bundle_platform, ruby_platforms, *args)
69
+ raise "#{bundle_platform} failed: exit code #{$?}"
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+
77
+ def with_gemfile(gemfile)
78
+ old_gemfile = ENV["BUNDLE_GEMFILE"]
79
+ ENV["BUNDLE_GEMFILE"] = gemfile
80
+ begin
81
+ yield
82
+ ensure
83
+ if old_gemfile
84
+ ENV["BUNDLE_GEMFILE"] = old_gemfile
85
+ else
86
+ ENV.delete("BUNDLE_GEMFILE")
87
+ end
88
+ end
89
+ end
90
+
91
+ def platforms
92
+ PLATFORMS.keys
93
+ end
94
+ end
@@ -0,0 +1,12 @@
1
+ begin
2
+ require "github_changelog_generator/task"
3
+
4
+ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
5
+ config.future_release = Chef::VERSION
6
+ config.enhancement_labels = "enhancement,Enhancement,New Feature,Feature".split(",")
7
+ config.bug_labels = "bug,Bug,Improvement,Upstream Bug".split(",")
8
+ config.exclude_labels = "duplicate,question,invalid,wontfix,no_changelog,Exclude From Changelog,Question,Discussion".split(",")
9
+ end
10
+ rescue LoadError
11
+ puts "github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs"
12
+ end
@@ -0,0 +1,147 @@
1
+ #
2
+ # Copyright:: Copyright (c) 2016 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_relative "bundle_util"
19
+ require_relative "bundle"
20
+ require_relative "../version_policy"
21
+
22
+ desc "Tasks to update and check dependencies"
23
+ namespace :dependencies do
24
+ # Update all dependencies to the latest constraint-matching version
25
+ desc "Update all dependencies. dependencies:update[conservative] to update as little as possible."
26
+ task :update, [:conservative] => %w{
27
+ dependencies:update_gemfile_lock
28
+ dependencies:update_omnibus_overrides
29
+ dependencies:update_omnibus_gemfile_lock
30
+ dependencies:update_acceptance_gemfile_lock
31
+ dependencies:update_kitchen_tests_gemfile_lock
32
+ dependencies:update_kitchen_tests_berksfile_lock
33
+ }
34
+
35
+ desc "Update Gemfile.lock and all Gemfile.<platform>.locks. update_gemfile_lock[conservative] to update as little as possible."
36
+ task :update_gemfile_lock, [:conservative] do |t, rake_args|
37
+ conservative = rake_args[:conservative]
38
+ if conservative
39
+ Rake::Task["bundle:install"].invoke
40
+ else
41
+ Rake::Task["bundle:update"].invoke
42
+ end
43
+ end
44
+
45
+ def gemfile_lock_task(task_name, dirs: [], other_platforms: true, leave_frozen: true)
46
+ dirs.each do |dir|
47
+ desc "Update #{dir}/Gemfile.lock. #{task_name}[conservative] to update as little as possible."
48
+ task task_name, [:conservative] do |t, rake_args|
49
+ extend BundleUtil
50
+ conservative = rake_args[:conservative]
51
+ puts ""
52
+ puts "-------------------------------------------------------------------"
53
+ puts "Updating #{dir}/Gemfile.lock#{conservative ? " (conservatively)" : ""} ..."
54
+ puts "-------------------------------------------------------------------"
55
+ with_bundle_unfrozen(cwd: dir, leave_frozen: leave_frozen) do
56
+ bundle "install", cwd: dir, delete_gemfile_lock: !conservative
57
+ if other_platforms
58
+ # Include all other supported platforms into the lockfile as well
59
+ platforms.each do |platform|
60
+ bundle "lock", cwd: dir, platform: platform
61
+ end
62
+ end
63
+ end
64
+ end
65
+ end
66
+ end
67
+
68
+ def berksfile_lock_task(task_name, dirs: [])
69
+ dirs.each do |dir|
70
+ desc "Update #{dir}/Berksfile.lock. #{task_name}[conservative] to update as little as possible."
71
+ task task_name, [:conservative] do |t, rake_args|
72
+ extend BundleUtil
73
+ conservative = rake_args[:conservative]
74
+ puts ""
75
+ puts "-------------------------------------------------------------------"
76
+ puts "Updating #{dir}/Berksfile.lock#{conservative ? " (conservatively)" : ""} ..."
77
+ puts "-------------------------------------------------------------------"
78
+ if !conservative && File.exist?("#{project_root}/#{dir}/Berksfile.lock")
79
+ File.delete("#{project_root}/#{dir}/Berksfile.lock")
80
+ end
81
+ Dir.chdir("#{project_root}/#{dir}") do
82
+ Bundler.with_clean_env do
83
+ sh "bundle exec berks install"
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+
90
+ gemfile_lock_task :update_omnibus_gemfile_lock, dirs: %w{omnibus}
91
+ gemfile_lock_task :update_acceptance_gemfile_lock, dirs: %w{acceptance},
92
+ other_platforms: false, leave_frozen: false
93
+ gemfile_lock_task :update_kitchen_tests_gemfile_lock, dirs: %w{
94
+ kitchen-tests
95
+ kitchen-tests/test/integration/webapp/serverspec
96
+ }
97
+ berksfile_lock_task :update_kitchen_tests_berksfile_lock, dirs: %w{
98
+ kitchen-tests
99
+ kitchen-tests/cookbooks/audit_test
100
+ }
101
+ # kitchen-tests/cookbooks/webapp isn't solving right now ....
102
+
103
+ desc "Update omnibus overrides, including versions in version_policy.rb and latest version of gems: #{OMNIBUS_RUBYGEMS_AT_LATEST_VERSION.keys}. update_omnibus_overrides[conservative] does nothing."
104
+ task :update_omnibus_overrides, [:conservative] do |t, rake_args|
105
+ conservative = rake_args[:conservative]
106
+ unless conservative
107
+ puts ""
108
+ puts "-------------------------------------------------------------------"
109
+ puts "Updating omnibus_overrides.rb ..."
110
+ puts "-------------------------------------------------------------------"
111
+
112
+ # Generate the new overrides file
113
+ overrides = "# DO NOT EDIT. Generated by \"rake dependencies\". Edit version_policy.rb instead.\n"
114
+
115
+ # Replace the bundler and rubygems versions
116
+ OMNIBUS_RUBYGEMS_AT_LATEST_VERSION.each do |override_name, gem_name|
117
+ # Get the latest bundler version
118
+ puts "Running gem list -r #{gem_name} ..."
119
+ gem_list = `gem list -r #{gem_name}`
120
+ unless gem_list =~ /^#{gem_name}\s*\(([^)]*)\)$/
121
+ raise "gem list -r #{gem_name} failed with output:\n#{gem_list}"
122
+ end
123
+
124
+ # Emit it
125
+ puts "Latest version of #{gem_name} is #{$1}"
126
+ overrides << "override #{override_name.inspect}, version: #{$1.inspect}\n"
127
+ end
128
+
129
+ # Add explicit overrides
130
+ OMNIBUS_OVERRIDES.each do |override_name, version|
131
+ overrides << "override #{override_name.inspect}, version: #{version.inspect}\n"
132
+ end
133
+
134
+ # Write the file out (if changed)
135
+ overrides_path = File.expand_path("../../omnibus_overrides.rb", __FILE__)
136
+ if overrides != IO.read(overrides_path)
137
+ puts "Overrides changed!"
138
+ puts `git diff #{overrides_path}`
139
+ puts "Writing modified #{overrides_path} ..."
140
+ IO.write(overrides_path, overrides)
141
+ end
142
+ end
143
+ end
144
+ end
145
+ desc "Update all dependencies and check for outdated gems. Call dependencies[conservative] to update as little as possible."
146
+ task :dependencies, [:conservative] => [ "dependencies:update", "bundle:outdated" ]
147
+ task :update, [:conservative] => [ "dependencies:update", "bundle:outdated"]