@@ -155,15 +155,28 @@ describe('KubeConfig', () => {
155
155
156
156
describe ( 'loadFromCluster' , ( ) => {
157
157
let originalTokenPath : string | undefined ;
158
+ let originalCaFilePath : string | undefined ;
158
159
159
160
before ( ( ) => {
160
161
originalTokenPath = process . env [ 'TOKEN_FILE_PATH' ] ;
162
+ originalCaFilePath = process . env [ 'KUBERNETES_CA_FILE_PATH' ]
161
163
162
164
delete process . env [ 'TOKEN_FILE_PATH' ]
165
+ delete process . env [ 'KUBERNETES_CA_FILE_PATH' ]
163
166
} )
164
167
165
168
after ( ( ) => {
169
+
170
+ delete process . env [ 'TOKEN_FILE_PATH' ]
171
+ delete process . env [ 'KUBERNETES_CA_FILE_PATH' ]
172
+
173
+ if ( originalTokenPath ) {
166
174
process . env [ 'TOKEN_FILE_PATH' ] = originalTokenPath
175
+ }
176
+
177
+ if ( originalCaFilePath ) {
178
+ process . env [ 'KUBERNETES_CA_FILE_PATH' ] = originalCaFilePath
179
+ }
167
180
} )
168
181
169
182
it ( 'should load from default env vars' , ( ) => {
@@ -198,11 +211,13 @@ describe('KubeConfig', () => {
198
211
it ( 'should support custom token file path' , ( ) => {
199
212
const kc = new KubeConfig ( ) ;
200
213
process . env [ 'TOKEN_FILE_PATH' ] = '/etc/tokenFile'
214
+ process . env [ 'KUBERNETES_CA_FILE_PATH' ] = '/etc/ca.crt'
215
+
201
216
const cluster = {
202
217
name : 'inCluster' ,
203
218
server : 'https://undefined:undefined' ,
204
219
skipTLSVerify : false ,
205
- caFile : '/var/run/secrets/kubernetes.io/serviceaccount /ca.crt'
220
+ caFile : '/etc /ca.crt'
206
221
} as Cluster ;
207
222
208
223
const user = {
0 commit comments