File tree Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Expand file tree Collapse file tree 1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -132,6 +132,29 @@ describe('KubeConfig', () => {
132132 } ) ;
133133 } ) ;
134134
135+ describe ( 'loadFromCluster' , ( ) => {
136+ it ( 'should load from cluster' , ( ) => {
137+ process . env . KUBERNETES_SERVICE_HOST = 'example.com' ;
138+ process . env . KUBERNETES_SERVICE_PORT = '8080' ;
139+
140+ const kc = new KubeConfig ( ) ;
141+ kc . loadFromCluster ( ) ;
142+ const expectedCluster = {
143+ caFile : '/var/run/secrets/kubernetes.io/serviceaccount/ca.crt' ,
144+ name : 'inCluster' ,
145+ server : 'http://example.com:8080' ,
146+ skipTLSVerify : false ,
147+ } ;
148+
149+ process . env . KUBERNETES_SERVICE_HOST = undefined ;
150+ process . env . KUBERNETES_SERVICE_PORT = undefined ;
151+
152+ strictEqual ( kc . getCurrentContext ( ) , 'inClusterContext' ) ;
153+ deepEqual ( kc . getCurrentCluster ( ) , expectedCluster ) ;
154+ deepEqual ( kc . getCluster ( kc . getContextObject ( kc . getCurrentContext ( ) ) ! . cluster ) , expectedCluster ) ;
155+ } ) ;
156+ } ) ;
157+
135158 describe ( 'loadFromClusterAndUser' , ( ) => {
136159 it ( 'should load from cluster and user' , ( ) => {
137160 const kc = new KubeConfig ( ) ;
You can’t perform that action at this time.
0 commit comments