Class: Chef::Knife::S3List

Inherits:
S3Base show all
Defined in:
lib/chef/knife/s3_list.rb

Instance Method Summary collapse

Methods inherited from S3Base

#connection, included, #locate_config_value, #msg_pair, #validate!

Instance Method Details

#runObject



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# 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