Module: ClusterFsck::S3Methods

Included in:
Commands::Environments, Commands::List, Reader, Writer
Defined in:
lib/clusterfsck/s3_methods.rb

Defined Under Namespace

Classes: ConflictError, KeyDoesNotExistError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.credentialsObject



19
20
21
# File 'lib/clusterfsck/s3_methods.rb', line 19

def self.credentials
  @credentials ||= CredentialGrabber.find
end

.s3Object



27
28
29
30
31
32
33
# File 'lib/clusterfsck/s3_methods.rb', line 27

def self.s3
  if credentials
    AWS::S3.new(credentials) #could be nil, especially if on EC2
  else
    AWS::S3.new
  end
end

Instance Method Details

#all_environmentsObject



39
40
41
# File 'lib/clusterfsck/s3_methods.rb', line 39

def all_environments
  bucket.objects.map(&:key).map {|key| key.split('/').first }.uniq
end

#all_filesObject



35
36
37
# File 'lib/clusterfsck/s3_methods.rb', line 35

def all_files
  bucket.objects.with_prefix(cluster_fsck_env).collect(&:key)
end

#bucketObject



11
12
13
# File 'lib/clusterfsck/s3_methods.rb', line 11

def bucket
  @bucket ||= s3.buckets[ClusterFsck.config_bucket]
end

#cluster_fsck_envObject



47
48
49
# File 'lib/clusterfsck/s3_methods.rb', line 47

def cluster_fsck_env
  @cluster_fsck_env || ClusterFsck.cluster_fsck_env
end

#credentialsObject



15
16
17
# File 'lib/clusterfsck/s3_methods.rb', line 15

def credentials
  S3Methods.credentials
end

#full_s3_path(key) ⇒ Object



43
44
45
# File 'lib/clusterfsck/s3_methods.rb', line 43

def full_s3_path(key)
  "#{cluster_fsck_env}/#{key}"
end

#s3Object



23
24
25
# File 'lib/clusterfsck/s3_methods.rb', line 23

def s3
  S3Methods.s3
end

#s3_object(object_name) ⇒ Object



7
8
9
# File 'lib/clusterfsck/s3_methods.rb', line 7

def s3_object(object_name)
  bucket.objects[full_s3_path(object_name)]
end