Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: firebase/firebase-functions
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v3.18.0
Choose a base ref
...
head repository: firebase/firebase-functions
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v3.18.1
Choose a head ref
  • 4 commits
  • 6 files changed
  • 2 contributors

Commits on Feb 11, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    f68e629 View commit details

Commits on Feb 15, 2022

  1. Expose stack on functions.yaml instead of stack.yaml. (#1036)

    Some contractual changes to how we expose the container contract:
    
    * We will expose `__/functions.yaml` instead of `__/stack.yaml` in the control api
    * Environment variables for exposing the control api changes from `STACK_CONTROL_API_PORT` to `PORT` and `FUNCTIONS_CONTROL_API` (whose value should equal `true`).
    taeold authored Feb 15, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b3a549d View commit details

Commits on Feb 17, 2022

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    069695b View commit details

Commits on Feb 18, 2022

  1. 3.18.1

    google-oss-bot committed Feb 18, 2022

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    0345715 View commit details
Showing with 28 additions and 25 deletions.
  1. +1 −1 CHANGELOG.md
  2. +2 −2 package-lock.json
  3. +1 −1 package.json
  4. +7 −6 scripts/bin-test/test.ts
  5. +16 −13 src/bin/firebase-functions.ts
  6. +1 −2 src/runtime/loader.ts
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
- Add new runtime option for setting secrets.
- Expose stack YAML via \_\_/functions.yaml endpoint instead (#1036).
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firebase-functions",
"version": "3.18.0",
"version": "3.18.1",
"description": "Firebase SDK for Cloud Functions",
"keywords": [
"firebase",
13 changes: 7 additions & 6 deletions scripts/bin-test/test.ts
Original file line number Diff line number Diff line change
@@ -85,7 +85,8 @@ async function startBin(
env: {
PATH: process.env.PATH,
GLCOUD_PROJECT: 'test-project',
STACK_CONTROL_API_PORT: port,
PORT: port,
FUNCTIONS_CONTROL_API: 'true',
},
});

@@ -95,7 +96,7 @@ async function startBin(

await retryUntil(async () => {
try {
await fetch(`http://localhost:${port}/__/stack.yaml`);
await fetch(`http://localhost:${port}/__/functions.yaml`);
} catch (e) {
if (e?.code === 'ECONNREFUSED') {
return false;
@@ -132,7 +133,7 @@ async function startBin(
};
}

describe('stack.yaml', () => {
describe('functions.yaml', () => {
async function runTests(tc: Testcase) {
let port: number;
let cleanup: () => Promise<void>;
@@ -147,14 +148,14 @@ describe('stack.yaml', () => {
await cleanup?.();
});

it('stack.yaml returns expected Manifest', async () => {
const res = await fetch(`http://localhost:${port}/__/stack.yaml`);
it('functions.yaml returns expected Manifest', async () => {
const res = await fetch(`http://localhost:${port}/__/functions.yaml`);
const text = await res.text();
let parsed: any;
try {
parsed = yaml.load(text);
} catch (err) {
throw new Error('Failed to parse stack.yaml ' + err);
throw new Error('Failed to parse functions.yaml ' + err);
}
expect(parsed).to.be.deep.equal(tc.expected);
});
29 changes: 16 additions & 13 deletions src/bin/firebase-functions.ts
Original file line number Diff line number Diff line change
@@ -35,21 +35,24 @@ async function handleQuitquitquit(req: express.Request, res: express.Response) {

app.get('/__/quitquitquit', handleQuitquitquit);
app.post('/__/quitquitquit', handleQuitquitquit);
app.get('/__/stack.yaml', async (req, res) => {
try {
const stack = await loadStack(functionsDir);
res.setHeader('content-type', 'text/yaml');
res.send(JSON.stringify(stack));
} catch (e) {
res
.status(400)
.send(`Failed to generate manifest from function source: ${e}`);
}
});

if (process.env.FUNCTIONS_CONTROL_API === 'true') {
app.get('/__/functions.yaml', async (req, res) => {
try {
const stack = await loadStack(functionsDir);
res.setHeader('content-type', 'text/yaml');
res.send(JSON.stringify(stack));
} catch (e) {
res
.status(400)
.send(`Failed to generate manifest from function source: ${e}`);
}
});
}

let port = 8080;
if (process.env.STACK_CONTROL_API_PORT) {
port = Number.parseInt(process.env.STACK_CONTROL_API_PORT);
if (process.env.PORT) {
port = Number.parseInt(process.env.PORT);
}

console.log('Serving at port', port);
3 changes: 1 addition & 2 deletions src/runtime/loader.ts
Original file line number Diff line number Diff line change
@@ -110,10 +110,9 @@ export async function loadStack(functionsDir: string): Promise<ManifestStack> {

extractStack(mod, endpoints, requiredAPIs);

const stack: ManifestStack = {
return {
endpoints,
specVersion: 'v1alpha1',
requiredAPIs: mergeRequiredAPIs(requiredAPIs),
};
return stack;
}