From 69d615d156cef38c8e7419bb18d56ccaba5e7b6f Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Fri, 27 Apr 2018 21:16:32 -0700 Subject: [PATCH] Add some defensive code. --- node-client/src/config.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/node-client/src/config.ts b/node-client/src/config.ts index 7bb10a6caa..d5f8fb6dee 100644 --- a/node-client/src/config.ts +++ b/node-client/src/config.ts @@ -160,6 +160,9 @@ export class KubeConfig { } if (token) { + if (!opts.headers) { + opts.headers = []; + } opts.headers['Authorization'] = token; } } @@ -239,6 +242,9 @@ export class Config { k8sApi.setDefaultAuthentication({ 'applyToRequest': (opts) => { opts.ca = caCert; + if (!opts.headers) { + opts.headers = []; + } opts.headers['Authorization'] = 'Bearer ' + token; } });