Class: DPL::Provider::S3
Instance Attribute Summary
#context, #options
Instance Method Summary
collapse
#cleanup, context, #create_key, #error, experimental, #initialize, #log, new, npm_g, #option, pip, requires, #run, #setup_git_credentials, #setup_git_ssh, #sha, shell, #uncleanup
Constructor Details
This class inherits a constructor from DPL::Provider
Instance Method Details
#api ⇒ Object
8
9
10
|
# File 'lib/dpl/provider/s3.rb', line 8
def api
@api ||= AWS::S3.new
end
|
#check_app ⇒ Object
16
17
18
|
# File 'lib/dpl/provider/s3.rb', line 16
def check_app
end
|
#check_auth ⇒ Object
24
25
26
27
|
# File 'lib/dpl/provider/s3.rb', line 24
def check_auth
setup_auth
log "Logging in with Access Key: #{option(:access_key_id)[-4..-1].rjust(20, '*')}"
end
|
#deploy ⇒ Object
41
42
43
44
45
46
47
48
49
|
# File 'lib/dpl/provider/s3.rb', line 41
def deploy
super
rescue AWS::S3::Errors::InvalidAccessKeyId
raise Error, "Invalid S3 Access Key Id, Stopping Deploy"
rescue AWS::S3::Errors::SignatureDoesNotMatch
raise Error, "Aws Secret Key does not match Access Key Id, Stopping Deploy"
rescue AWS::S3::Errors::AccessDenied
raise Error, "Oops, It looks like you tried to write to a bucket that isn't yours or doesn't exist yet. Please create the bucket before trying to write to it."
end
|
#needs_key? ⇒ Boolean
12
13
14
|
# File 'lib/dpl/provider/s3.rb', line 12
def needs_key?
false
end
|
#push_app ⇒ Object
33
34
35
36
37
38
39
|
# File 'lib/dpl/provider/s3.rb', line 33
def push_app
Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
Dir.glob("**/*") do |filename|
api.buckets[option(:bucket)].objects.create(upload_path(filename), File.read(filename)) unless File.directory?(filename)
end
end
end
|
#setup_auth ⇒ Object
20
21
22
|
# File 'lib/dpl/provider/s3.rb', line 20
def setup_auth
AWS.config(:access_key_id => option(:access_key_id), :secret_access_key => option(:secret_access_key))
end
|
#upload_path(filename) ⇒ Object
29
30
31
|
# File 'lib/dpl/provider/s3.rb', line 29
def upload_path(filename)
[options[:upload_dir], filename].compact.join("/")
end
|