@@ -3,7 +3,7 @@ const CFError = require('cf-errors');
3
3
const cmd = require ( '../base.cmd' ) ;
4
4
const { sdk } = require ( '../../../../../../../logic' ) ;
5
5
6
- function buildAuthObject ( { token, username, password, roleId, secretId, loginPath } ) {
6
+ function buildAuthObject ( { token, username, password, roleId, secretId, loginPath, gcpRole , kubernetesRole , kubernetesJwt } ) {
7
7
const mountPoint = loginPath ? { mount_point : loginPath } : { } ;
8
8
if ( token ) {
9
9
return { type : 'token' , token, ...mountPoint } ;
@@ -17,6 +17,19 @@ function buildAuthObject({ token, username, password, roleId, secretId, loginPat
17
17
return { type : 'approle' , role_id : roleId , secret_id : secretId , ...mountPoint } ;
18
18
}
19
19
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
+
20
33
throw new CFError ( 'missing authentication info' ) ;
21
34
}
22
35
@@ -27,56 +40,71 @@ const command = new Command({
27
40
usage : cmd . usage ,
28
41
webDocs : {
29
42
category : 'Create Secret-Store Context' ,
30
- subCategory : 'vault' ,
31
- title : 'vault' ,
43
+ subCategory : 'hashicorp- vault' ,
44
+ title : 'hashicorp- vault' ,
32
45
weight : 10 ,
33
46
} ,
34
47
builder ( yargs ) {
35
48
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
+ } )
36
54
. option ( 'api-url' , {
37
55
alias : 'a' ,
38
56
describe : 'URL of the vault server' ,
39
57
type : 'string' ,
40
58
required : true ,
41
59
} )
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
+ } )
42
64
. option ( 'token' , {
43
65
alias : 't' ,
44
66
describe : 'Token' ,
45
67
type : 'string' ,
46
- conflicts : [ 'username' , 'password' , 'roleId' , 'secretId' ] ,
68
+ conflicts : [ 'username' , 'password' , 'roleId' , 'secretId' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
47
69
} )
48
70
. option ( 'username' , {
49
71
describe : 'Username' ,
50
72
alias : 'u' ,
51
73
type : 'string' ,
52
- conflicts : [ 'token' , 'roleId' , 'secretId' ] ,
74
+ conflicts : [ 'token' , 'roleId' , 'secretId' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
53
75
} )
54
76
. option ( 'password' , {
55
77
describe : 'Password' ,
56
78
alias : 'p' ,
57
79
type : 'string' ,
58
- conflicts : [ 'token' , 'roleId' , 'secretId' ] ,
80
+ conflicts : [ 'token' , 'roleId' , 'secretId' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
59
81
} )
60
82
. option ( 'role-id' , {
61
83
describe : 'Role Id' ,
62
84
alias : 'r' ,
63
85
type : 'string' ,
64
- conflicts : [ 'token' , 'username' , 'password' ] ,
86
+ conflicts : [ 'token' , 'username' , 'password' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
65
87
} )
66
88
. option ( 'secret-id' , {
67
89
describe : 'Secret Id' ,
68
90
alias : 's' ,
69
91
type : 'string' ,
70
- conflicts : [ 'token' , 'username' , 'password' ] ,
92
+ conflicts : [ 'token' , 'username' , 'password' , 'gcp-role' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
71
93
} )
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 ' ,
74
96
type : 'string' ,
97
+ conflicts : [ 'token' , 'username' , 'password' , 'role-id' , 'secret-id' , 'kubernetes-role' , 'kubernetes-jwt' ] ,
75
98
} )
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' ] ,
80
108
} )
81
109
. check ( buildAuthObject ) ;
82
110
} ,
0 commit comments