in lib/functions_framework/cli.rb [196:215]
def load_function
::FunctionsFramework.logger.level = @logging_level
::FunctionsFramework.logger.info "FunctionsFramework v#{VERSION}"
::ENV["FUNCTION_TARGET"] = @target
::ENV["FUNCTION_SOURCE"] = @source
::ENV["FUNCTION_SIGNATURE_TYPE"] = @signature_type
::FunctionsFramework.logger.info "FunctionsFramework: Loading functions from #{@source.inspect}..."
load @source
::FunctionsFramework.logger.info "FunctionsFramework: Looking for function name #{@target.inspect}..."
function = ::FunctionsFramework.global_registry[@target]
raise "Undefined function: #{@target.inspect}" if function.nil?
unless @signature_type.nil? ||
(@signature_type == "http" && function.type == :http) ||
(@signature_type == "http" && function.type == :typed) ||
(["cloudevent", "event"].include?(@signature_type) && function.type == :cloud_event)
raise "Function #{@target.inspect} does not match type #{@signature_type}"
end
function
end