class Chef::Knife::S3List

Public Instance Methods

run() click to toggle source
# File lib/chef/knife/s3_list.rb, line 28
def run
  $stdout.sync = true

  validate!

  if config[:bucket]
    puts "Listing bucket " + config[:bucket]
  else
    puts "No bucket specified"
    exit 1
  end

  if config[:prefix]
    puts "Listing with prefix " + config[:prefix]
  end

  begin
    if config[:prefix].nil?
      connection.directories.get(config[:bucket]).files.map do |file|
        puts file.key
      end
    else
      connection.directories.get(config[:bucket], prefix: config[:prefix]).files.map do |file|
        puts file.key
      end
    end
  end


end