@@ -18,7 +18,7 @@ use thiserror::Error;
18
18
use tokio:: sync:: { Mutex , RwLock } ;
19
19
use tower:: { filter:: AsyncPredicate , BoxError } ;
20
20
21
- use crate :: config:: { AuthInfo , AuthProviderConfig , ExecConfig } ;
21
+ use crate :: config:: { AuthInfo , AuthProviderConfig , ExecConfig , ExecInteractiveMode } ;
22
22
23
23
#[ cfg( feature = "oauth" ) ] mod oauth;
24
24
#[ cfg( feature = "oauth" ) ] pub use oauth:: Error as OAuthError ;
@@ -66,6 +66,10 @@ pub enum Error {
66
66
#[ error( "failed to parse auth exec output: {0}" ) ]
67
67
AuthExecParse ( #[ source] serde_json:: Error ) ,
68
68
69
+ /// Fail to serialize input
70
+ #[ error( "failed to serialize input: {0}" ) ]
71
+ AuthExecSerialize ( #[ source] serde_json:: Error ) ,
72
+
69
73
/// Failed to exec auth
70
74
#[ error( "failed exec auth: {0}" ) ]
71
75
AuthExec ( String ) ,
@@ -461,13 +465,17 @@ pub struct ExecCredential {
461
465
#[ serde( rename = "apiVersion" ) ]
462
466
pub api_version : Option < String > ,
463
467
pub spec : Option < ExecCredentialSpec > ,
468
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
464
469
pub status : Option < ExecCredentialStatus > ,
465
470
}
466
471
467
472
/// ExecCredenitalSpec holds request and runtime specific information provided
468
473
/// by transport.
469
474
#[ derive( Clone , Debug , Serialize , Deserialize ) ]
470
- pub struct ExecCredentialSpec { }
475
+ pub struct ExecCredentialSpec {
476
+ #[ serde( skip_serializing_if = "Option::is_none" ) ]
477
+ interactive : Option < bool > ,
478
+ }
471
479
472
480
/// ExecCredentialStatus holds credentials for the transport to use.
473
481
#[ derive( Clone , Debug , Serialize , Deserialize ) ]
@@ -500,6 +508,25 @@ fn auth_exec(auth: &ExecConfig) -> Result<ExecCredential, Error> {
500
508
cmd. envs ( envs) ;
501
509
}
502
510
511
+ let interactive = auth. interactive_mode != Some ( ExecInteractiveMode :: Never ) ;
512
+ if interactive {
513
+ cmd. stdin ( std:: process:: Stdio :: inherit ( ) ) ;
514
+ } else {
515
+ cmd. stdin ( std:: process:: Stdio :: piped ( ) ) ;
516
+ }
517
+
518
+ // Provide exec info to child process
519
+ let exec_info = serde_json:: to_string ( & ExecCredential {
520
+ api_version : auth. api_version . clone ( ) ,
521
+ kind : None ,
522
+ spec : Some ( ExecCredentialSpec {
523
+ interactive : Some ( interactive) ,
524
+ } ) ,
525
+ status : None ,
526
+ } )
527
+ . map_err ( Error :: AuthExecSerialize ) ?;
528
+ cmd. env ( "KUBERNETES_EXEC_INFO" , exec_info) ;
529
+
503
530
if let Some ( envs) = & auth. drop_env {
504
531
for env in envs {
505
532
cmd. env_remove ( env) ;
0 commit comments