summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2017-03-31 13:57:07 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2017-03-31 13:57:07 -0700
commit9c0a6a3775314872c8d3b9c914ba56bbda6c8e1b (patch)
treee2c26673b936dde27eb5fe3890111315a3ebc3b2
parent5dacd74ce5cccc4dbb651a45f9e591dd1921cc6e (diff)
downloadchef-9c0a6a3775314872c8d3b9c914ba56bbda6c8e1b.tar.gz
Chef-13: remove deprecated run_command API entirely
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r--lib/chef/mixin/command.rb194
-rw-r--r--lib/chef/mixins.rb1
-rw-r--r--lib/chef/provider/cron.rb2
-rw-r--r--lib/chef/provider/deploy.rb2
-rw-r--r--lib/chef/provider/env.rb2
-rw-r--r--lib/chef/provider/erl_call.rb2
-rw-r--r--lib/chef/provider/group.rb2
-rw-r--r--lib/chef/provider/ifconfig.rb2
-rw-r--r--lib/chef/provider/osx_profile.rb1
-rw-r--r--lib/chef/provider/package.rb2
-rw-r--r--lib/chef/provider/package/aix.rb1
-rw-r--r--lib/chef/provider/package/ips.rb1
-rw-r--r--lib/chef/provider/package/pacman.rb1
-rw-r--r--lib/chef/provider/package/portage.rb1
-rw-r--r--lib/chef/provider/package/rpm.rb1
-rw-r--r--lib/chef/provider/package/rubygems.rb1
-rw-r--r--lib/chef/provider/package/solaris.rb1
-rw-r--r--lib/chef/provider/route.rb2
-rw-r--r--lib/chef/provider/service.rb3
-rw-r--r--lib/chef/provider/service/freebsd.rb1
-rw-r--r--lib/chef/provider/service/gentoo.rb1
-rw-r--r--lib/chef/provider/service/init.rb1
-rw-r--r--lib/chef/provider/service/openbsd.rb1
-rw-r--r--lib/chef/provider/service/simple.rb1
-rw-r--r--lib/chef/provider/service/solaris.rb1
-rw-r--r--lib/chef/provider/service/upstart.rb1
-rw-r--r--lib/chef/provider/subversion.rb2
-rw-r--r--lib/chef/provider/user.rb2
28 files changed, 0 insertions, 233 deletions
diff --git a/lib/chef/mixin/command.rb b/lib/chef/mixin/command.rb
deleted file mode 100644
index b1fa7ebd89..0000000000
--- a/lib/chef/mixin/command.rb
+++ /dev/null
@@ -1,194 +0,0 @@
-#
-# Author:: Adam Jacob (<adam@chef.io>)
-# Copyright:: Copyright 2008-2016, Chef Software Inc.
-# License:: Apache License, Version 2.0
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-require "chef/log"
-require "chef/exceptions"
-require "tmpdir"
-require "fcntl"
-require "etc"
-
-class Chef
- module Mixin
-
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- # NOTE:
- # The popen4 method upon which all the code here is based has a race
- # condition where it may fail to read all of the data written to stdout and
- # stderr after the child process exits. The tests for the code here
- # occasionally fail because of this race condition, so they have been
- # tagged "volatile".
- #
- # This code is considered deprecated, so it should not need to be modified
- # frequently, if at all. HOWEVER, if you do modify the code here, you must
- # explicitly enable volatile tests:
- #
- # bundle exec rspec spec/unit/mixin/command_spec.rb -t volatile
- #
- # In addition, you should make a note that tests need to be run with
- # volatile tests enabled on any pull request or bug report you submit with
- # your patch.
- #!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
- module Command
- extend self
-
- # NOTE: run_command is deprecated in favor of using Chef::Shellout which now comes from the mixlib-shellout gem. NOTE #
-
- if RUBY_PLATFORM =~ /mswin|mingw32|windows/
- require "chef/mixin/command/windows"
- include ::Chef::Mixin::Command::Windows
- extend ::Chef::Mixin::Command::Windows
- else
- require "chef/mixin/command/unix"
- include ::Chef::Mixin::Command::Unix
- extend ::Chef::Mixin::Command::Unix
- end
-
- # === Parameters
- # args<Hash>: A number of required and optional arguments
- # command<String>, <Array>: A complete command with options to execute or a command and options as an Array
- # creates<String>: The absolute path to a file that prevents the command from running if it exists
- # cwd<String>: Working directory to execute command in, defaults to Dir.tmpdir
- # timeout<String>: How many seconds to wait for the command to execute before timing out
- # returns<String>: The single exit value command is expected to return, otherwise causes an exception
- # ignore_failure<Boolean>: Whether to raise an exception on failure, or just return the status
- # output_on_failure<Boolean>: Return output in raised exception regardless of Log.level
- #
- # user<String>: The UID or user name of the user to execute the command as
- # group<String>: The GID or group name of the group to execute the command as
- # environment<Hash>: Pairs of environment variable names and their values to set before execution
- #
- # === Returns
- # Returns the exit status of args[:command]
- def run_command(args = {})
- status, stdout, stderr = run_command_and_return_stdout_stderr(args)
-
- status
- end
-
- # works same as above, except that it returns stdout and stderr
- # requirement => platforms like solaris 9,10 has weird issues where
- # even in command failure the exit code is zero, so we need to lookup stderr.
- def run_command_and_return_stdout_stderr(args = {})
- command_output = ""
-
- args[:ignore_failure] ||= false
- args[:output_on_failure] ||= false
-
- # TODO: This is the wrong place for this responsibility.
- if args.has_key?(:creates)
- if File.exists?(args[:creates])
- Chef::Log.debug("Skipping #{args[:command]} - creates #{args[:creates]} exists.")
- return false
- end
- end
-
- status, stdout, stderr = output_of_command(args[:command], args)
- command_output << "STDOUT: #{stdout}"
- command_output << "STDERR: #{stderr}"
- handle_command_failures(status, command_output, args)
-
- [status, stdout, stderr]
- end
-
- def output_of_command(command, args)
- Chef.deprecated(:run_command, "Chef::Mixin::Command.run_command is deprecated, please use shell_out")
- Chef::Log.debug("Executing #{command}")
- stderr_string, stdout_string, status = "", "", nil
-
- exec_processing_block = lambda do |pid, stdin, stdout, stderr|
- stdout_string, stderr_string = stdout.string.chomp, stderr.string.chomp
- end
-
- args[:cwd] ||= Dir.tmpdir
- unless ::File.directory?(args[:cwd])
- raise Chef::Exceptions::Exec, "#{args[:cwd]} does not exist or is not a directory"
- end
-
- Dir.chdir(args[:cwd]) do
- if args[:timeout]
- begin
- Timeout.timeout(args[:timeout]) do
- status = popen4(command, args, &exec_processing_block)
- end
- rescue Timeout::Error => e
- Chef::Log.error("#{command} exceeded timeout #{args[:timeout]}")
- raise(e)
- end
- else
- status = popen4(command, args, &exec_processing_block)
- end
-
- Chef::Log.debug("---- Begin output of #{command} ----")
- Chef::Log.debug("STDOUT: #{stdout_string}")
- Chef::Log.debug("STDERR: #{stderr_string}")
- Chef::Log.debug("---- End output of #{command} ----")
- Chef::Log.debug("Ran #{command} returned #{status.exitstatus}")
- end
-
- [status, stdout_string, stderr_string]
- end
-
- def handle_command_failures(status, command_output, opts = {})
- return if opts[:ignore_failure]
- opts[:returns] ||= 0
- return if Array(opts[:returns]).include?(status.exitstatus)
-
- # if the log level is not debug, through output of command when we fail
- output = ""
- if Chef::Log.level == :debug || opts[:output_on_failure]
- output << "\n---- Begin output of #{opts[:command]} ----\n"
- output << command_output.to_s
- output << "\n---- End output of #{opts[:command]} ----\n"
- end
- raise Chef::Exceptions::Exec, "#{opts[:command]} returned #{status.exitstatus}, expected #{opts[:returns]}#{output}"
- end
-
- # Call #run_command but set LC_ALL to the system's current environment so it doesn't get changed to C.
- #
- # === Parameters
- # args<Hash>: A number of required and optional arguments that will be handed out to #run_command
- #
- # === Returns
- # Returns the result of #run_command
- def run_command_with_systems_locale(args = {})
- args[:environment] ||= {}
- args[:environment]["LC_ALL"] = ENV["LC_ALL"]
- run_command args
- end
-
- # def popen4(cmd, args={}, &b)
- # @@os_handler.popen4(cmd, args, &b)
- # end
-
- # module_function :popen4
-
- # FIXME: yard with @yield
- def chdir_or_tmpdir(dir)
- dir ||= Dir.tmpdir
- unless File.directory?(dir)
- raise Chef::Exceptions::Exec, "#{dir} does not exist or is not a directory"
- end
- Dir.chdir(dir) do
- yield
- end
- end
-
- end
- end
-end
diff --git a/lib/chef/mixins.rb b/lib/chef/mixins.rb
index b980e81287..2306fb9e89 100644
--- a/lib/chef/mixins.rb
+++ b/lib/chef/mixins.rb
@@ -1,6 +1,5 @@
require "chef/mixin/shell_out"
require "chef/mixin/checksum"
-require "chef/mixin/command"
require "chef/mixin/convert_to_class_name"
require "chef/mixin/create_path"
require "chef/mixin/deep_merge"
diff --git a/lib/chef/provider/cron.rb b/lib/chef/provider/cron.rb
index a45e889bcc..790849673d 100644
--- a/lib/chef/provider/cron.rb
+++ b/lib/chef/provider/cron.rb
@@ -17,13 +17,11 @@
#
require "chef/log"
-require "chef/mixin/command"
require "chef/provider"
class Chef
class Provider
class Cron < Chef::Provider
- include Chef::Mixin::Command
provides :cron, os: ["!aix", "!solaris2"]
diff --git a/lib/chef/provider/deploy.rb b/lib/chef/provider/deploy.rb
index 172705ac71..c4229d2441 100644
--- a/lib/chef/provider/deploy.rb
+++ b/lib/chef/provider/deploy.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-require "chef/mixin/command"
require "chef/mixin/from_file"
require "chef/provider/git"
require "chef/provider/subversion"
@@ -29,7 +28,6 @@ class Chef
include Chef::DSL::Recipe
include Chef::Mixin::FromFile
- include Chef::Mixin::Command
attr_reader :scm_provider, :release_path, :shared_path, :previous_release_path
diff --git a/lib/chef/provider/env.rb b/lib/chef/provider/env.rb
index 7777da183d..490fa31146 100644
--- a/lib/chef/provider/env.rb
+++ b/lib/chef/provider/env.rb
@@ -17,13 +17,11 @@
#
require "chef/provider"
-require "chef/mixin/command"
require "chef/resource/env"
class Chef
class Provider
class Env < Chef::Provider
- include Chef::Mixin::Command
attr_accessor :key_exists
provides :env, os: "!windows"
diff --git a/lib/chef/provider/erl_call.rb b/lib/chef/provider/erl_call.rb
index 26ac19d03b..56591e2068 100644
--- a/lib/chef/provider/erl_call.rb
+++ b/lib/chef/provider/erl_call.rb
@@ -17,13 +17,11 @@
#
require "chef/log"
-require "chef/mixin/command"
require "chef/provider"
class Chef
class Provider
class ErlCall < Chef::Provider
- include Chef::Mixin::Command
provides :erl_call
diff --git a/lib/chef/provider/group.rb b/lib/chef/provider/group.rb
index 82196c72f3..ce20a2b5e5 100644
--- a/lib/chef/provider/group.rb
+++ b/lib/chef/provider/group.rb
@@ -18,14 +18,12 @@
require "chef/provider"
require "chef/mixin/shell_out"
-require "chef/mixin/command"
require "etc"
class Chef
class Provider
class Group < Chef::Provider
include Chef::Mixin::ShellOut
- include Chef::Mixin::Command
attr_accessor :group_exists
attr_accessor :change_desc
diff --git a/lib/chef/provider/ifconfig.rb b/lib/chef/provider/ifconfig.rb
index 003cc3b0e0..16bbe8124b 100644
--- a/lib/chef/provider/ifconfig.rb
+++ b/lib/chef/provider/ifconfig.rb
@@ -17,7 +17,6 @@
#
require "chef/log"
-require "chef/mixin/command"
require "chef/mixin/shell_out"
require "chef/provider"
require "chef/resource/file"
@@ -42,7 +41,6 @@ class Chef
provides :ifconfig
include Chef::Mixin::ShellOut
- include Chef::Mixin::Command
attr_accessor :config_template
attr_accessor :config_path
diff --git a/lib/chef/provider/osx_profile.rb b/lib/chef/provider/osx_profile.rb
index 8ecde54ce0..1d87f29eb2 100644
--- a/lib/chef/provider/osx_profile.rb
+++ b/lib/chef/provider/osx_profile.rb
@@ -25,7 +25,6 @@ require "uuidtools"
class Chef
class Provider
class OsxProfile < Chef::Provider
- include Chef::Mixin::Command
provides :osx_profile, os: "darwin"
provides :osx_config_profile, os: "darwin"
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 36df048741..6d4535fff5 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -17,7 +17,6 @@
#
require "chef/mixin/shell_out"
-require "chef/mixin/command"
require "chef/mixin/subclass_directive"
require "chef/log"
require "chef/file_cache"
@@ -28,7 +27,6 @@ require "shellwords"
class Chef
class Provider
class Package < Chef::Provider
- include Chef::Mixin::Command
include Chef::Mixin::ShellOut
extend Chef::Mixin::SubclassDirective
diff --git a/lib/chef/provider/package/aix.rb b/lib/chef/provider/package/aix.rb
index 5af5f5afad..b013b3d8ce 100644
--- a/lib/chef/provider/package/aix.rb
+++ b/lib/chef/provider/package/aix.rb
@@ -17,7 +17,6 @@
#
#
require "chef/provider/package"
-require "chef/mixin/command"
require "chef/resource/package"
require "chef/mixin/get_source_from_package"
diff --git a/lib/chef/provider/package/ips.rb b/lib/chef/provider/package/ips.rb
index 9666013cc3..d0c8bed175 100644
--- a/lib/chef/provider/package/ips.rb
+++ b/lib/chef/provider/package/ips.rb
@@ -19,7 +19,6 @@
require "open3"
require "chef/provider/package"
-require "chef/mixin/command"
require "chef/resource/package"
class Chef
diff --git a/lib/chef/provider/package/pacman.rb b/lib/chef/provider/package/pacman.rb
index 25683687b2..d1830bdefa 100644
--- a/lib/chef/provider/package/pacman.rb
+++ b/lib/chef/provider/package/pacman.rb
@@ -17,7 +17,6 @@
#
require "chef/provider/package"
-require "chef/mixin/command"
require "chef/resource/package"
class Chef
diff --git a/lib/chef/provider/package/portage.rb b/lib/chef/provider/package/portage.rb
index fd96dfa47f..05a5df370e 100644
--- a/lib/chef/provider/package/portage.rb
+++ b/lib/chef/provider/package/portage.rb
@@ -17,7 +17,6 @@
#
require "chef/provider/package"
-require "chef/mixin/command"
require "chef/resource/package"
require "chef/util/path_helper"
diff --git a/lib/chef/provider/package/rpm.rb b/lib/chef/provider/package/rpm.rb
index 1701886191..7ec24f8c24 100644
--- a/lib/chef/provider/package/rpm.rb
+++ b/lib/chef/provider/package/rpm.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
require "chef/provider/package"
-require "chef/mixin/command"
require "chef/resource/package"
require "chef/mixin/get_source_from_package"
diff --git a/lib/chef/provider/package/rubygems.rb b/lib/chef/provider/package/rubygems.rb
index 1019b8d3fa..9bf8fb5fbc 100644
--- a/lib/chef/provider/package/rubygems.rb
+++ b/lib/chef/provider/package/rubygems.rb
@@ -19,7 +19,6 @@
require "uri"
require "chef/provider/package"
-require "chef/mixin/command"
require "chef/resource/package"
require "chef/mixin/get_source_from_package"
diff --git a/lib/chef/provider/package/solaris.rb b/lib/chef/provider/package/solaris.rb
index 5537127310..f6e66c050a 100644
--- a/lib/chef/provider/package/solaris.rb
+++ b/lib/chef/provider/package/solaris.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
require "chef/provider/package"
-require "chef/mixin/command"
require "chef/resource/package"
require "chef/mixin/get_source_from_package"
diff --git a/lib/chef/provider/route.rb b/lib/chef/provider/route.rb
index 2e2a1266b4..59d516be6a 100644
--- a/lib/chef/provider/route.rb
+++ b/lib/chef/provider/route.rb
@@ -17,14 +17,12 @@
#
require "chef/log"
-require "chef/mixin/command"
require "chef/provider"
require "ipaddr"
class Chef
class Provider
class Route < Chef::Provider
- include Chef::Mixin::Command
provides :route
diff --git a/lib/chef/provider/service.rb b/lib/chef/provider/service.rb
index 11d04eaca2..9f06e2eb25 100644
--- a/lib/chef/provider/service.rb
+++ b/lib/chef/provider/service.rb
@@ -17,15 +17,12 @@
# limitations under the License.
#
-require "chef/mixin/command"
require "chef/provider"
class Chef
class Provider
class Service < Chef::Provider
- include Chef::Mixin::Command
-
def supports
@supports ||= new_resource.supports.dup
end
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb
index 9746dfdef0..c1e315afee 100644
--- a/lib/chef/provider/service/freebsd.rb
+++ b/lib/chef/provider/service/freebsd.rb
@@ -18,7 +18,6 @@
require "chef/resource/service"
require "chef/provider/service/init"
-require "chef/mixin/command"
class Chef
class Provider
diff --git a/lib/chef/provider/service/gentoo.rb b/lib/chef/provider/service/gentoo.rb
index 7bb57113ac..0ac74649b6 100644
--- a/lib/chef/provider/service/gentoo.rb
+++ b/lib/chef/provider/service/gentoo.rb
@@ -18,7 +18,6 @@
#
require "chef/provider/service/init"
-require "chef/mixin/command"
require "chef/util/path_helper"
class Chef::Provider::Service::Gentoo < Chef::Provider::Service::Init
diff --git a/lib/chef/provider/service/init.rb b/lib/chef/provider/service/init.rb
index dff627d016..c6c582f8b8 100644
--- a/lib/chef/provider/service/init.rb
+++ b/lib/chef/provider/service/init.rb
@@ -17,7 +17,6 @@
#
require "chef/provider/service/simple"
-require "chef/mixin/command"
require "chef/platform/service_helpers"
class Chef
diff --git a/lib/chef/provider/service/openbsd.rb b/lib/chef/provider/service/openbsd.rb
index 780337e1b6..f839d54780 100644
--- a/lib/chef/provider/service/openbsd.rb
+++ b/lib/chef/provider/service/openbsd.rb
@@ -16,7 +16,6 @@
# limitations under the License.
#
-require "chef/mixin/command"
require "chef/mixin/shell_out"
require "chef/provider/service/init"
require "chef/resource/service"
diff --git a/lib/chef/provider/service/simple.rb b/lib/chef/provider/service/simple.rb
index 84ced52071..81ac970b87 100644
--- a/lib/chef/provider/service/simple.rb
+++ b/lib/chef/provider/service/simple.rb
@@ -18,7 +18,6 @@
require "chef/provider/service"
require "chef/resource/service"
-require "chef/mixin/command"
class Chef
class Provider
diff --git a/lib/chef/provider/service/solaris.rb b/lib/chef/provider/service/solaris.rb
index c560bed011..9c85fda05f 100644
--- a/lib/chef/provider/service/solaris.rb
+++ b/lib/chef/provider/service/solaris.rb
@@ -18,7 +18,6 @@
require "chef/provider/service"
require "chef/resource/service"
-require "chef/mixin/command"
class Chef
class Provider
diff --git a/lib/chef/provider/service/upstart.rb b/lib/chef/provider/service/upstart.rb
index 9c0d97d376..f10660f57a 100644
--- a/lib/chef/provider/service/upstart.rb
+++ b/lib/chef/provider/service/upstart.rb
@@ -18,7 +18,6 @@
require "chef/resource/service"
require "chef/provider/service/simple"
-require "chef/mixin/command"
require "chef/util/file_edit"
class Chef
diff --git a/lib/chef/provider/subversion.rb b/lib/chef/provider/subversion.rb
index d7e26f3968..4fece0ae40 100644
--- a/lib/chef/provider/subversion.rb
+++ b/lib/chef/provider/subversion.rb
@@ -20,7 +20,6 @@
require "chef/log"
require "chef/provider"
-require "chef/mixin/command"
require "chef-config/mixin/fuzzy_hostname_matcher"
require "fileutils"
@@ -32,7 +31,6 @@ class Chef
SVN_INFO_PATTERN = /^([\w\s]+): (.+)$/
- include Chef::Mixin::Command
include ChefConfig::Mixin::FuzzyHostnameMatcher
def load_current_resource
diff --git a/lib/chef/provider/user.rb b/lib/chef/provider/user.rb
index dcfee22c31..abdff441a5 100644
--- a/lib/chef/provider/user.rb
+++ b/lib/chef/provider/user.rb
@@ -17,13 +17,11 @@
#
require "chef/provider"
-require "chef/mixin/command"
require "etc"
class Chef
class Provider
class User < Chef::Provider
- include Chef::Mixin::Command
attr_accessor :user_exists, :locked