File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,23 @@ describe('config()', () => {
4747 ( config as any ) . firebaseConfigCache = null ;
4848 delete process . env . FIREBASE_CONFIG ;
4949 delete process . env . CLOUD_RUNTIME_CONFIG ;
50+ delete process . env . K_CONFIGURATION ;
51+ } ) ;
52+
53+ it ( 'will never load in GCFv2' , ( ) => {
54+ const json = JSON . stringify ( {
55+ foo : 'bar' ,
56+ firebase : { } ,
57+ } ) ;
58+ readFileSync
59+ . withArgs ( '/srv/.runtimeconfig.json' )
60+ . returns ( Buffer . from ( json ) ) ;
61+
62+ process . env . K_CONFIGURATION = 'my-service' ;
63+ expect ( ( ) => config . config ( ) ) . to . throw (
64+ Error ,
65+ / t r a n s i t i o n t o u s i n g e n v i r o n m e n t v a r i a b l e s /
66+ ) ;
5067 } ) ;
5168
5269 it ( 'loads config values from .runtimeconfig.json' , ( ) => {
Original file line number Diff line number Diff line change @@ -26,6 +26,14 @@ import * as path from 'path';
2626import * as firebase from 'firebase-admin' ;
2727
2828export function config ( ) : config . Config {
29+ // K_CONFIGURATION is only set in GCFv2
30+ if ( process . env . K_CONFIGURATION ) {
31+ throw new Error (
32+ 'functions.config() is no longer available in Cloud Functions for ' +
33+ 'Firebase v2. Please see the latest documentation for information ' +
34+ 'on how to transition to using environment variables'
35+ ) ;
36+ }
2937 if ( typeof config . singleton === 'undefined' ) {
3038 init ( ) ;
3139 }
You can’t perform that action at this time.
0 commit comments