@@ -56,8 +56,32 @@ export class Log {
56
56
podName : string ,
57
57
containerName : string ,
58
58
stream : Writable ,
59
- options : LogOptions = { } ,
59
+ options ?: LogOptions ,
60
+ ) : Promise < request . Request > ;
61
+ /** @deprecated done callback is deprecated */
62
+ public async log (
63
+ namespace : string ,
64
+ podName : string ,
65
+ containerName : string ,
66
+ stream : Writable ,
67
+ done : ( err : any ) => void ,
68
+ options ?: LogOptions ,
69
+ ) : Promise < request . Request > ;
70
+ public async log (
71
+ namespace : string ,
72
+ podName : string ,
73
+ containerName : string ,
74
+ stream : Writable ,
75
+ doneOrOptions ?: ( ( err : any ) => void ) | LogOptions ,
76
+ options ?: LogOptions ,
60
77
) : Promise < request . Request > {
78
+ let done : ( err : any ) => void = ( ) => undefined ;
79
+ if ( typeof doneOrOptions === 'function' ) {
80
+ done = doneOrOptions ;
81
+ } else {
82
+ options = doneOrOptions ;
83
+ }
84
+
61
85
const path = `/api/v1/namespaces/${ namespace } /pods/${ podName } /log` ;
62
86
63
87
const cluster = this . config . getCurrentCluster ( ) ;
@@ -80,9 +104,13 @@ export class Log {
80
104
const req = request ( requestOptions , ( error , response , body ) => {
81
105
if ( error ) {
82
106
reject ( error ) ;
107
+ done ( error ) ;
83
108
} else if ( response . statusCode !== 200 ) {
84
- body = ObjectSerializer . deserialize ( JSON . parse ( body ) , 'V1Status' ) ;
85
- reject ( new HttpError ( response , body , response . statusCode ) ) ;
109
+ const deserializedBody = ObjectSerializer . deserialize ( JSON . parse ( body ) , 'V1Status' ) ;
110
+ reject ( new HttpError ( response , deserializedBody , response . statusCode ) ) ;
111
+ done ( body ) ;
112
+ } else {
113
+ done ( null ) ;
86
114
}
87
115
} ) . on ( 'response' , ( response ) => {
88
116
if ( response . statusCode === 200 ) {
0 commit comments