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
9
10
11
|
# File 'lib/dpl/provider/s3.rb', line 9
def api
@api ||= AWS::S3.new(endpoint: options[:endpoint] || 's3.amazonaws.com')
end
|
#check_app ⇒ Object
17
18
19
|
# File 'lib/dpl/provider/s3.rb', line 17
def check_app
end
|
#check_auth ⇒ Object
25
26
27
28
|
# File 'lib/dpl/provider/s3.rb', line 25
def check_auth
setup_auth
log "Logging in with Access Key: #{option(:access_key_id)[-4..-1].rjust(20, '*')}"
end
|
#deploy ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/dpl/provider/s3.rb', line 43
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
13
14
15
|
# File 'lib/dpl/provider/s3.rb', line 13
def needs_key?
false
end
|
#push_app ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/dpl/provider/s3.rb', line 34
def push_app
Dir.chdir(options.fetch(:local_dir, Dir.pwd)) do
Dir.glob("**/*") do |filename|
content_type = MIME::Types.type_for(filename).first.to_s
api.buckets[option(:bucket)].objects.create(upload_path(filename), File.read(filename), :content_type => content_type) unless File.directory?(filename)
end
end
end
|
#setup_auth ⇒ Object
21
22
23
|
# File 'lib/dpl/provider/s3.rb', line 21
def setup_auth
AWS.config(:access_key_id => option(:access_key_id), :secret_access_key => option(:secret_access_key), :region => options[:region]||'us-east-1')
end
|
#upload_path(filename) ⇒ Object
30
31
32
|
# File 'lib/dpl/provider/s3.rb', line 30
def upload_path(filename)
[options[:upload_dir], filename].compact.join("/")
end
|