@@ -3,7 +3,7 @@ const CFError = require('cf-errors');
33const cmd = require ( '../base.cmd' ) ;
44const { sdk } = require ( '../../../../../../../logic' ) ;
55
6- function buildAuthObject ( { token, username, password, roleId, secretId, loginPath } ) {
6+ function buildAuthObject ( { token, username, password, roleId, secretId, loginPath, gcpRole , kubernetesRole , kubernetesJwt } ) {
77 const mountPoint = loginPath ? { mount_point : loginPath } : { } ;
88 if ( token ) {
99 return { type : 'token' , token, ...mountPoint } ;
@@ -17,6 +17,19 @@ function buildAuthObject({ token, username, password, roleId, secretId, loginPat
1717 return { type : 'approle' , role_id : roleId , secret_id : secretId , ...mountPoint } ;
1818 }
1919
20+ if ( gcpRole ) {
21+ return { type : 'gcp' , roleType : 'gce' , role : gcpRole , ...mountPoint } ;
22+ }
23+
24+ if ( kubernetesRole ) {
25+ return {
26+ type : 'kubernetes' ,
27+ role : kubernetesRole ,
28+ ...( kubernetesJwt && { jwt : kubernetesJwt } ) ,
29+ ...mountPoint ,
30+ } ;
31+ }
32+
2033 throw new CFError ( 'missing authentication info' ) ;
2134}
2235
@@ -27,56 +40,71 @@ const command = new Command({
2740 usage : cmd . usage ,
2841 webDocs : {
2942 category : 'Create Secret-Store Context' ,
30- subCategory : 'vault' ,
31- title : 'vault' ,
43+ subCategory : 'hashicorp- vault' ,
44+ title : 'hashicorp- vault' ,
3245 weight : 10 ,
3346 } ,
3447 builder ( yargs ) {
3548 return yargs
49+ . option ( 'behind-firewall' , {
50+ describe : 'Set to true to mark this context with behind firewall flag' ,
51+ type : 'boolean' ,
52+ default : false ,
53+ } )
3654 . option ( 'api-url' , {
3755 alias : 'a' ,
3856 describe : 'URL of the vault server' ,
3957 type : 'string' ,
4058 required : true ,
4159 } )
60+ . option ( 'login-path' , {
61+ describe : 'Path for given auth method. Leave out to use the default path for the type.' ,
62+ type : 'string' ,
63+ } )
4264 . option ( 'token' , {
4365 alias : 't' ,
4466 describe : 'Token' ,
4567 type : 'string' ,
46- conflicts : [ 'username' , 'password' , 'roleId' , 'secretId' ] ,
68+ conflicts : [ 'username' , 'password' , 'roleId' , 'secretId' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
4769 } )
4870 . option ( 'username' , {
4971 describe : 'Username' ,
5072 alias : 'u' ,
5173 type : 'string' ,
52- conflicts : [ 'token' , 'roleId' , 'secretId' ] ,
74+ conflicts : [ 'token' , 'roleId' , 'secretId' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
5375 } )
5476 . option ( 'password' , {
5577 describe : 'Password' ,
5678 alias : 'p' ,
5779 type : 'string' ,
58- conflicts : [ 'token' , 'roleId' , 'secretId' ] ,
80+ conflicts : [ 'token' , 'roleId' , 'secretId' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
5981 } )
6082 . option ( 'role-id' , {
6183 describe : 'Role Id' ,
6284 alias : 'r' ,
6385 type : 'string' ,
64- conflicts : [ 'token' , 'username' , 'password' ] ,
86+ conflicts : [ 'token' , 'username' , 'password' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
6587 } )
6688 . option ( 'secret-id' , {
6789 describe : 'Secret Id' ,
6890 alias : 's' ,
6991 type : 'string' ,
70- conflicts : [ 'token' , 'username' , 'password' ] ,
92+ conflicts : [ 'token' , 'username' , 'password' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
7193 } )
72- . option ( 'login-path ' , {
73- describe : 'Path for given auth method. Leave out to use the default path for the type. ' ,
94+ . option ( 'gcp-role ' , {
95+ describe : 'GCP Role ' ,
7496 type : 'string' ,
97+ conflicts : [ 'token' , 'username' , 'password' , 'role-id' , 'secret-id' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
7598 } )
76- . option ( 'behind-firewall' , {
77- describe : 'Set to true to mark this context with behind firewall flag' ,
78- type : 'boolean' ,
79- default : false ,
99+ . option ( 'kubernetes-role' , {
100+ describe : 'Kubernetes Role' ,
101+ type : 'string' ,
102+ conflicts : [ 'token' , 'username' , 'password' , 'role-id' , 'secret-id' , 'gcp-role' ] ,
103+ } )
104+ . option ( 'kubernetes-jwt' , {
105+ describe : 'Kubernetes Role' ,
106+ type : 'string' ,
107+ conflicts : [ 'token' , 'username' , 'password' , 'role-id' , 'secret-id' , 'gcp-role' ] ,
80108 } )
81109 . check ( buildAuthObject ) ;
82110 } ,
0 commit comments