Skip to content

Commit

Permalink
Interate over all lambda functions
Browse files Browse the repository at this point in the history
Not just the functions returned by the first call to `#list_functions`.
  • Loading branch information
BanzaiMan committed May 18, 2017
1 parent ab3f98c commit 99bda55
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
17 changes: 14 additions & 3 deletions lib/dpl/provider/lambda.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ def push_app

function_name = options[:name] || option(:function_name)

response = lambda.list_functions

if response.functions.any? { |function| function.function_name == function_name }
if all_lambda_functions.any? { |function| function.function_name == function_name }

log "Function #{function_name} already exists, updating."

Expand Down Expand Up @@ -180,6 +178,19 @@ def cleanup

def uncleanup
end

def all_lambda_functions
response = lambda.list_functions
functions = response.functions
marker = response.next_marker
until marker.empty? do
response = lambda.list_functions(marker: marker)
functions += response.functions
marker = response.next_marker
end

functions
end
end
end
end
4 changes: 3 additions & 1 deletion spec/provider/lambda_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@
}

list_functions_response = {
next_marker: "", # no more functions
functions: [
{ function_name: 'test-function' }
]
}

empty_list_functions_response = {
functions: [ ]
next_marker: "",
functions: [ ]
}

example_response = {
Expand Down

0 comments on commit 99bda55

Please sign in to comment.