Skip to content

Commit

Permalink
Merge ac56891 into d9a4421
Browse files Browse the repository at this point in the history
  • Loading branch information
svenfuchs committed Aug 21, 2019
2 parents d9a4421 + ac56891 commit 0dc6d0b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 5 deletions.
28 changes: 23 additions & 5 deletions lib/dpl/providers/lambda.rb
Expand Up @@ -129,11 +129,7 @@ def function_code
end

def handler
[module_name, java? ? '::' : '.', handler_name].join if handler_name?
end

def java?
runtime =~ /java/
Handler.new(runtime, module_name, handler_name).to_s if handler_name?
end

def function_zip
Expand Down Expand Up @@ -179,6 +175,28 @@ def split_vars(vars)
def tmp_filename
@tmp_filename ||= "#{tmp_dir}/#{repo_name}.zip"
end

class Handler < Struct.new(:runtime, :module_name, :handler_name)
SEP = {
default: '.',
java: '::',
dotnet: '::',
go: ''
}

def to_s
[go? ? nil : module_name, sep, handler_name].compact.join
end

def sep
key = SEP.keys.detect { |key| runtime.start_with?(key.to_s) }
SEP[key || :default]
end

def go?
runtime.start_with?('go')
end
end
end
end
end
8 changes: 8 additions & 0 deletions spec/dpl/providers/lambda_spec.rb
Expand Up @@ -68,6 +68,14 @@
it { should create_function Handler: 'index::handler' }
end

describe 'given --runtime dotnetcore2.1' do
it { should create_function Handler: 'index::handler' }
end

describe 'given --runtime go1.x' do
it { should create_function Handler: 'handler' }
end

describe 'given --subnet_ids one --subnet_ids two' do
it { should create_function VpcConfig: { SubnetIds: ['one', 'two'] } }
end
Expand Down

0 comments on commit 0dc6d0b

Please sign in to comment.