Skip to content

Commit

Permalink
Merge pull request #59 from chef-cookbooks/chef13
Browse files Browse the repository at this point in the history
Chef 13 compatibility
  • Loading branch information
tas50 committed Mar 25, 2017
2 parents 366147d + d1fc269 commit ea20281
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .kitchen.yml
Expand Up @@ -18,11 +18,11 @@ platforms:
- name: fedora-25
- name: opensuse-leap-42.2
- name: ubuntu-14.04
- name: ubuntu-14.04-chef125
- name: ubuntu-14.04-chef127
driver_config:
box: bento/ubuntu-14.04
provisioner:
require_chef_omnibus: 12.5.1
require_chef_omnibus: 12.7.2
- name: ubuntu-16.04
- name: windows-2008r2
driver_config:
Expand Down
4 changes: 2 additions & 2 deletions resources/hint.rb
Expand Up @@ -4,7 +4,7 @@

action_class do
def ohai_hint_path
path = ::File.join(::Ohai::Config[:hints_path].first, new_resource.hint_name)
path = ::File.join(::Ohai::Config.ohai.hints_path.first, new_resource.hint_name)
path << '.json' unless path.end_with?('.json')
path
end
Expand All @@ -24,7 +24,7 @@ def file_content(path)
end

action :create do
directory ::Ohai::Config[:hints_path].first do
directory ::Ohai::Config.ohai.hints_path.first do
action :create
recursive true
end
Expand Down
28 changes: 6 additions & 22 deletions resources/plugin.rb
Expand Up @@ -10,10 +10,10 @@
# return the path property if specified or
# CHEF_CONFIG_PATH/ohai/plugins if a path isn't specified
def desired_plugin_path
if path
path
if new_resource.path
new_resource.path
else
ohai_plugin_path
::File.join(chef_config_path, 'ohai', 'plugins')
end
end

Expand All @@ -28,37 +28,21 @@ def chef_config_path
end
end

# return the ohai plugin path. Most likely /etc/chef/ohai/plugins/
def ohai_plugin_path
::File.join(chef_config_path, 'ohai', 'plugins')
end

# is the desired plugin dir in the ohai config plugin dir array?
def in_plugin_path?(path)
# get the directory where we plan to stick the plugin (not the actual file path)
desired_dir = ::File.directory?(path) ? path : ::File.dirname(path)

# get the array of plugin paths Ohai knows about
ohai_plugin_dir = if ::Ohai::Config.ohai.nil?
::Ohai::Config['plugin_path'] # old format
else
::Ohai::Config.ohai['plugin_path'] # new format
end

case node['platform']
when 'windows'
ohai_plugin_dir.map(&:downcase).include?(desired_dir.downcase)
::Ohai::Config.ohai['plugin_path'].map(&:downcase).include?(desired_dir.downcase)
else
ohai_plugin_dir.include?(desired_dir)
::Ohai::Config.ohai['plugin_path'].include?(desired_dir)
end
end

def add_to_plugin_path(path)
if ::Ohai::Config.ohai.nil?
::Ohai::Config['plugin_path'] << path # old format
else
::Ohai::Config.ohai['plugin_path'] << path # new format
end
::Ohai::Config.ohai['plugin_path'] << path # new format
end

# we need to warn the user that unless the path for this plugin is in Ohai's
Expand Down

0 comments on commit ea20281

Please sign in to comment.