File tree 2 files changed +21
-0
lines changed
2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ const os = require('os');
7
7
const _ = require ( 'lodash' ) ;
8
8
const google = require ( 'googleapis' ) . google ;
9
9
10
+ const packageJson = require ( '../package.json' ) ;
11
+
10
12
const constants = {
11
13
providerName : 'google' ,
12
14
} ;
@@ -21,7 +23,18 @@ class GoogleProvider {
21
23
this . provider = this ; // only load plugin in a Google service context
22
24
this . serverless . setProvider ( constants . providerName , this ) ;
23
25
26
+ const serverlessVersion = this . serverless . version ;
27
+ const pluginVersion = packageJson . version ;
28
+ const googleApisVersion = packageJson . dependencies . googleapis ;
29
+
30
+ google . options ( {
31
+ headers : {
32
+ 'User-Agent' : `Serverless/${ serverlessVersion } Serverless-Google-Provider/${ pluginVersion } Googleapis/${ googleApisVersion } ` ,
33
+ } ,
34
+ } ) ;
35
+
24
36
this . sdk = {
37
+ google,
25
38
deploymentmanager : google . deploymentmanager ( 'v2' ) ,
26
39
storage : google . storage ( 'v1' ) ,
27
40
logging : google . logging ( 'v2' ) ,
Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ describe('GoogleProvider', () => {
18
18
19
19
beforeEach ( ( ) => {
20
20
serverless = new Serverless ( ) ;
21
+ serverless . version = '1.0.0' ;
21
22
serverless . service = {
22
23
provider : {
23
24
project : 'example-project' ,
@@ -58,6 +59,8 @@ describe('GoogleProvider', () => {
58
59
} ) ;
59
60
60
61
it ( 'should set the used SDKs' , ( ) => {
62
+ expect ( googleProvider . sdk . google ) . toBeDefined ( ) ;
63
+
61
64
expect ( googleProvider . sdk . deploymentmanager )
62
65
. toBeDefined ( ) ;
63
66
@@ -70,6 +73,11 @@ describe('GoogleProvider', () => {
70
73
expect ( googleProvider . sdk . cloudfunctions )
71
74
. toBeDefined ( ) ;
72
75
} ) ;
76
+
77
+ it ( 'should set the google options' , ( ) => {
78
+ expect ( google . _options . headers [ 'User-Agent' ] ) // eslint-disable-line no-underscore-dangle
79
+ . toMatch ( / S e r v e r l e s s \/ .+ S e r v e r l e s s - G o o g l e - P r o v i d e r \/ .+ G o o g l e a p i s \/ .+ / ) ;
80
+ } ) ;
73
81
} ) ;
74
82
75
83
describe ( '#request()' , ( ) => {
You can’t perform that action at this time.
0 commit comments