Skip to content

Conversation

@inlined
Copy link
Member

@inlined inlined commented Jun 8, 2021

This PR builds upon #3464 (subset of this diff) to add the first steps of discovery documents.

We can successfully read functions/backend.yaml to decide what to deploy as well as launching a service and reading from /__/backend.yaml. Currently the response from /__/backend.yaml is hard coded.

inlined and others added 6 commits June 7, 2021 19:06
* Unbreak build

* linter changed its mind
#3457)

The firestore:delete command should notify the user of the current project. This should help users minimize chances of accidental deletions when switching between projects.
When the optional feature parameter is provided in a `firebase init
[feature]` command, this checks that its value is a valid choice before
attempting any other initialization.
@inlined inlined requested a review from hiranya911 June 8, 2021 21:49
@google-cla google-cla bot added the cla: yes Manual indication that this has passed CLA. label Jun 8, 2021
@inlined inlined force-pushed the inlined.detect-backend-yaml branch from 22e4187 to d2994c3 Compare June 8, 2021 22:01
dependabot bot and others added 21 commits June 9, 2021 08:20
Bumps [trim-newlines](https://github.com/sindresorhus/trim-newlines) from 3.0.0 to 3.0.1.
- [Release notes](https://github.com/sindresorhus/trim-newlines/releases)
- [Commits](https://github.com/sindresorhus/trim-newlines/commits)

---
updated-dependencies:
- dependency-name: trim-newlines
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [normalize-url](https://github.com/sindresorhus/normalize-url) from 4.5.0 to 4.5.1.
- [Release notes](https://github.com/sindresorhus/normalize-url/releases)
- [Commits](https://github.com/sindresorhus/normalize-url/commits)

---
updated-dependencies:
- dependency-name: normalize-url
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
added note to run `npm install` before `npm link` the first time
inlined and others added 7 commits June 24, 2021 19:12
Basic create support

This change adds support for `firebase --open-sesame golang`.

After running this command, `firebase init` will support Go 1.13
as a langauge for Cloud Functions.

Limitations:

1. Customers cannot mix Node and Go code (WAI)
2. There is little validation being done of customer code
3. The actual deployed function params are hard coded; SDK incoming
\To import modules packaged as ES module, we have to use import instead of require. Both the emulator and function deploy code hardcodes require to load user's function code and ends up throwing ERR_REQUIRE_ESM when given ES modules.

We will now try using import when require fails with an ERR_REQUIRE_ESM error. This is a bit lazy - we could've detected whether given module is ES module vs CommonJS and dispatch require vs import appropriately - but I think it simplifies the script while still being correct.
@inlined inlined force-pushed the inlined.detect-backend-yaml branch from a513a2e to feda382 Compare July 3, 2021 01:36
The primary purpose of this change is to introduce the "discovery"
subpackage of "runtimes". This package is a common utility that all
runtimes will use to discover their backend spec based on the "container
contract" being finalized currently.

The container contract says that we must interact with customer code
using tools we'd have in a docker container: a fully-contained directory
of code, a "run" command, and environment variables. Backend specs can
be discovered as:

1. The file /backend.yaml at the root of the container
2. The response to http://localhost:${ADMIN_PORT}/backend.yaml when
   running the container's RUN command with ADMIN_PORT set to a free
   port.

The golang runtime fulfills #2 through two steps:

1. The Functions SDK includes the "codegen" package that reads the
   customer code and creates an "autogen" main package that runs
   the customer code as the Firebase runtime (skeleton implementation
   currently).
2. We then start up the Firebase runtime with ADMIN_PORT set and
   fetch /backend.yaml

After this + a minor fix to the template code, we have working Go
deploys!

I also moved gomod parsing into its own file to keep index.ts to a
minimal set of things that aren't easily unit tested. Unfortunately
the diff is largr than it needs to be now.
@inlined inlined force-pushed the inlined.detect-backend-yaml branch from feda382 to 7a1c5bc Compare July 3, 2021 01:48
anishkny and others added 18 commits July 7, 2021 09:40
Emulator does not log about the default being used for any other option. Why log about default used for `sourceDirectory`? Seems unnecessary.
… extension configurations (#3529)

* fixes a number of issues where ext:dev:emulator:* did not allow valid extension configurations

* Adding tests for cases fixed

* add changelog

* format

* pr fixes

* correct a comment
Today, function logs with structured data (e.g. those generated using firebase-functions SDK's logger api) do not show up in `firebase functions:log` command:

```js
// index.js
exports.hello = functions.https.onRequest((request, response) => {
  info("Hello logs!", {structuredData: true});
  info("hello world!");
  response.send("Hello from Firebase!");
});
```

```bash
$ firebase functions:log
2021-06-30T12:47:42.955491814Z D hello: Function execution started
2021-06-30T12:47:43.050Z I hello: # LOOK HERE: where's the message?
2021-06-30T12:47:43.050Z I hello: hello world!
2021-06-30T12:47:43.061418239Z D hello: Function execution took 107 ms, finished with status code: 200
```

This happens because structured log entries are stored in [`jsonPayload` field](https://cloud.google.com/logging/docs/structured-logging), not `textPayload` field.

In addition to correctly parsing `jsonPayload` field, we will also correctly parse log entries with `protoPayload` fields (in most cases, these log entries come from audit logs).

*After*
```bash
2021-06-30T12:47:42.955491814Z D hello: Function execution started
2021-06-30T12:47:43.050Z I hello: {"message":"Hello logs!","structuredData":true}
2021-06-30T12:47:43.050Z I hello: hello world!
2021-06-30T12:47:43.061418239Z D hello: Function execution took 107 ms, finished with status code: 200
```
* Release Firestore Emulator v1.6.0.

* Fix checksums.

* CHANGLOG.
@inlined inlined closed this Jul 19, 2021
@bkendall bkendall deleted the inlined.detect-backend-yaml branch March 18, 2022 23:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Manual indication that this has passed CLA.

Projects

None yet

Development

Successfully merging this pull request may close these issues.