@@ -18,63 +18,63 @@ const configMapName = 'hkube-versions';
1818describe ( 'Utils' , ( ) => {
1919 describe ( 'ingress' , ( ) => {
2020 it ( 'should return correct ingress kind extensions/v1beta1' , ( ) => {
21- const ret = utils . getIngressKind ( { version : '1.13' } ) ;
21+ const ret = utils . getIngressApiVersion ( { version : '1.13' } ) ;
2222 expect ( ret ) . to . eql ( 'extensions/v1beta1' )
2323 } ) ;
2424 it ( 'should return correct ingress kind networking.k8s.io/v1beta1' , ( ) => {
25- const ret = utils . getIngressKind ( { version : '1.16' } ) ;
25+ const ret = utils . getIngressApiVersion ( { version : '1.16' } ) ;
2626 expect ( ret ) . to . eql ( 'networking.k8s.io/v1beta1' )
2727 } ) ;
2828 it ( 'should return correct ingress kind networking.k8s.io/v1' , ( ) => {
29- const ret = utils . getIngressKind ( { version : '1.20' } ) ;
29+ const ret = utils . getIngressApiVersion ( { version : '1.20' } ) ;
3030 expect ( ret ) . to . eql ( 'networking.k8s.io/v1' )
3131 } ) ;
3232
3333 it ( 'should return correct backend networking.k8s.io/v1 number' , ( ) => {
3434 const serviceName = 'service1' ;
3535 const servicePort = 8080 ;
36- const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.20' } ) ;
36+ const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.20' } ) ;
3737 expect ( ret ) . to . eql ( {
38- service :{
39- name : serviceName ,
40- port : {
41- number : servicePort
38+ backend : {
39+ service : {
40+ name : serviceName ,
41+ port : {
42+ number : servicePort
43+ }
4244 }
43- }
45+ } ,
46+ pathType : 'ImplementationSpecific'
4447 } )
4548 } ) ;
4649 it ( 'should return correct backend networking.k8s.io/v1 string' , ( ) => {
4750 const serviceName = 'service1' ;
4851 const servicePort = 'http' ;
49- const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.20' } ) ;
52+ const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.20' } ) ;
5053 expect ( ret ) . to . eql ( {
51- service :{
52- name : serviceName ,
53- port : {
54- name : servicePort
54+ backend : {
55+ service : {
56+ name : serviceName ,
57+ port : {
58+ name : servicePort
59+ }
5560 }
56- }
61+ } ,
62+ pathType : 'ImplementationSpecific'
5763 } )
5864 } ) ;
5965 it ( 'should return correct backend networking.k8s.io/v1beta1' , ( ) => {
6066 const serviceName = 'service1' ;
6167 const servicePort = 8080 ;
62- const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.16' } ) ;
63- expect ( ret ) . to . eql ( { serviceName, servicePort} )
68+ const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.16' } ) ;
69+ expect ( ret . backend ) . to . eql ( { serviceName, servicePort } )
70+ expect ( ret . pathType ) . to . not . exist ;
6471 } ) ;
6572 it ( 'should return correct backend extensions/v1beta1' , ( ) => {
6673 const serviceName = 'service1' ;
6774 const servicePort = 8080 ;
68- const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.13' } ) ;
69- expect ( ret ) . to . eql ( { serviceName, servicePort} )
70- } ) ;
71- it ( 'should return false shouldAddIngressPathType' , ( ) => {
72- const ret = utils . shouldAddIngressPathType ( { version : '1.13' } ) ;
73- expect ( ret ) . to . be . false ;
74- } ) ;
75- it ( 'should return true correct shouldAddIngressPathType' , ( ) => {
76- const ret = utils . shouldAddIngressPathType ( { version : '1.20' } ) ;
77- expect ( ret ) . to . be . true ;
75+ const ret = utils . getIngressBackend ( serviceName , servicePort , { version : '1.13' } ) ;
76+ expect ( ret . backend ) . to . eql ( { serviceName, servicePort } )
77+ expect ( ret . pathType ) . to . not . exist ;
7878 } ) ;
7979 } ) ;
8080 describe ( 'findContainer' , ( ) => {
@@ -151,7 +151,7 @@ describe('Utils', () => {
151151 expect ( res ) . to . have . property ( 'tag' ) ;
152152 expect ( res ) . to . have . property ( 'name' ) ;
153153 expect ( res ) . to . have . property ( 'fullname' ) ;
154-
154+
155155 expect ( res . registry ) . to . equal ( 'hostname.com' ) ;
156156 expect ( res . namespace ) . to . equal ( 'docker-virtual/foo/foo' ) ;
157157 expect ( res . repository ) . to . equal ( 'algorithm-queue' ) ;
@@ -227,7 +227,7 @@ describe('Utils', () => {
227227 const container = 'worker' ;
228228 const configMapRes = await client . configMaps . get ( { name : configMapName } ) ;
229229 const configMap = client . configMaps . extractConfigMap ( configMapRes ) ;
230- configMap . versions . versions . find ( v => v . project === container ) . image = 'foo/worker2'
230+ configMap . versions . versions . find ( v => v . project === container ) . image = 'foo/worker2'
231231 const res = utils . createImageFromContainer ( slimJobTemplate , container , configMap . versions , { registry : configMap . registry } ) ;
232232 expect ( res ) . to . equal ( 'cloud.docker.com/foo/worker2:v2.1.0' ) ;
233233 } ) ;
@@ -279,27 +279,27 @@ describe('Utils', () => {
279279
280280 describe ( 'applyImagePullSecret' , ( ) => {
281281 it ( 'should return original spec if no secret' , ( ) => {
282- const res = utils . applyImagePullSecret ( slimJobTemplate , '' ) ;
282+ const res = utils . applyImagePullSecret ( slimJobTemplate , '' ) ;
283283 expect ( res ) . to . eql ( slimJobTemplate )
284284 } ) ;
285285 it ( 'should set one secret' , ( ) => {
286- const res = utils . applyImagePullSecret ( slimJobTemplate , 'my-secret' ) ;
286+ const res = utils . applyImagePullSecret ( slimJobTemplate , 'my-secret' ) ;
287287 expect ( res . spec . template . spec . imagePullSecrets ) . to . exist ;
288- expect ( res . spec . template . spec . imagePullSecrets [ 0 ] ) . to . eql ( { name : 'my-secret' } ) ;
288+ expect ( res . spec . template . spec . imagePullSecrets [ 0 ] ) . to . eql ( { name : 'my-secret' } ) ;
289289 } ) ;
290290 it ( 'should add two secrets' , ( ) => {
291- let res = utils . applyImagePullSecret ( slimJobTemplate , 'my-secret' ) ;
292- res = utils . applyImagePullSecret ( res , 'my-secret2' ) ;
291+ let res = utils . applyImagePullSecret ( slimJobTemplate , 'my-secret' ) ;
292+ res = utils . applyImagePullSecret ( res , 'my-secret2' ) ;
293293 expect ( res . spec . template . spec . imagePullSecrets ) . to . exist ;
294- expect ( res . spec . template . spec . imagePullSecrets [ 0 ] ) . to . eql ( { name : 'my-secret' } ) ;
295- expect ( res . spec . template . spec . imagePullSecrets [ 1 ] ) . to . eql ( { name : 'my-secret2' } ) ;
294+ expect ( res . spec . template . spec . imagePullSecrets [ 0 ] ) . to . eql ( { name : 'my-secret' } ) ;
295+ expect ( res . spec . template . spec . imagePullSecrets [ 1 ] ) . to . eql ( { name : 'my-secret2' } ) ;
296296 } ) ;
297297 it ( 'should not duplicate' , ( ) => {
298- let res = utils . applyImagePullSecret ( slimJobTemplate , 'my-secret' ) ;
299- res = utils . applyImagePullSecret ( res , 'my-secret' ) ;
298+ let res = utils . applyImagePullSecret ( slimJobTemplate , 'my-secret' ) ;
299+ res = utils . applyImagePullSecret ( res , 'my-secret' ) ;
300300 expect ( res . spec . template . spec . imagePullSecrets ) . to . exist ;
301301 expect ( res . spec . template . spec . imagePullSecrets ) . to . have . lengthOf ( 1 ) ;
302- expect ( res . spec . template . spec . imagePullSecrets [ 0 ] ) . to . eql ( { name : 'my-secret' } ) ;
302+ expect ( res . spec . template . spec . imagePullSecrets [ 0 ] ) . to . eql ( { name : 'my-secret' } ) ;
303303 } ) ;
304304 } ) ;
305305 describe ( 'applyAnnotations' , ( ) => {
@@ -325,15 +325,15 @@ describe('Utils', () => {
325325
326326 } ) ;
327327 it ( 'should add multiple keys' , ( ) => {
328- const res2 = utils . applyAnnotation ( slimJobTemplate , { ann1 : 'value1' , ann2 : 'value2' } ) ;
328+ const res2 = utils . applyAnnotation ( slimJobTemplate , { ann1 : 'value1' , ann2 : 'value2' } ) ;
329329 expect ( res2 . metadata . annotations ) . to . exist ;
330330 expect ( res2 . metadata . annotations . ann1 ) . to . eql ( 'value1' ) ;
331331 expect ( res2 . metadata . annotations . ann2 ) . to . eql ( 'value2' ) ;
332332 expect ( res2 . spec . template . metadata . annotations . ann2 ) . to . eql ( 'value2' ) ;
333333
334334 } ) ;
335335 it ( 'should delete annotation' , ( ) => {
336- const res1 = utils . applyAnnotation ( slimJobTemplate , { ann1 : 'value1' , ann2 : 'value2' } ) ;
336+ const res1 = utils . applyAnnotation ( slimJobTemplate , { ann1 : 'value1' , ann2 : 'value2' } ) ;
337337 expect ( res1 . metadata . annotations . ann1 ) . to . eql ( 'value1' ) ;
338338 const res2 = utils . applyAnnotation ( res1 , { ann2 : null } ) ;
339339 expect ( res2 . metadata . annotations ) . to . exist ;
@@ -673,9 +673,9 @@ describe('Utils', () => {
673673 } ) ;
674674 it ( 'should add secret to spec with existing env' , ( ) => {
675675 const spec = clonedeep ( slimJobTemplate ) ;
676- spec . spec . template . spec . containers [ 0 ] . env = [ { name : 'e1' , value : 'v1' } ]
676+ spec . spec . template . spec . containers [ 0 ] . env = [ { name : 'e1' , value : 'v1' } ]
677677 const res = utils . applySecret ( spec , containerName , secretMock ) ;
678- expect ( res . spec . template . spec . containers [ 0 ] . env ) . to . have . lengthOf ( Object . keys ( secretMock . data ) . length + 1 ) ;
678+ expect ( res . spec . template . spec . containers [ 0 ] . env ) . to . have . lengthOf ( Object . keys ( secretMock . data ) . length + 1 ) ;
679679 } ) ;
680680 } ) ;
681681} ) ;
0 commit comments