resources/download_buildpack_cache.rb
# Returns array of config maps containing references to the root index.yml
# of file sets to be included in the cache.
#
# @param [Array<String>] config_files list of config files to check. By default it contains all yml files in buildpack config and service config directories.
# @param [Array<String>] cached_hosts list of host names which content should be cached. Collect all remote content by default.
# @param [Array<String>] exclude_files list of YML file names to exclude from collection. Exclude none by default.
Returns array of config maps containing references to the root index.yml
of file sets to be included in the cache.
Returns array of config maps containing references to the root index . yml of file sets to be included in the cache .
def collect_configs(config_files = nil, cached_hosts = nil, exclude_files = nil)
    if config_files.nil?
      config_files = Dir[File.expand_path(File.join('..', '..', 'config', '*.yml'), __FILE__)]
      config_files.concat(Dir[File.expand_path(File.join('..', '..', 'lib', 'liberty_buildpack', 'services', 'config', '*.yml'), __FILE__)])
    end
    configs = []
    config_files.reject! { |f| exclude_files.include?(File.basename(f)) } unless exclude_files.nil?
    config_files.each do |file|
      @logger.debug "Checking #{file}"
      begin
        config = YAML.load_file(file)
      rescue => e
        abort "ERROR: Failed loading config #{file}: #{e}"
      end
      next if config.nil?
      config = config[DRIVER] || config
      if repository_configuration?(config) && (File.exist?(index_path(config)) || cached_hosts.nil? || cached_hosts.include?(URI(repository_root(config)).host))
        configs.push(config)
      end
    end
    configs
  end
def collect_configs ( config_files = nil , cached_hosts = nil , exclude_files = nil ) if config_files . nil? config_files = Dir [ File . expand_path ( File . join ( '..' , '..' , 'config' , '*.yml' ) , __FILE__ ) ] config_files . concat ( Dir [ File . expand_path ( File . join ( '..' , '..' , 'lib' , 'liberty_buildpack' , 'services' , 'config' , '*.yml' ) , __FILE__ ) ] ) end configs = [ ] config_files . reject! { | f | exclude_files . include? ( File . basename ( f ) ) } unless exclude_files . nil? config_files . each do | file | @logger . debug "Checking #{file}" begin config = YAML . load_file ( file ) rescue => e abort "ERROR: Failed loading config #{file}: #{e}" end next if config . nil? config = config [ DRIVER ] || config if repository_configuration? ( config ) && ( File . exist? ( index_path ( config ) ) || cached_hosts . nil? || cached_hosts . include? ( URI ( repository_root ( config ) ) . host ) ) configs . push ( config ) end end configs end
Returns array of config maps containing references to the root index.yml
of file sets to be included in the cache.
Returns array of config maps containing references to the root index . yml of file sets to be included in the cache .
config_files
cached_hosts
exclude_files
exclude_files list of YML file names to exclude from collection. Exclude none by default.
exclude_files list of YML file names to exclude from collection . Exclude none by default .