Skip to content
This repository has been archived by the owner on Feb 22, 2021. It is now read-only.

Commit

Permalink
[COOK-3343] Use feature detection instead of version detection in Che…
Browse files Browse the repository at this point in the history
…f::Platform#provider_for_resource

Signed-off-by: Sean OMeara <someara@opscode.com>
  • Loading branch information
sethvargo authored and Sean OMeara committed Oct 25, 2013
1 parent 0c0bda4 commit ff8dacb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 20 deletions.
21 changes: 9 additions & 12 deletions libraries/default.rb
Expand Up @@ -137,18 +137,15 @@ def self.included(klass)
end

def deploy_provider
@deploy_provider ||=
begin
version = Chef::Version.new(Chef::VERSION)
deploy_provider =
if version.major > 10 || version.minor >= 14
Chef::Platform.provider_for_resource(@deploy_resource, :nothing)
else
Chef::Platform.provider_for_resource(@deploy_resource)
end
deploy_provider.load_current_resource
deploy_provider
end
@deploy_provider ||= begin
provider = if Chef::Platform.method(:provider_for_resource).arity == 2
Chef::Platform.provider_for_resource(@deploy_resource, :nothing)
else
Chef::Platform.provider_for_resource(@deploy_resource)
end
provider.load_current_resource
provider
end
end

def release_path
Expand Down
9 changes: 1 addition & 8 deletions providers/default.rb
Expand Up @@ -140,14 +140,7 @@ def run_deploy(force = false)
([new_resource]+new_resource.sub_resources).each do |res|
cmd = res.restart_command
if cmd.is_a? Proc
version = Chef::Version.new(Chef::VERSION)
provider = if version.major > 10 || version.minor >= 14
Chef::Platform.provider_for_resource(res, :nothing)
else
Chef::Platform.provider_for_resource(res)
end
provider.load_current_resource
provider.instance_eval(&cmd)
deploy_provider.instance_eval(&cmd) # @see libraries/default.rb
elsif cmd && !cmd.empty?
execute cmd do
user new_resource.owner
Expand Down

3 comments on commit ff8dacb

@paulczar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you broke stuff with this commit.

https://tickets.opscode.com/browse/COOK-4004

using this revision makes the bad errors stop - e929b6a

@coderanger
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@paulczar Please try using master, this error should be fixed in both app_ruby and app_python.

@paulczar
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I was! ( the version from the community cookbooks ... which shows as 3.0.2 which is the same version show in the metadata.rb in master branch ) .. perhaps a version bump is in order to avoid such confusion!

Please sign in to comment.