12
12
*/
13
13
package io .kubernetes .client ;
14
14
15
- import io .kubernetes .client .Configuration ;
16
15
import io .kubernetes .client .models .V1Pod ;
17
16
import io .kubernetes .client .util .WebSocketStreamHandler ;
18
17
import io .kubernetes .client .util .WebSockets ;
18
+ import org .apache .commons .lang3 .StringUtils ;
19
19
20
- import java .io .ByteArrayInputStream ;
21
- import java .io .Closeable ;
22
20
import java .io .InputStream ;
23
21
import java .io .IOException ;
24
22
import java .io .OutputStream ;
25
- import java .io .PipedInputStream ;
26
- import java .io .PipedOutputStream ;
27
- import java .io .Reader ;
28
-
29
- import org .apache .commons .lang .StringUtils ;
30
23
31
24
public class Exec {
32
25
private ApiClient apiClient ;
@@ -70,15 +63,15 @@ private String makePath(String namespace, String name, String[] command, String
70
63
"/exec?" +
71
64
"stdin=" + stdin +
72
65
"&tty=" + tty +
73
- (container != null ? "&container=" + container : "" ) +
66
+ (container != null ? "&container=" + container : "" ) +
74
67
"&command=" + StringUtils .join (command , "&command=" );
75
68
return path ;
76
69
}
77
70
78
71
/**
79
72
* Execute a command in a container. If there are multiple containers in the pod, uses
80
73
* the first container in the Pod.
81
- *
74
+ *
82
75
* @param namespace The namespace of the Pod
83
76
* @param name The name of the Pod
84
77
* @param command The command to run
@@ -91,10 +84,10 @@ public Process exec(String namespace, String name, String[] command, boolean std
91
84
/**
92
85
* Execute a command in a container. If there are multiple containers in the pod, uses
93
86
* the first container in the Pod.
94
- *
87
+ *
95
88
* @param pod The pod where the command is run.
96
89
* @param command The command to run
97
- * @param stdin If true, pass a stdin stream into the container
90
+ * @param stdin If true, pass a stdin stream into the container
98
91
*/
99
92
public Process exec (V1Pod pod , String [] command , boolean stdin ) throws ApiException , IOException {
100
93
return exec (pod , command , null , stdin , false );
@@ -103,11 +96,11 @@ public Process exec(V1Pod pod, String[] command, boolean stdin) throws ApiExcept
103
96
/**
104
97
* Execute a command in a container. If there are multiple containers in the pod, uses
105
98
* the first container in the Pod.
106
- *
99
+ *
107
100
* @param namespace The namespace of the Pod
108
101
* @param name The name of the Pod
109
102
* @param command The command to run
110
- * @param stdin If true, pass a stdin stream into the container
103
+ * @param stdin If true, pass a stdin stream into the container
111
104
* @param tty If true, stdin is a tty.
112
105
*/
113
106
public Process exec (String namespace , String name , String [] command , boolean stdin , boolean tty ) throws ApiException , IOException {
@@ -117,10 +110,10 @@ public Process exec(String namespace, String name, String[] command, boolean std
117
110
/**
118
111
* Execute a command in a container. If there are multiple containers in the pod, uses
119
112
* the first container in the Pod.
120
- *
113
+ *
121
114
* @param pod The pod where the command is run.
122
115
* @param command The command to run
123
- * @param stdin If true, pass a stdin stream into the container
116
+ * @param stdin If true, pass a stdin stream into the container
124
117
* @param tty If true, stdin is a tty.
125
118
*/
126
119
public Process exec (V1Pod pod , String [] command , boolean stdin , boolean tty ) throws ApiException , IOException {
@@ -130,7 +123,7 @@ public Process exec(V1Pod pod, String[] command, boolean stdin, boolean tty) thr
130
123
/**
131
124
* Execute a command in a container. If there are multiple containers in the pod, uses
132
125
* the first container in the Pod.
133
- *
126
+ *
134
127
* @param pod The pod where the command is run.
135
128
* @param command The command to run
136
129
* @param container The container in the Pod where the command is run.
@@ -144,7 +137,7 @@ public Process exec(V1Pod pod, String[] command, String container, boolean stdin
144
137
/**
145
138
* Execute a command in a container. If there are multiple containers in the pod, uses
146
139
* the first container in the Pod.
147
- *
140
+ *
148
141
* @param namespace The namespace of the Pod
149
142
* @param name The name of the Pod
150
143
* @param command The command to run
@@ -166,7 +159,7 @@ private static class ExecProcess extends Process {
166
159
WebSocketStreamHandler streamHandler ;
167
160
private int statusCode ;
168
161
169
-
162
+
170
163
public ExecProcess (WebSocketStreamHandler handler ) throws IOException {
171
164
this .streamHandler = handler ;
172
165
this .statusCode = -1 ;
@@ -194,13 +187,13 @@ public int waitFor() throws InterruptedException {
194
187
}
195
188
return statusCode ;
196
189
}
197
-
190
+
198
191
public int exitValue () {
199
192
return statusCode ;
200
193
}
201
194
202
195
public void destroy () {
203
196
streamHandler .close ();
204
197
}
205
- }
198
+ }
206
199
}
0 commit comments