Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Give secret params a .value() method #1281

Merged
merged 8 commits into from Oct 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions spec/params/params.spec.ts
Expand Up @@ -27,6 +27,7 @@ describe("Params value extraction", () => {
process.env.PI = "3.14159";
process.env.TRUE = "true";
process.env.FALSE = "false";
process.env.A_SECRET_STRING = "123456supersecret";
});

afterEach(() => {
Expand All @@ -41,6 +42,7 @@ describe("Params value extraction", () => {
delete process.env.PI;
delete process.env.TRUE;
delete process.env.FALSE;
delete process.env.A_SECRET_STRING;
});

it("extracts identity params from the environment", () => {
Expand All @@ -58,6 +60,9 @@ describe("Params value extraction", () => {

const falseParam = params.defineBoolean("FALSE");
expect(falseParam.value()).to.be.false;

const secretParam = params.defineSecret("A_SECRET_STRING");
expect(secretParam.value()).to.equal("123456supersecret");
});

it("extracts the special case internal params from env.FIREBASE_CONFIG", () => {
Expand Down
3 changes: 2 additions & 1 deletion src/params/types.ts
Expand Up @@ -335,11 +335,12 @@ export abstract class Param<T extends string | number | boolean | string[]> exte
* the secrets array while defining a Function to make their values accessible
* during execution of that Function.
*/
export class SecretParam {
export class SecretParam extends Expression<string> {
static type: ParamValueType = "secret";
name: string;

constructor(name: string) {
super();
this.name = name;
}

Expand Down