Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3ad62e2
wip: expr type
Berlioz Jul 19, 2022
5f8cccb
npm run prettier
Berlioz Jul 19, 2022
b7f879b
trigger fields
Berlioz Jul 20, 2022
48f2d9a
more detailed expr type
Berlioz Jul 21, 2022
bf6c420
Merge remote-tracking branch 'origin' into vf_expr_type
Berlioz Jul 21, 2022
b6d592e
Merge remote-tracking branch 'origin' into vf_expr_type
Berlioz Jul 28, 2022
e274fc7
wip: in-progress commit for providing params and param-valued fields …
Berlioz Aug 2, 2022
c00c2f7
wip: regexp validation
Berlioz Aug 2, 2022
66cffc9
resourceInput selectors
Berlioz Aug 9, 2022
156a21d
remove extraneous changes to triggerannotation which is no longer in use
Berlioz Aug 9, 2022
1089043
wip class-ification of expression type
Berlioz Aug 11, 2022
b0a9063
wip: split wire/manifest spec
Berlioz Aug 12, 2022
8942e5c
WIP: classification of Expressions
Berlioz Aug 15, 2022
3778deb
WIP: add value() semantics to params and expressions
Berlioz Aug 16, 2022
6379cc3
type system changes to conform with go/cf3-params-detailed
Berlioz Aug 17, 2022
27937eb
style fixes per review
Berlioz Aug 17, 2022
df07167
removed shotgun testing change
Berlioz Aug 18, 2022
aaf3dda
changes per review, most substantially making param inputs an optiona…
Berlioz Aug 25, 2022
d4bf770
merge experssions.ts with params.ts
Berlioz Aug 25, 2022
a114386
remove empty expressions.ts
Berlioz Aug 25, 2022
8c3447b
Merge remote-tracking branch 'origin' into vf_expr_type
Berlioz Aug 29, 2022
f63c895
nits per pr
Berlioz Aug 29, 2022
2c67693
typo
Berlioz Aug 29, 2022
251aa43
format fix
Berlioz Aug 29, 2022
47e2330
timezone -> timeZone, and fix SelectInput
Berlioz Aug 30, 2022
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion package-lock.json

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

12 changes: 10 additions & 2 deletions spec/fixtures/sources/commonjs-params/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
const functions = require("../../../../src/index");
const functionsv2 = require("../../../../src/v2/index");
const { defineString } = require("../../../../src/v2/params");
const params = require("../../../../src/v2/params");

defineString("FOO");
params.defineString("BORING");
params.defineString("FOO", {input: {text: {validationRegex:"\w+"}}});
params.defineString("BAR", {default: "{{ params.FOO }}", label: "asdf"});
params.defineString("BAZ", {input: {select: {options: [{value: "a"}, {value: "b"}]}}});

params.defineInt("AN_INT", {default: 22});
params.defineInt("ANOTHER_INT", {input: {select: {options:[{label: "a", value: -2}, {"label": "b", value: 2}]}}});

params.defineSecret("SUPER_SECRET_FLAG")

exports.v1http = functions.https.onRequest((req, resp) => {
resp.status(200).send("PASS");
Expand Down
41 changes: 40 additions & 1 deletion spec/runtime/loader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
ManifestRequiredAPI,
ManifestStack,
} from '../../src/runtime/manifest';
import { clearParams } from '../../src/v2/params';

describe('extractStack', () => {
const httpFn = functions.https.onRequest(() => {});
Expand Down Expand Up @@ -104,6 +105,7 @@ describe('extractStack', () => {

afterEach(() => {
process.env.GCLOUD_PROJECT = prev;
clearParams();
});

it('extracts stack from a simple module', () => {
Expand Down Expand Up @@ -313,7 +315,44 @@ describe('loadStack', () => {
{
name: 'has params',
modulePath: './spec/fixtures/sources/commonjs-params',
expected: { ...expected, params: [{ name: 'FOO', type: 'string' }] },
expected: {
...expected,
params: [
{ name: 'BORING', type: 'string' },
{
name: 'FOO',
type: 'string',
input: { text: { validationRegex: 'w+' } },
},
{
name: 'BAR',
type: 'string',
default: '{{ params.FOO }}',
label: 'asdf',
},
{
name: 'BAZ',
type: 'string',
input: {
select: { options: [{ value: 'a' }, { value: 'b' }] },
},
},
{ name: 'AN_INT', type: 'int', default: 22 },
{
name: 'ANOTHER_INT',
type: 'int',
input: {
select: {
options: [
{ label: 'a', value: -2 },
{ label: 'b', value: 2 },
],
},
},
},
{ name: 'SUPER_SECRET_FLAG', type: 'secret' },
],
},
},
];

Expand Down
67 changes: 67 additions & 0 deletions spec/runtime/manifest.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { stackToWire, ManifestStack } from '../../src/runtime/manifest';
import { expect } from 'chai';
import * as params from '../../src/v2/params';

describe('stackToWire', () => {
afterEach(() => {
params.clearParams();
});

it('converts Expression types in endpoint options to CEL', () => {
const intParam = params.defineInt('foo', { default: 11 });
const stringParam = params.defineString('bar', {
default: 'America/Los_Angeles',
});

const stack: ManifestStack = {
endpoints: {
v2http: {
platform: 'gcfv2',
entryPoint: 'v2http',
labels: {},
httpsTrigger: {},
concurrency: intParam,
maxInstances: intParam.equals(24).then(-1, 1),
},
v2schedule: {
platform: 'gcfv2',
entryPoint: 'v2callable',
labels: {},
scheduleTrigger: {
schedule: stringParam
.equals('America/Mexico_City')
.then('mexico', 'usa'),
timeZone: stringParam,
},
},
},
requiredAPIs: [],
specVersion: 'v1alpha1',
};
const expected = {
endpoints: {
v2http: {
platform: 'gcfv2',
entryPoint: 'v2http',
labels: {},
httpsTrigger: {},
concurrency: '{{ params.foo }}',
maxInstances: '{{ params.foo == 24 ? -1 : 1 }}',
},
v2schedule: {
platform: 'gcfv2',
entryPoint: 'v2callable',
labels: {},
scheduleTrigger: {
schedule:
'{{ params.bar == "America/Mexico_City" ? "mexico" : "usa" }}',
timeZone: '{{ params.bar }}',
},
},
},
requiredAPIs: [],
specVersion: 'v1alpha1',
};
expect(stackToWire(stack)).to.deep.equal(expected);
});
});
Loading