Skip to content

Commit

Permalink
Refactor config path logic in to lib
Browse files Browse the repository at this point in the history
  • Loading branch information
ncs-alane committed Jan 25, 2015
1 parent fa7e226 commit 23c307d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 7 additions & 0 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ module Pipeline
module Helpers
Chef::Recipe.send :include, self

def path_to_config_for(name)
file_cache_path = Chef::Config[:file_cache_path]
file_name = "#{name}-config.xml"

::File.join file_cache_path, file_name
end

def each_chef_org(&block)
if Chef::Config[:solo]
Chef::Log.warn 'This recipe uses search;' \
Expand Down
4 changes: 2 additions & 2 deletions recipes/jobs.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# set up chef-repo job per chef-repo
each_chef_repo do |repo|
xml = File.join(Chef::Config[:file_cache_path], "#{repo['name']}-config.xml")
xml = path_to_config_for repo['name']

template xml do
source "job-config.xml.erb"
Expand Down Expand Up @@ -30,7 +30,7 @@

berksfile.list.reject{|c| c.location == nil}.each do |cookbook|
Chef::Log.info(cookbook.location.to_s)
xml = File.join(Chef::Config[:file_cache_path], "#{cookbook.name}-config.xml")
xml = path_to_config_for cookbook.name

template xml do
source "job-config.xml.erb"
Expand Down

0 comments on commit 23c307d

Please sign in to comment.