Skip to content

Commit

Permalink
use chef data_bag_path array setting
Browse files Browse the repository at this point in the history
  • Loading branch information
stonith committed Mar 23, 2016
1 parent 63bf41b commit 67159e7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/chefdepartie/cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ def dump

def to_key(path)
case path
when /\/data_bags\//
path.gsub(/.*data_bags/, 'data').gsub('.json', '')
when /data_bags[^\/]*\//
path.gsub(/.*data_bags([^\/]*)/, 'data_bags\1').gsub('.json', '')
when /\/roles\//
File.join('roles', path.gsub(/.*roles\//, '').gsub('/', '--').gsub('.rb', ''))
when /cookbooks[^\/]*\//
Expand Down
14 changes: 11 additions & 3 deletions lib/chefdepartie/databag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,17 @@ module Chefdepartie
module Databags
def self.upload_all
puts 'Uploading databags'
cookbooks = File.dirname(Chef::Config[:cookbook_path])
bags = Dir[File.join(cookbooks, 'data_bags', '/*')]
upload_all_data_bags(bags)
data_bag_path = Chef::Config[:data_bag_path]
bags = []
if data_bag_path.kind_of?(Array)
data_bag_path.each do |path|
bag = Dir[File.join(path, '/*')]
bags << bag
end
else
bags = Dir[File.join(data_bag_path, '/*')]
end
upload_all_data_bags(bags.flatten)
end

private
Expand Down

0 comments on commit 67159e7

Please sign in to comment.