convert_source service, resource, domain

in lib/functions_framework/legacy_event_converter.rb [132:155]


    def convert_source service, resource, domain
      return ["//#{service}/#{resource}", nil] unless CE_SERVICE_TO_RESOURCE_RE.key? service

      match = CE_SERVICE_TO_RESOURCE_RE[service].match resource
      return [nil, nil] unless match
      resource_fragment = match[1]
      subject = match[2]

      if service == "firebasedatabase.googleapis.com"
        location =
          case domain
          when "firebaseio.com"
            "us-central1"
          when /^([\w-]+)\./
            Regexp.last_match[1]
          else
            return [nil, nil]
          end
        ["//#{service}/projects/_/locations/#{location}/#{resource_fragment}", subject]
      else
        ["//#{service}/#{resource_fragment}", subject]
      end
    end