File tree Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Expand file tree Collapse file tree 2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export enum GCPEnv {
2020 CLOUD_FUNCTIONS = 'CLOUD_FUNCTIONS' ,
2121 COMPUTE_ENGINE = 'COMPUTE_ENGINE' ,
2222 CLOUD_RUN = 'CLOUD_RUN' ,
23+ CLOUD_RUN_JOBS = 'CLOUD_RUN_JOBS' ,
2324 NONE = 'NONE' ,
2425}
2526
@@ -48,6 +49,8 @@ async function getEnvMemoized(): Promise<GCPEnv> {
4849 env = GCPEnv . KUBERNETES_ENGINE ;
4950 } else if ( isCloudRun ( ) ) {
5051 env = GCPEnv . CLOUD_RUN ;
52+ } else if ( isCloudRunJob ( ) ) {
53+ env = GCPEnv . CLOUD_RUN_JOBS ;
5154 } else {
5255 env = GCPEnv . COMPUTE_ENGINE ;
5356 }
@@ -74,6 +77,10 @@ function isCloudRun() {
7477 return ! ! process . env . K_CONFIGURATION ;
7578}
7679
80+ function isCloudRunJob ( ) {
81+ return ! ! process . env . CLOUD_RUN_JOB ;
82+ }
83+
7784async function isKubernetesEngine ( ) {
7885 try {
7986 await gcpMetadata . instance ( 'attributes/cluster-name' ) ;
Original file line number Diff line number Diff line change @@ -1449,6 +1449,14 @@ describe('googleauth', () => {
14491449 assert . strictEqual ( env , envDetect . GCPEnv . CLOUD_RUN ) ;
14501450 } ) ;
14511451
1452+ it ( 'should get the current environment if Cloud Run Jobs' , async ( ) => {
1453+ envDetect . clear ( ) ;
1454+ mockEnvVar ( 'CLOUD_RUN_JOB' , 'KITTY' ) ;
1455+ const { auth} = mockGCE ( ) ;
1456+ const env = await auth . getEnv ( ) ;
1457+ assert . strictEqual ( env , envDetect . GCPEnv . CLOUD_RUN_JOBS ) ;
1458+ } ) ;
1459+
14521460 it ( 'should make the request via `#fetch`' , async ( ) => {
14531461 const url = 'http://example.com' ;
14541462 const { auth, scopes} = mockGCE ( ) ;
You can’t perform that action at this time.
0 commit comments