@@ -25,16 +25,7 @@ public class Kubectl {
2525
2626 /** Equivalence for `kubectl taint`. */
2727 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 ();
3829 }
3930
4031 /**
@@ -43,17 +34,7 @@ public static KubectlTaint taint(ApiClient apiClient) {
4334 * @return the kubectl copy
4435 */
4536 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 ();
5738 }
5839
5940 /**
@@ -65,20 +46,7 @@ public static KubectlCopy copy(ApiClient apiClient) {
6546 */
6647 public static <ApiType extends KubernetesObject > KubectlLabel <ApiType > label (
6748 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 );
8250 }
8351
8452 /**
@@ -90,20 +58,7 @@ public static <ApiType extends KubernetesObject> KubectlLabel<ApiType> label(
9058 */
9159 public static <ApiType extends KubernetesObject > KubectlAnnotate <ApiType > annotate (
9260 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 );
10762 }
10863
10964 /**
@@ -112,17 +67,7 @@ public static <ApiType extends KubernetesObject> KubectlAnnotate<ApiType> annota
11267 * @return the kubectl version
11368 */
11469 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 ();
12671 }
12772
12873 /*
@@ -134,30 +79,7 @@ public static KubectlVersion version(ApiClient apiClient) {
13479 */
13580 public static <ApiType extends KubernetesObject > KubectlScale <ApiType > scale (
13681 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 );
16183 }
16284
16385 /**
@@ -166,17 +88,7 @@ public static KubectlExec exec(ApiClient apiClient) {
16688 * @return the kubectl exec operator
16789 */
16890 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 ();
18092 }
18193
18294 /**
@@ -185,23 +97,15 @@ public static KubectlLog log(ApiClient apiClient) {
18597 * @return the kubectl log operator
18698 */
18799 public static KubectlLog log () {
188- return log ( Configuration . getDefaultApiClient () );
100+ return new KubectlLog ( );
189101 }
190102
191103 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 ();
197105 }
198106
199107 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 ();
205109 }
206110
207111 /**
@@ -220,18 +124,27 @@ public static interface Executable<OUTPUT> {
220124 OUTPUT execute () throws KubectlException ;
221125 }
222126
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+
223137 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 > {
226140 final Class <ApiType > apiTypeClass ;
227141 String namespace ;
228142 String name ;
229143 String apiGroup ;
230144 String apiVersion ;
231145 String resourceNamePlural ;
232146
233- ResourceBuilder (ApiClient client , Class <ApiType > apiTypeClass ) {
234- this .apiClient = client ;
147+ ResourceBuilder (Class <ApiType > apiTypeClass ) {
235148 this .apiTypeClass = apiTypeClass ;
236149 }
237150
@@ -266,8 +179,8 @@ abstract static class ResourceAndContainerBuilder<
266179 extends ResourceBuilder <ApiType , T > {
267180 String container ;
268181
269- ResourceAndContainerBuilder (ApiClient client , Class <ApiType > apiTypeClass ) {
270- super (client , apiTypeClass );
182+ ResourceAndContainerBuilder (Class <ApiType > apiTypeClass ) {
183+ super (apiTypeClass );
271184 }
272185
273186 public T container (String container ) {
0 commit comments