@@ -373,42 +373,59 @@ var _ = Describe("Kubeconfig", func() {
373
373
})
374
374
It ("writes the right api version if aws-iam-authenticator version is below 0.5.3" , func () {
375
375
kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
376
- return exec .Command (filepath .Join ("testdata" , "aws-iam-authenticator " ), `{"Version":"0.5.1","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
376
+ return exec .Command (filepath .Join ("testdata" , "fake-version " ), `{"Version":"0.5.1","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
377
377
})
378
378
kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSIAMAuthenticator , "" , "" )
379
379
Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1alpha1" ))
380
380
})
381
381
It ("writes the right api version if aws-iam-authenticator version is above 0.5.3" , func () {
382
382
kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
383
- return exec .Command (filepath .Join ("testdata" , "aws-iam-authenticator " ), `{"Version":"0.5.5","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
383
+ return exec .Command (filepath .Join ("testdata" , "fake-version " ), `{"Version":"0.5.5","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
384
384
})
385
385
kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSIAMAuthenticator , "" , "" )
386
386
Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1beta1" ))
387
387
})
388
388
It ("writes the right api version if aws-iam-authenticator version equals 0.5.3" , func () {
389
389
kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
390
- return exec .Command (filepath .Join ("testdata" , "aws-iam-authenticator " ), `{"Version":"0.5.3","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
390
+ return exec .Command (filepath .Join ("testdata" , "fake-version " ), `{"Version":"0.5.3","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
391
391
})
392
392
kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSIAMAuthenticator , "" , "" )
393
393
Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1beta1" ))
394
394
})
395
395
It ("defaults to alpha1 if we fail to detect aws-iam-authenticator version" , func () {
396
396
kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
397
- return exec .Command (filepath .Join ("testdata" , "aws-iam-authenticator " ), "fail" )
397
+ return exec .Command (filepath .Join ("testdata" , "fake-version " ), "fail" )
398
398
})
399
399
kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSIAMAuthenticator , "" , "" )
400
400
Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1alpha1" ))
401
401
})
402
402
It ("defaults to alpha1 if we fail to parse the output" , func () {
403
403
kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
404
- return exec .Command (filepath .Join ("testdata" , "aws-iam-authenticator " ), "not-json-output" )
404
+ return exec .Command (filepath .Join ("testdata" , "fake-version " ), "not-json-output" )
405
405
})
406
406
kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSIAMAuthenticator , "" , "" )
407
407
Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1alpha1" ))
408
408
})
409
409
It ("defaults to alpha1 if we can't parse the version because it's a dev version" , func () {
410
410
kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
411
- return exec .Command (filepath .Join ("testdata" , "aws-iam-authenticator" ), `{"Version":"git-85e50980","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
411
+ return exec .Command (filepath .Join ("testdata" , "fake-version" ), `{"Version":"git-85e50980","Commit":"85e50980d9d916ae95882176c18f14ae145f916f"}` )
412
+ })
413
+ kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSIAMAuthenticator , "" , "" )
414
+ Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1alpha1" ))
415
+ })
416
+ It ("defaults to beta1 if we detect kubectl 1.24.0 or above" , func () {
417
+ kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
418
+ return exec .Command (filepath .Join ("testdata" , "fake-version" ), `{"clientVersion": {"gitVersion": "v1.24.0"}}` )
419
+ })
420
+ kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSEKSAuthenticator , "" , "" )
421
+ Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1beta1" ))
422
+ })
423
+ It ("doesn't default to beta1 if we detect kubectl 1.23.0 or below" , func () {
424
+ kubeconfig .SetExecCommand (func (name string , arg ... string ) * exec.Cmd {
425
+ if name == "kubectl" {
426
+ return exec .Command (filepath .Join ("testdata" , "fake-version" ), `{"clientVersion": {"gitVersion": "v1.23.6"}}` )
427
+ }
428
+ return exec .Command (filepath .Join ("testdata" , "fake-version" ), "fail" )
412
429
})
413
430
kubeconfig .AppendAuthenticator (config , clusterMeta , kubeconfig .AWSIAMAuthenticator , "" , "" )
414
431
Expect (config .AuthInfos ["test" ].Exec .APIVersion ).To (Equal ("client.authentication.k8s.io/v1alpha1" ))
0 commit comments