module ChefOpsDCC
  module Helpers
    def liveness_agent_recipe_url
      github_api = Chef::HTTP.new('https://api.github.com/')
      release = JSON.parse(github_api.get('/repos/chef/automate-liveness-agent/releases/latest'))
      release['assets'].find { |a| a['name'] == 'automate-liveness-recipe.rb' }['browser_download_url']
    end

    def oc_id_applciation_config(app_name)
      File.read("/etc/opscode/oc-id-applications/#{app_name}.json")
    rescue Errno::ENOENT
      ''
    end
  end
end

Chef::Node.send(:include, ChefOpsDCC::Helpers)
Chef::Recipe.send(:include, ChefOpsDCC::Helpers)
Chef::Resource.send(:include, ChefOpsDCC::Helpers)

module ChefOpsDCC
  module Helpers
    def liveness_agent_recipe_url
      github_api = Chef::HTTP.new('https://api.github.com/')
      release = JSON.parse(github_api.get('/repos/chef/automate-liveness-agent/releases/latest'))
      release['assets'].find { |a| a['name'] == 'automate-liveness-recipe.rb' }['browser_download_url']
    end

    def oc_id_applciation_config(app_name)
      File.read("/etc/opscode/oc-id-applications/#{app_name}.json")
    rescue Errno::ENOENT
      ''
    end
  end
end

Chef::Node.include ChefOpsDCC::Helpers
Chef::Recipe.include ChefOpsDCC::Helpers
Chef::Resource.include ChefOpsDCC::Helpers

Fix new chefstyle finding in chef-server-deploy cookbooks
Fix new chefstyle finding in chef-server-deploy cookbooks

As a follow up we should look at removing these cookbooks as I don't
think they are required anymore.

Signed-off-by: Steven Danna <9ce5770b3bb4b2a1d59be2d97e34379cd192299f@chef.io>
