lib/bolt/pal.rb
# PALError is used to convert errors from executing puppet code into
# Bolt::Errors
PALError is used to convert errors from executing puppet code into
Bolt::Errors
PALError is used to convert errors from executing puppet code into Bolt :: Errors
def list_tasks_with_cache(filter_content: false)
      task_names = list_tasks(filter_content: false).map(&:first)
      task_cache = if @project
                     Bolt::Util.read_optional_json_file(@project.task_cache_file, 'Task cache file')
                   else
                     {}
                   end
      updated = false
      task_list = task_names.each_with_object([]) do |task_name, list|
        data = task_cache[task_name] || get_task_info(task_name, with_mtime: true)
        data = Bolt::Util.walk_keys(data, &:to_s)
        if data['files']&.any?
          data['files'].each do |f|
            next unless file_modified?(f['path'], f['mtime'])
            data = get_task_info(task_name, with_mtime: true)
            data = Bolt::Util.walk_keys(data, &:to_s)
            updated = true
            task_cache[task_name] = data
          end
        end
        metadata = data['metadata'] || {}
        list << [task_name, metadata['description']] unless metadata['private']
      end
      File.write(@project.task_cache_file, task_cache.to_json) if updated && @project
      filter_content ? filter_content(task_list, @project&.tasks) : task_list
    end
def list_tasks_with_cache ( filter_content : false ) task_names = list_tasks ( filter_content : false ) . map ( & :first ) task_cache = if @project Bolt :: Util . read_optional_json_file ( @project . task_cache_file , 'Task cache file' ) else { } end updated = false task_list = task_names . each_with_object ( [ ] ) do | task_name , list | data = task_cache [ task_name ] || get_task_info ( task_name , with_mtime : true ) data = Bolt :: Util . walk_keys ( data , & :to_s ) if data [ 'files' ] &. any? data [ 'files' ] . each do | f | next unless file_modified? ( f [ 'path' ] , f [ 'mtime' ] ) data = get_task_info ( task_name , with_mtime : true ) data = Bolt :: Util . walk_keys ( data , & :to_s ) updated = true task_cache [ task_name ] = data end end metadata = data [ 'metadata' ] || { } list << [ task_name , metadata [ 'description' ] ] unless metadata [ 'private' ] end File . write ( @project . task_cache_file , task_cache . to_json ) if updated && @project filter_content ? filter_content ( task_list , @project &. tasks ) : task_list end
PALError is used to convert errors from executing puppet code into
Bolt::Errors
PALError is used to convert errors from executing puppet code into Bolt :: Errors
# Don't filter content yet, so that if users update their task filters # we don't need to refresh the cache # Make sure all the keys are strings - if we get data from # get_task_info they will be symbols # If any files in the task were updated, refresh the cache # For all the files that are part of the task # If any file has been updated since we last cached, update the # cache # Tell Bolt to write to the cache file once we're done # Update the cache data # Don't add tasks to the list to return if they are private # Write the cache if any entries were updated
filter_content
<not_specific>