@@ -25,16 +25,7 @@ public class Kubectl {
25
25
26
26
/** Equivalence for `kubectl taint`. */
27
27
public static KubectlTaint taint () {
28
- return taint (Configuration .getDefaultApiClient ());
29
- }
30
-
31
- /**
32
- * Equivalence for `kubectl taint`
33
- *
34
- * @param apiClient The client to use
35
- */
36
- public static KubectlTaint taint (ApiClient apiClient ) {
37
- return new KubectlTaint (apiClient );
28
+ return new KubectlTaint ();
38
29
}
39
30
40
31
/**
@@ -43,17 +34,7 @@ public static KubectlTaint taint(ApiClient apiClient) {
43
34
* @return the kubectl copy
44
35
*/
45
36
public static KubectlCopy copy () {
46
- return copy (Configuration .getDefaultApiClient ());
47
- }
48
-
49
- /**
50
- * Equivalence for `kubectl cp`.
51
- *
52
- * @param apiClient the api client instance
53
- * @return the kubectl copy
54
- */
55
- public static KubectlCopy copy (ApiClient apiClient ) {
56
- return new KubectlCopy (apiClient );
37
+ return new KubectlCopy ();
57
38
}
58
39
59
40
/**
@@ -65,20 +46,7 @@ public static KubectlCopy copy(ApiClient apiClient) {
65
46
*/
66
47
public static <ApiType extends KubernetesObject > KubectlLabel <ApiType > label (
67
48
Class <ApiType > apiTypeClass ) {
68
- return label (Configuration .getDefaultApiClient (), apiTypeClass );
69
- }
70
-
71
- /**
72
- * Equivalence for `kubectl label`.
73
- *
74
- * @param <ApiType> the target api type
75
- * @param apiClient the api client instance
76
- * @param apiTypeClass the api type class
77
- * @return the kubectl label
78
- */
79
- public static <ApiType extends KubernetesObject > KubectlLabel <ApiType > label (
80
- ApiClient apiClient , Class <ApiType > apiTypeClass ) {
81
- return new KubectlLabel <>(apiClient , apiTypeClass );
49
+ return new KubectlLabel <>(apiTypeClass );
82
50
}
83
51
84
52
/**
@@ -90,20 +58,7 @@ public static <ApiType extends KubernetesObject> KubectlLabel<ApiType> label(
90
58
*/
91
59
public static <ApiType extends KubernetesObject > KubectlAnnotate <ApiType > annotate (
92
60
Class <ApiType > apiTypeClass ) {
93
- return annotate (Configuration .getDefaultApiClient (), apiTypeClass );
94
- }
95
-
96
- /**
97
- * Equivalence for `kubectl annotate`.
98
- *
99
- * @param <ApiType> the target api type
100
- * @param apiClient the api client instance
101
- * @param apiTypeClass the api type class
102
- * @return the kubectl annotation
103
- */
104
- public static <ApiType extends KubernetesObject > KubectlAnnotate <ApiType > annotate (
105
- ApiClient apiClient , Class <ApiType > apiTypeClass ) {
106
- return new KubectlAnnotate <>(apiClient , apiTypeClass );
61
+ return new KubectlAnnotate <>(apiTypeClass );
107
62
}
108
63
109
64
/**
@@ -112,17 +67,7 @@ public static <ApiType extends KubernetesObject> KubectlAnnotate<ApiType> annota
112
67
* @return the kubectl version
113
68
*/
114
69
public static KubectlVersion version () {
115
- return version (Configuration .getDefaultApiClient ());
116
- }
117
-
118
- /**
119
- * Equivalence for `kubectl version`.
120
- *
121
- * @param apiClient the api client instance
122
- * @return the kubectl version
123
- */
124
- public static KubectlVersion version (ApiClient apiClient ) {
125
- return new KubectlVersion (apiClient );
70
+ return new KubectlVersion ();
126
71
}
127
72
128
73
/*
@@ -134,30 +79,7 @@ public static KubectlVersion version(ApiClient apiClient) {
134
79
*/
135
80
public static <ApiType extends KubernetesObject > KubectlScale <ApiType > scale (
136
81
Class <ApiType > apiTypeClass ) {
137
- return scale (Configuration .getDefaultApiClient (), apiTypeClass );
138
- }
139
-
140
- /**
141
- * Equivalent for `kubectl scale`
142
- *
143
- * @param <ApiType> the target api type
144
- * @param apiClient The api client instance
145
- * @param apiTypeClass the api type class
146
- * @return the kubectl scale operator
147
- */
148
- public static <ApiType extends KubernetesObject > KubectlScale <ApiType > scale (
149
- ApiClient apiClient , Class <ApiType > apiTypeClass ) {
150
- return new KubectlScale <>(apiClient , apiTypeClass );
151
- }
152
-
153
- /**
154
- * Equivalent for `kubectl exec`
155
- *
156
- * @param apiClient The api client instance
157
- * @return the kubectl exec operator
158
- */
159
- public static KubectlExec exec (ApiClient apiClient ) {
160
- return new KubectlExec (apiClient );
82
+ return new KubectlScale <>(apiTypeClass );
161
83
}
162
84
163
85
/**
@@ -166,17 +88,7 @@ public static KubectlExec exec(ApiClient apiClient) {
166
88
* @return the kubectl exec operator
167
89
*/
168
90
public static KubectlExec exec () {
169
- return exec (Configuration .getDefaultApiClient ());
170
- }
171
-
172
- /**
173
- * Equivalent for `kubectl log`
174
- *
175
- * @param apiClient The api client instance
176
- * @return the kubectl log operator
177
- */
178
- public static KubectlLog log (ApiClient apiClient ) {
179
- return new KubectlLog (apiClient );
91
+ return new KubectlExec ();
180
92
}
181
93
182
94
/**
@@ -185,23 +97,15 @@ public static KubectlLog log(ApiClient apiClient) {
185
97
* @return the kubectl log operator
186
98
*/
187
99
public static KubectlLog log () {
188
- return log ( Configuration . getDefaultApiClient () );
100
+ return new KubectlLog ( );
189
101
}
190
102
191
103
public static KubectlPortForward portforward () {
192
- return portforward (Configuration .getDefaultApiClient ());
193
- }
194
-
195
- public static KubectlPortForward portforward (ApiClient apiClient ) {
196
- return new KubectlPortForward (apiClient );
104
+ return new KubectlPortForward ();
197
105
}
198
106
199
107
public static KubectlApiResources apiResources () {
200
- return apiResources (Configuration .getDefaultApiClient ());
201
- }
202
-
203
- public static KubectlApiResources apiResources (ApiClient apiClient ) {
204
- return new KubectlApiResources (apiClient );
108
+ return new KubectlApiResources ();
205
109
}
206
110
207
111
/**
@@ -220,18 +124,27 @@ public static interface Executable<OUTPUT> {
220
124
OUTPUT execute () throws KubectlException ;
221
125
}
222
126
127
+ abstract static class ApiClientBuilder <T extends ApiClientBuilder > {
128
+
129
+ ApiClient apiClient = Configuration .getDefaultApiClient ();
130
+
131
+ public T apiClient (ApiClient apiClient ) {
132
+ this .apiClient = apiClient ;
133
+ return (T ) this ;
134
+ }
135
+ }
136
+
223
137
abstract static class ResourceBuilder <
224
- ApiType extends KubernetesObject , T extends ResourceBuilder <ApiType , T >> {
225
- final ApiClient apiClient ;
138
+ ApiType extends KubernetesObject , T extends ResourceBuilder <ApiType , T >>
139
+ extends ApiClientBuilder < T > {
226
140
final Class <ApiType > apiTypeClass ;
227
141
String namespace ;
228
142
String name ;
229
143
String apiGroup ;
230
144
String apiVersion ;
231
145
String resourceNamePlural ;
232
146
233
- ResourceBuilder (ApiClient client , Class <ApiType > apiTypeClass ) {
234
- this .apiClient = client ;
147
+ ResourceBuilder (Class <ApiType > apiTypeClass ) {
235
148
this .apiTypeClass = apiTypeClass ;
236
149
}
237
150
@@ -266,8 +179,8 @@ abstract static class ResourceAndContainerBuilder<
266
179
extends ResourceBuilder <ApiType , T > {
267
180
String container ;
268
181
269
- ResourceAndContainerBuilder (ApiClient client , Class <ApiType > apiTypeClass ) {
270
- super (client , apiTypeClass );
182
+ ResourceAndContainerBuilder (Class <ApiType > apiTypeClass ) {
183
+ super (apiTypeClass );
271
184
}
272
185
273
186
public T container (String container ) {
0 commit comments