lib/modulesync.rb in modulesync-0.1.0 vs lib/modulesync.rb in modulesync-0.2.0
- old
+ new
@@ -28,16 +28,17 @@
def self.module_files(local_files, path)
local_files.map { |file| file.sub(/#{path}/, '') }
end
- def self.managed_modules(path)
+ def self.managed_modules(path, filter)
managed_modules = Util.parse_config(path)
if managed_modules.empty?
puts "No modules found at #{path}. Check that you specified the right configs directory containing managed_modules.yml."
exit
end
+ managed_modules.select! { |m| m =~ Regexp.new(filter) } unless filter.nil?
managed_modules
end
def self.run(args)
cli = CLI.new
@@ -48,10 +49,10 @@
path = "#{options[:configs]}/#{MODULE_FILES_DIR}"
local_files = self.local_files(path)
module_files = self.module_files(local_files, path)
- managed_modules = self.managed_modules("#{options[:configs]}/managed_modules.yml")
+ managed_modules = self.managed_modules("#{options[:configs]}/managed_modules.yml", options[:filter])
managed_modules.each do |puppet_module|
puts "Syncing #{puppet_module}"
Git.pull(options[:git_user], options[:git_provider_address], options[:namespace], puppet_module)
module_configs = Util.parse_config("#{PROJ_ROOT}/#{puppet_module}/#{MODULE_CONF_FILE}")