diff options
author | Thom May <thom@may.lt> | 2017-03-21 13:51:26 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-03-21 13:51:26 +0000 |
commit | 0b1668d28e7c70b11e8c4a299d01e323056a740a (patch) | |
tree | 3dc6f908a1a2344ad50d31c0fceeca8c23d831f1 | |
parent | ecb4139243a08c0c92efc628a3a0ccb1eb12bc8a (diff) | |
parent | 36779b5199334cfac56ac56c35862c9552897373 (diff) | |
download | chef-0b1668d28e7c70b11e8c4a299d01e323056a740a.tar.gz |
Merge branch 'master' into query-sort
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | Gemfile.lock | 10 | ||||
-rw-r--r-- | RELEASE_NOTES.md | 4 | ||||
-rw-r--r-- | VERSION | 2 | ||||
-rw-r--r-- | acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb | 2 | ||||
-rw-r--r-- | acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb | 17 | ||||
-rw-r--r-- | chef-config/lib/chef-config/version.rb | 2 | ||||
-rw-r--r-- | lib/chef.rb | 3 | ||||
-rw-r--r-- | lib/chef/node_map.rb | 7 | ||||
-rw-r--r-- | lib/chef/provider/service/solaris.rb | 6 | ||||
-rw-r--r-- | lib/chef/resource/service.rb | 10 | ||||
-rw-r--r-- | lib/chef/run_context.rb | 23 | ||||
-rw-r--r-- | lib/chef/shell.rb | 8 | ||||
-rw-r--r-- | lib/chef/shell_out.rb | 13 | ||||
-rw-r--r-- | lib/chef/util/windows/net_user.rb | 2 | ||||
-rw-r--r-- | lib/chef/version.rb | 2 | ||||
-rw-r--r-- | lib/chef/win32/security/sid.rb | 5 | ||||
-rw-r--r-- | spec/unit/node_map_spec.rb | 24 | ||||
-rw-r--r-- | spec/unit/provider/service/solaris_smf_service_spec.rb | 38 | ||||
-rw-r--r-- | spec/unit/resource/service_spec.rb | 22 | ||||
-rw-r--r-- | spec/unit/shell_out_spec.rb | 18 |
21 files changed, 112 insertions, 110 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 253d8fd854..997abd0b0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ This changelog reflects the current state of chef's master branch on github and may not reflect the current released version of chef, which is [![Gem Version](https://badge.fury.io/rb/chef.svg)](https://badge.fury.io/rb/chef). -## [v13.0.54](https://github.com/chef/chef/tree/v13.0.54) (2017-03-20) -[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.54) +## [v13.0.58](https://github.com/chef/chef/tree/v13.0.58) (2017-03-21) +[Full Changelog](https://github.com/chef/chef/compare/v12.19.36...v13.0.58) **Closed issues:** diff --git a/Gemfile.lock b/Gemfile.lock index ba61db2c34..c5a0d2eca0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -113,10 +113,10 @@ GIT PATH remote: . specs: - chef (13.0.55) + chef (13.0.59) addressable bundler (>= 1.10) - chef-config (= 13.0.55) + chef-config (= 13.0.59) chef-zero (>= 4.8) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -142,10 +142,10 @@ PATH specinfra (~> 2.10) syslog-logger (~> 1.6) uuidtools (~> 2.1.5) - chef (13.0.55-universal-mingw32) + chef (13.0.59-universal-mingw32) addressable bundler (>= 1.10) - chef-config (= 13.0.55) + chef-config (= 13.0.59) chef-zero (>= 4.8) diff-lcs (~> 1.2, >= 1.2.4) erubis (~> 2.7) @@ -186,7 +186,7 @@ PATH PATH remote: chef-config specs: - chef-config (13.0.55) + chef-config (13.0.59) addressable fuzzyurl mixlib-config (~> 2.0) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index dfae712000..6c35ae9354 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -113,3 +113,7 @@ The deprecated code has been removed. All providers and resources should now be ### Remove `sort` option for the Search API This option has been unimplemented on the server side for years, so any use of it has been pointless. + +### Remove Chef::ShellOut + +This was deprecated and replaced a long time ago with mixlib-shellout and the shell_out mixin. @@ -1 +1 @@ -13.0.55
\ No newline at end of file +13.0.59
\ No newline at end of file diff --git a/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb b/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb index dd0e0e4e34..7bdb4e4ed3 100644 --- a/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb +++ b/acceptance/basics/test/integration/chef-current-install/serverspec/chef_client_spec.rb @@ -2,7 +2,7 @@ require "spec_helper" gem_path = "/opt/chef/embedded/bin/gem" -white_list = %w{chef-config json rake} +white_list = %w{addressable chef-config json rake} describe "gem list" do it "should not have non-whitelisted duplicate gems" do diff --git a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb index 73f5151bca..5716b97737 100644 --- a/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb +++ b/acceptance/top-cookbooks/.acceptance/acceptance-cookbook/libraries/top_cookbooks.rb @@ -12,15 +12,16 @@ class TopCookbooks < Chef::Resource cookbook_kitchen "#{command} git" do end - cookbook_kitchen "#{command} learn-the-basics-ubuntu" do - repository "learn-chef/learn-chef-acceptance" - cookbook_relative_dir "cookbooks/learn-the-basics-ubuntu" - end + # FIXME: waiting for https://github.com/learn-chef/learn-chef-acceptance/pull/23 + # cookbook_kitchen "#{command} learn-the-basics-ubuntu" do + # repository "learn-chef/learn-chef-acceptance" + # cookbook_relative_dir "cookbooks/learn-the-basics-ubuntu" + # end - cookbook_kitchen "#{command} learn-the-basics-windows" do - repository "learn-chef/learn-chef-acceptance" - cookbook_relative_dir "cookbooks/learn-the-basics-windows" - end + # cookbook_kitchen "#{command} learn-the-basics-windows" do + # repository "learn-chef/learn-chef-acceptance" + # cookbook_relative_dir "cookbooks/learn-the-basics-windows" + # end cookbook_kitchen "#{command} powershell" do end diff --git a/chef-config/lib/chef-config/version.rb b/chef-config/lib/chef-config/version.rb index ea7797e2ea..27b3e41ca3 100644 --- a/chef-config/lib/chef-config/version.rb +++ b/chef-config/lib/chef-config/version.rb @@ -21,7 +21,7 @@ module ChefConfig CHEFCONFIG_ROOT = File.expand_path("../..", __FILE__) - VERSION = "13.0.55" + VERSION = "13.0.59" end # diff --git a/lib/chef.rb b/lib/chef.rb index 3e161dc365..3d6b783253 100644 --- a/lib/chef.rb +++ b/lib/chef.rb @@ -1,6 +1,6 @@ # # Author:: Adam Jacob (<adam@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,7 +24,6 @@ require "chef/log" require "chef/config" require "chef/providers" require "chef/resources" -require "chef/shell_out" require "chef/daemon" diff --git a/lib/chef/node_map.rb b/lib/chef/node_map.rb index 552c90b8d1..7a1a09ae24 100644 --- a/lib/chef/node_map.rb +++ b/lib/chef/node_map.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -31,10 +31,7 @@ class Chef # # @return [NodeMap] Returns self for possible chaining # - def set(key, value, platform: nil, platform_version: nil, platform_family: nil, os: nil, on_platform: nil, on_platforms: nil, canonical: nil, override: nil, &block) - Chef.deprecated(:internal_api, "The on_platform option to node_map has been deprecated") if on_platform - Chef.deprecated(:internal_api, "The on_platforms option to node_map has been deprecated") if on_platforms - platform ||= on_platform || on_platforms + def set(key, value, platform: nil, platform_version: nil, platform_family: nil, os: nil, canonical: nil, override: nil, &block) filters = {} filters[:platform] = platform if platform filters[:platform_version] = platform_version if platform_version diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb index f7f8eaf31b..c560bed011 100644 --- a/lib/chef/provider/service/solaris.rb +++ b/lib/chef/provider/service/solaris.rb @@ -56,11 +56,13 @@ class Chef def enable_service shell_out!(default_init_command, "clear", @new_resource.service_name) if @maintenance - shell_out!(default_init_command, "enable", "-s", @new_resource.service_name) + enable_flags = [ "-s", @new_resource.options ].flatten.compact + shell_out!(default_init_command, "enable", *enable_flags, @new_resource.service_name) end def disable_service - shell_out!(default_init_command, "disable", "-s", @new_resource.service_name) + disable_flags = [ "-s", @new_resource.options ].flatten.compact + shell_out!(default_init_command, "disable", *disable_flags, @new_resource.service_name) end alias_method :stop_service, :disable_service diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb index d9f0969ecb..0231964fdf 100644 --- a/lib/chef/resource/service.rb +++ b/lib/chef/resource/service.rb @@ -18,6 +18,7 @@ # require "chef/resource" +require "shellwords" class Chef class Resource @@ -40,6 +41,7 @@ class Chef @enabled = nil @running = nil @masked = nil + @options = nil @parameters = nil @pattern = service_name @start_command = nil @@ -155,6 +157,14 @@ class Chef ) end + def options(arg = nil) + set_or_return( + :options, + arg.respond_to?(:split) ? arg.shellsplit : arg, + :kind_of => [ Array, String ] + ) + end + # Priority arguments can have two forms: # # - a simple number, in which the default start runlevels get diff --git a/lib/chef/run_context.rb b/lib/chef/run_context.rb index 6d84b7773d..a606585e80 100644 --- a/lib/chef/run_context.rb +++ b/lib/chef/run_context.rb @@ -2,7 +2,7 @@ # Author:: Adam Jacob (<adam@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) # Author:: Tim Hinderliter (<tim@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -576,27 +576,6 @@ ERROR_MESSAGE attr_reader :loaded_attributes_hash attr_reader :loaded_recipes_hash - module Deprecated - ### - # These need to be settable so deploy can run a resource_collection - # independent of any cookbooks via +recipe_eval+ - def audits=(value) - Chef.deprecated(:internal_api, "Setting run_context.audits will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.") - @audits = value - end - - def immediate_notification_collection=(value) - Chef.deprecated(:internal_api, "Setting run_context.immediate_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.") - @immediate_notification_collection = value - end - - def delayed_notification_collection=(value) - Chef.deprecated(:internal_api, "Setting run_context.delayed_notification_collection will be removed in a future Chef. Use run_context.create_child to create a new RunContext instead.") - @delayed_notification_collection = value - end - end - prepend Deprecated - # # A child run context. Delegates all root context calls to its parent. # diff --git a/lib/chef/shell.rb b/lib/chef/shell.rb index 6d6d1437e2..b4c0277c57 100644 --- a/lib/chef/shell.rb +++ b/lib/chef/shell.rb @@ -211,8 +211,10 @@ module Shell When no CONFIG is specified, chef-shell attempts to load a default configuration file: * If a NAMED_CONF is given, chef-shell will load ~/.chef/NAMED_CONF/chef_shell.rb * If no NAMED_CONF is given chef-shell will load ~/.chef/chef_shell.rb if it exists -* chef-shell falls back to loading /etc/chef/client.rb or /etc/chef/solo.rb if -z or - -s options are given and no chef_shell.rb can be found. +* If no chef_shell.rb can be found, chef-shell falls back to load: + /etc/chef/client.rb if -z option is given. + /etc/chef/solo.rb if --solo-legacy-mode option is given. + .chef/knife.rb if -s option is given. FOOTER option :config_file, @@ -338,7 +340,7 @@ FOOTER Chef::Config.platform_specific_path("/etc/chef/solo.rb") elsif config[:client] Chef::Config.platform_specific_path("/etc/chef/client.rb") - elsif config[:solo] + elsif config[:solo_shell] Chef::WorkstationConfigLoader.new(nil, Chef::Log).config_location else nil diff --git a/lib/chef/shell_out.rb b/lib/chef/shell_out.rb deleted file mode 100644 index 54ff718e8e..0000000000 --- a/lib/chef/shell_out.rb +++ /dev/null @@ -1,13 +0,0 @@ -require "mixlib/shellout" - -class Chef - class ShellOut < Mixlib::ShellOut - - def initialize(*args) - Chef::Log.warn("Chef::ShellOut is deprecated, please use Mixlib::ShellOut") - called_from = caller[0..3].inject("Called from:\n") { |msg, trace_line| msg << " #{trace_line}\n" } - Chef::Log.warn(called_from) - super - end - end -end diff --git a/lib/chef/util/windows/net_user.rb b/lib/chef/util/windows/net_user.rb index f9f8f011af..059a04d59a 100644 --- a/lib/chef/util/windows/net_user.rb +++ b/lib/chef/util/windows/net_user.rb @@ -112,7 +112,7 @@ class Chef::Util::Windows::NetUser < Chef::Util::Windows def add(args) transformed_args = transform_usri3(args) NetUser.net_user_add_l3(nil, transformed_args) - NetUser.net_local_group_add_member(nil, "Users", args[:name]) + NetUser.net_local_group_add_member(nil, Chef::ReservedNames::Win32::Security::SID.BuiltinUsers.account_simple_name, args[:name]) end # FIXME: yard with @yield diff --git a/lib/chef/version.rb b/lib/chef/version.rb index 68951d1ac7..a8e341ef7f 100644 --- a/lib/chef/version.rb +++ b/lib/chef/version.rb @@ -21,7 +21,7 @@ class Chef CHEF_ROOT = File.expand_path("../..", __FILE__) - VERSION = "13.0.55" + VERSION = "13.0.59" end # diff --git a/lib/chef/win32/security/sid.rb b/lib/chef/win32/security/sid.rb index 983166ac70..c77616853c 100644 --- a/lib/chef/win32/security/sid.rb +++ b/lib/chef/win32/security/sid.rb @@ -59,6 +59,11 @@ class Chef Chef::ReservedNames::Win32::Security.lookup_account_sid(self) end + def account_simple_name + domain, name, use = account + name + end + def account_name domain, name, use = account (!domain.nil? && domain.length > 0) ? "#{domain}\\#{name}" : name diff --git a/spec/unit/node_map_spec.rb b/spec/unit/node_map_spec.rb index 0480a721af..822f689eab 100644 --- a/spec/unit/node_map_spec.rb +++ b/spec/unit/node_map_spec.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2014-2016, Chef Software, Inc. +# Copyright:: Copyright 2014-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -145,26 +145,4 @@ describe Chef::NodeMap do end end - describe "resource back-compat testing" do - before :each do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - end - - it "should handle :on_platforms => :all" do - node_map.set(:chef_gem, :foo, :on_platforms => :all) - allow(node).to receive(:[]).with(:platform).and_return("windows") - expect(node_map.get(node, :chef_gem)).to eql(:foo) - end - it "should handle :on_platforms => [ 'windows' ]" do - node_map.set(:dsc_script, :foo, :on_platforms => [ "windows" ]) - allow(node).to receive(:[]).with(:platform).and_return("windows") - expect(node_map.get(node, :dsc_script)).to eql(:foo) - end - it "should handle :on_platform => :all" do - node_map.set(:link, :foo, :on_platform => :all) - allow(node).to receive(:[]).with(:platform).and_return("windows") - expect(node_map.get(node, :link)).to eql(:foo) - end - end - end diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index c6835bed64..584176b944 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_spec.rb @@ -198,6 +198,33 @@ describe Chef::Provider::Service::Solaris do end end + describe "when enabling the service recursively" do + before(:each) do + @provider.current_resource = @current_resource + end + + it "should call svcadm enable -s -r chef" do + @new_resource.options("-r") + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) + expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", @current_resource.service_name).and_return(@success) + @provider.load_current_resource + expect(@provider.enable_service).to be_truthy + expect(@current_resource.enabled).to be_truthy + end + + it "should call svcadm enable -s -r -t chef when passed an array of options" do + @new_resource.options(["-r", "-t"]) + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@enabled_svc_status) + expect(@provider).not_to receive(:shell_out!).with("/usr/sbin/svcadm", "clear", @current_resource.service_name) + expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "enable", "-s", "-r", "-t", @current_resource.service_name).and_return(@success) + @provider.load_current_resource + expect(@provider.enable_service).to be_truthy + expect(@current_resource.enabled).to be_truthy + end + + end + describe "when disabling the service" do before(:each) do @provider.current_resource = @current_resource @@ -215,7 +242,16 @@ describe Chef::Provider::Service::Solaris do expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "chef").and_return(@success) @provider.load_current_resource - expect(@provider.stop_service).to be_truthy + expect(@provider.disable_service).to be_truthy + expect(@current_resource.enabled).to be_falsey + end + + it "should call svcadm disable chef with options" do + @new_resource.options("-t") + expect(@provider).to receive(:shell_out!).with("/bin/svcs", "-l", "chef", { :returns => [0, 1] }).and_return(@disabled_svc_status) + expect(@provider).to receive(:shell_out!).with("/usr/sbin/svcadm", "disable", "-s", "-t", "chef").and_return(@success) + @provider.load_current_resource + expect(@provider.disable_service).to be_truthy expect(@current_resource.enabled).to be_falsey end diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index 205282b99f..67a4635983 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -124,6 +124,27 @@ describe Chef::Resource::Service do end.to raise_error(ArgumentError) end + it "should accept an array for options" do + @resource.options ["-r", "-s"] + expect(@resource.options).to eql(["-r", "-s"]) + end + + it "should accept a string for options" do + @resource.options "-r" + expect(@resource.options).to eql(["-r"]) + end + + it "should accept a string with multiple flags for options" do + @resource.options "-r -s" + expect(@resource.options).to eql(["-r", "-s"]) + end + + it "should not accept a boolean for options" do + expect do + @resource.options true + end.to raise_error(ArgumentError) + end + %w{enabled running}.each do |attrib| it "should accept true for #{attrib}" do @resource.send(attrib, true) @@ -175,5 +196,4 @@ describe Chef::Resource::Service do expect(@resource.identity).to eq("superfriend") end end - end diff --git a/spec/unit/shell_out_spec.rb b/spec/unit/shell_out_spec.rb deleted file mode 100644 index 35844f4961..0000000000 --- a/spec/unit/shell_out_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -require File.expand_path("../../spec_helper", __FILE__) - -describe "Chef::ShellOut deprecation notices" do - it "logs a warning when initializing a new Chef::ShellOut object" do - expect(Chef::Log).to receive(:warn).with("Chef::ShellOut is deprecated, please use Mixlib::ShellOut") - expect(Chef::Log).to receive(:warn).with(/Called from\:/) - Chef::ShellOut.new("pwd") - end -end - -describe "Chef::Exceptions::ShellCommandFailed deprecation notices" do - - it "logs a warning when referencing the constant Chef::Exceptions::ShellCommandFailed" do - expect(Chef::Log).to receive(:warn).with("Chef::Exceptions::ShellCommandFailed is deprecated, use Mixlib::ShellOut::ShellCommandFailed") - expect(Chef::Log).to receive(:warn).with(/Called from\:/) - Chef::Exceptions::ShellCommandFailed - end -end |