summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoah Kantrowitz <noah@coderanger.net>2017-03-14 15:24:50 -0700
committerGitHub <noreply@github.com>2017-03-14 15:24:50 -0700
commit5f8511b74dc0b527d667685340206658143282a2 (patch)
tree04c5f4a61d56dc93f479ccc3d9ab3333f912cbd2
parent65222c7f098c2dd4c3dc429151ab55686a790e9b (diff)
parent264a07e15cd6ef83a2872cabcba2eced21d0f93d (diff)
downloadchef-5f8511b74dc0b527d667685340206658143282a2.tar.gz
Merge pull request #5901 from coderanger/rip-easy-install
No more easy_install resource.
-rw-r--r--lib/chef/provider/package/easy_install.rb135
-rw-r--r--lib/chef/providers.rb1
-rw-r--r--lib/chef/resource/easy_install_package.rb32
-rw-r--r--lib/chef/resources.rb1
-rw-r--r--spec/unit/provider/package/easy_install_spec.rb114
-rw-r--r--spec/unit/provider_resolver_spec.rb1
-rw-r--r--spec/unit/resource/easy_install_package_spec.rb39
7 files changed, 0 insertions, 323 deletions
diff --git a/lib/chef/provider/package/easy_install.rb b/lib/chef/provider/package/easy_install.rb
deleted file mode 100644
index cc915e606c..0000000000
--- a/lib/chef/provider/package/easy_install.rb
+++ /dev/null
@@ -1,135 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# 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/provider/package"
-require "chef/mixin/command"
-require "chef/resource/package"
-
-class Chef
- class Provider
- class Package
- class EasyInstall < Chef::Provider::Package
-
- provides :easy_install_package
-
- def install_check(name)
- check = false
-
- begin
- # first check to see if we can import it
- output = shell_out_compact_timeout!(python_binary_path, "-c", "import #{name}", returns: [0, 1]).stderr
- if output.include? "ImportError"
- # then check to see if its on the path
- output = shell_out_compact_timeout!(python_binary_path, "-c", "import sys; print sys.path", returns: [0, 1]).stdout
- if output.downcase.include? name.downcase.to_s
- check = true
- end
- else
- check = true
- end
- rescue
- # it's probably not installed
- end
-
- check
- end
-
- def easy_install_binary_path
- path = new_resource.easy_install_binary
- path ? path : "easy_install"
- end
-
- def python_binary_path
- path = new_resource.python_binary
- path ? path : "python"
- end
-
- def module_name
- m = new_resource.module_name
- m ? m : new_resource.name
- end
-
- def load_current_resource
- @current_resource = Chef::Resource::Package.new(new_resource.name)
- current_resource.package_name(new_resource.package_name)
-
- # get the currently installed version if installed
- package_version = nil
- if install_check(module_name)
- begin
- output = shell_out_compact_timeout!("#{python_binary_path} -c \"import #{module_name}; print #{module_name}.__version__\"").stdout
- package_version = output.strip
- rescue
- output = shell_out_compact_timeout!("#{python_binary_path} -c \"import sys; print sys.path\"", returns: [0, 1]).stdout
-
- output_array = output.gsub(/[\[\]]/, "").split(/\s*,\s*/)
- package_path = ""
-
- output_array.each do |entry|
- if entry.downcase.include?(new_resource.package_name)
- package_path = entry
- end
- end
-
- package_path[/\S\S(.*)\/(.*)-(.*)-py(.*).egg\S/]
- package_version = $3
- end
- end
-
- if package_version == new_resource.version
- Chef::Log.debug("#{new_resource} at version #{new_resource.version}")
- current_resource.version(new_resource.version)
- else
- Chef::Log.debug("#{new_resource} at version #{package_version}")
- current_resource.version(package_version)
- end
-
- current_resource
- end
-
- def candidate_version
- return @candidate_version if @candidate_version
-
- # do a dry run to get the latest version
- result = shell_out_compact_timeout!("#{easy_install_binary_path} -n #{new_resource.package_name}", returns: [0, 1])
- @candidate_version = result.stdout[/(.*)Best match: (.*) (.*)$/, 3]
- @candidate_version
- end
-
- def install_package(name, version)
- Chef.deprecated(:easy_install, "The easy_install package provider is deprecated and will be removed in Chef 13.")
- shell_out_compact_timeout!(easy_install_binary_path, options, "#{name}==#{version}")
- end
-
- def upgrade_package(name, version)
- install_package(name, version)
- end
-
- def remove_package(name, version)
- Chef.deprecated(:easy_install, "The easy_install package provider is deprecated and will be removed in Chef 13.")
- shell_out_compact_timeout!(easy_install_binary_path, options, "-m", name)
- end
-
- def purge_package(name, version)
- remove_package(name, version)
- end
-
- end
- end
- end
-end
diff --git a/lib/chef/providers.rb b/lib/chef/providers.rb
index 35722840e6..0f19f56a8f 100644
--- a/lib/chef/providers.rb
+++ b/lib/chef/providers.rb
@@ -66,7 +66,6 @@ require "chef/provider/package/apt"
require "chef/provider/package/chocolatey"
require "chef/provider/package/dpkg"
require "chef/provider/package/dnf"
-require "chef/provider/package/easy_install"
require "chef/provider/package/freebsd/port"
require "chef/provider/package/freebsd/pkg"
require "chef/provider/package/freebsd/pkgng"
diff --git a/lib/chef/resource/easy_install_package.rb b/lib/chef/resource/easy_install_package.rb
deleted file mode 100644
index dc5073a6f7..0000000000
--- a/lib/chef/resource/easy_install_package.rb
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# 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/resource/package"
-
-class Chef
- class Resource
- class EasyInstallPackage < Chef::Resource::Package
- resource_name :easy_install_package
-
- property :easy_install_binary, String, desired_state: false
- property :python_binary, String, desired_state: false
- property :module_name, String, desired_state: false
-
- end
- end
-end
diff --git a/lib/chef/resources.rb b/lib/chef/resources.rb
index ab89ce66e0..a254fa601f 100644
--- a/lib/chef/resources.rb
+++ b/lib/chef/resources.rb
@@ -34,7 +34,6 @@ require "chef/resource/dpkg_package"
require "chef/resource/dnf_package"
require "chef/resource/dsc_script"
require "chef/resource/dsc_resource"
-require "chef/resource/easy_install_package"
require "chef/resource/env"
require "chef/resource/erl_call"
require "chef/resource/execute"
diff --git a/spec/unit/provider/package/easy_install_spec.rb b/spec/unit/provider/package/easy_install_spec.rb
deleted file mode 100644
index 910f01bfeb..0000000000
--- a/spec/unit/provider/package/easy_install_spec.rb
+++ /dev/null
@@ -1,114 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# 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 "spec_helper"
-
-describe Chef::Provider::Package::EasyInstall do
- before(:each) do
- @node = Chef::Node.new
- @events = Chef::EventDispatch::Dispatcher.new
- @run_context = Chef::RunContext.new(@node, {}, @events)
- @new_resource = Chef::Resource::EasyInstallPackage.new("boto")
- @new_resource.version("1.8d")
-
- @provider = Chef::Provider::Package::EasyInstall.new(@new_resource, @run_context)
-
- @stdin = StringIO.new
- @stdout = StringIO.new
- @status = double("Status", :exitstatus => 0)
- @stderr = StringIO.new
- @pid = 2342
- allow(@provider).to receive(:popen4).and_return(@status)
- end
-
- describe "easy_install_binary_path" do
- it "should return a Chef::Provider::EasyInstall object" do
- provider = Chef::Provider::Package::EasyInstall.new(@node, @new_resource)
- expect(provider).to be_a_kind_of(Chef::Provider::Package::EasyInstall)
- end
-
- it "should set the current resources package name to the new resources package name" do
- allow($stdout).to receive(:write)
- @provider.load_current_resource
- expect(@provider.current_resource.package_name).to eq(@new_resource.package_name)
- end
-
- it "should return a relative path to easy_install if no easy_install_binary is given" do
- expect(@provider.easy_install_binary_path).to eql("easy_install")
- end
-
- it "should return a specific path to easy_install if a easy_install_binary is given" do
- expect(@new_resource).to receive(:easy_install_binary).and_return("/opt/local/bin/custom/easy_install")
- expect(@provider.easy_install_binary_path).to eql("/opt/local/bin/custom/easy_install")
- end
-
- end
-
- describe "actions_on_package" do
- it "should run easy_install with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "boto==1.8d", { timeout: 900 }
- )
- @provider.install_package("boto", "1.8d")
- end
-
- it "should run easy_install with the package name and version and specified options" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "--always-unzip", "boto==1.8d", { timeout: 900 }
- )
- allow(@new_resource).to receive(:options).and_return("--always-unzip")
- @provider.install_package("boto", "1.8d")
- end
-
- it "should run easy_install with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "boto==1.8d", { timeout: 900 }
- )
- @provider.upgrade_package("boto", "1.8d")
- end
-
- it "should run easy_install -m with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "-m", "boto", { timeout: 900 }
- )
- @provider.remove_package("boto", "1.8d")
- end
-
- it "should run easy_install -m with the package name and version and specified options" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "-x", "-m", "boto", { timeout: 900 }
- )
- allow(@new_resource).to receive(:options).and_return("-x")
- @provider.remove_package("boto", "1.8d")
- end
-
- it "should run easy_install -m with the package name and version" do
- expect(Chef).to receive(:deprecated).with(:easy_install, /easy_install package provider is deprecated/)
- expect(@provider).to receive(:shell_out!).with(
- "easy_install", "-m", "boto", { timeout: 900 }
- )
- @provider.purge_package("boto", "1.8d")
- end
-
- end
-end
diff --git a/spec/unit/provider_resolver_spec.rb b/spec/unit/provider_resolver_spec.rb
index ec102209ab..9a66df82b3 100644
--- a/spec/unit/provider_resolver_spec.rb
+++ b/spec/unit/provider_resolver_spec.rb
@@ -561,7 +561,6 @@ describe Chef::ProviderResolver do
deploy: [ Chef::Resource::Deploy, Chef::Provider::Deploy::Timestamped ],
deploy_revision: [ Chef::Resource::DeployRevision, Chef::Provider::Deploy::Revision ],
directory: [ Chef::Resource::Directory, Chef::Provider::Directory ],
- easy_install_package: [ Chef::Resource::EasyInstallPackage, Chef::Provider::Package::EasyInstall ],
erl_call: [ Chef::Resource::ErlCall, Chef::Provider::ErlCall ],
execute: [ Chef::Resource::Execute, Chef::Provider::Execute ],
file: [ Chef::Resource::File, Chef::Provider::File ],
diff --git a/spec/unit/resource/easy_install_package_spec.rb b/spec/unit/resource/easy_install_package_spec.rb
deleted file mode 100644
index ce8e6d8bf6..0000000000
--- a/spec/unit/resource/easy_install_package_spec.rb
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Author:: Joe Williams (<joe@joetify.com>)
-# Copyright:: Copyright 2009-2016, Joe Williams
-# 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 "spec_helper"
-require "support/shared/unit/resource/static_provider_resolution"
-
-describe Chef::Resource::EasyInstallPackage, "initialize" do
-
- static_provider_resolution(
- resource: Chef::Resource::EasyInstallPackage,
- provider: Chef::Provider::Package::EasyInstall,
- name: :easy_install_package,
- action: :install
- )
-
- before(:each) do
- @resource = Chef::Resource::EasyInstallPackage.new("foo")
- end
-
- it "should allow you to set the easy_install_binary attribute" do
- @resource.easy_install_binary "/opt/local/bin/easy_install"
- expect(@resource.easy_install_binary).to eql("/opt/local/bin/easy_install")
- end
-end