Skip to content

Commit 726e88c

Browse files
authored
Merge pull request #2991 from yue9944882/automated-generate-6f7825ce
OpenApi generate from k8s 1.28 with `USE_SINGLE_PARAMETER` and client-side openapi validation enabled
2 parents 9968115 + 06a989d commit 726e88c

File tree

1,318 files changed

+245398
-107600
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,318 files changed

+245398
-107600
lines changed

.github/workflows/generate.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,17 @@ jobs:
5959
export PACKAGE_NAME="io.kubernetes.client.openapi"
6060
EOF
6161
62-
bash java.sh ../../kubernetes/ settings
62+
USE_SINGLE_PARAMETER=true bash java.sh ../../kubernetes/ settings
6363
popd
6464
rm -rf gen
6565
- name: Generate Fluent
6666
run: |
6767
# Only install the generated openapi module because the higher modules' compile
6868
# may fail due to api-changes.
69-
mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn -Pfluent-gen -pl kubernetes -am clean install
69+
mvn -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
70+
-Dmaven.test.skip=true \
71+
-Pfluent-gen \
72+
-pl kubernetes -am clean install
7073
pushd fluent-gen
7174
bash -x generate.sh
7275
popd

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
strategy:
2828
matrix:
2929
# Test against the LTS Java versions. TODO: add JDK18 when it becomes available.
30-
java: [ 8.0.x, 11.0.x, 17.0.x ]
30+
java: [ 11.0.x, 17.0.x ]
3131
os: [ macos-latest, windows-latest, ubuntu-latest ]
3232
runs-on: ${{ matrix.os }}
3333
steps:

e2e/src/test/groovy/io/kubernetes/client/e2e/basic/CoreV1ApiTest.groovy

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ package io.kubernetes.client.e2e.basic
1515
import io.kubernetes.client.openapi.Configuration
1616
import io.kubernetes.client.openapi.apis.CoreV1Api
1717
import io.kubernetes.client.openapi.models.V1Namespace
18+
import io.kubernetes.client.openapi.models.V1NamespaceSpec
1819
import io.kubernetes.client.openapi.models.V1ObjectMeta
1920
import io.kubernetes.client.openapi.models.V1Status
2021
import io.kubernetes.client.util.ClientBuilder
@@ -26,13 +27,15 @@ class CoreV1ApiTest extends Specification {
2627
def apiClient = ClientBuilder.defaultClient()
2728
def corev1api = new CoreV1Api(apiClient)
2829
Configuration.setDefaultApiClient(apiClient)
29-
def namespaceFoo = new V1Namespace().metadata(new V1ObjectMeta().name("e2e-basic"))
30+
def namespaceFoo = new V1Namespace()
31+
.metadata(new V1ObjectMeta().name("e2e-basic"))
32+
.spec(new V1NamespaceSpec())
3033
when:
31-
V1Namespace created = corev1api.createNamespace(namespaceFoo, null, null, null, null)
34+
V1Namespace created = corev1api.createNamespace(namespaceFoo).execute()
3235
then:
3336
created != null
3437
when:
35-
V1Status deleted = corev1api.deleteNamespace("e2e-basic", null, null, null, null, null, null)
38+
V1Status deleted = corev1api.deleteNamespace("e2e-basic").execute()
3639
then:
3740
deleted != null
3841
}

e2e/src/test/groovy/io/kubernetes/client/e2e/kubectl/KubectlDrainTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ class KubectlDrainTest extends Specification {
4242
)))
4343
when:
4444
V1Node createdNode = Kubectl.create(V1Node.class).resource(testNode).execute()
45-
V1Pod createdPod = Kubectl.create(V1Pod.class).resource(testPod).execute()
45+
// V1Pod createdPod = Kubectl.create(V1Pod.class).resource(testPod).execute()
4646
then:
4747
createdNode != null
48-
createdPod != null
48+
// createdPod != null
4949
when:
5050
V1Node drainedNode = Kubectl.drain().gracePeriod(0).name("foo").execute()
5151
then:

e2e/src/test/java/io/kubernetes/client/e2e/extended/leaderelection/LeaderElectorTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private void deleteConfigMapLockResource() throws Exception {
277277
try {
278278
CoreV1Api coreV1Api = new CoreV1Api(apiClient);
279279
coreV1Api.deleteNamespacedConfigMap(
280-
LOCK_RESOURCE_NAME, NAMESPACE, null, null, null, null, null, null);
280+
LOCK_RESOURCE_NAME, NAMESPACE).execute();
281281
} catch (ApiException ex) {
282282
if (ex.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
283283
throw ex;
@@ -289,7 +289,7 @@ private void deleteEndpointsLockResource() throws Exception {
289289
try {
290290
CoreV1Api coreV1Api = new CoreV1Api(apiClient);
291291
coreV1Api.deleteNamespacedEndpoints(
292-
LOCK_RESOURCE_NAME, NAMESPACE, null, null, null, null, null, null);
292+
LOCK_RESOURCE_NAME, NAMESPACE).execute();
293293
} catch (ApiException ex) {
294294
if (ex.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
295295
throw ex;
@@ -301,7 +301,7 @@ private void deleteLeaseLockResource() throws Exception {
301301
try {
302302
CoordinationV1Api coordinationV1Api = new CoordinationV1Api(apiClient);
303303
coordinationV1Api.deleteNamespacedLease(
304-
LOCK_RESOURCE_NAME, NAMESPACE, null, null, null, null, null, null);
304+
LOCK_RESOURCE_NAME, NAMESPACE).execute();
305305
} catch (ApiException ex) {
306306
if (ex.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
307307
throw ex;

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/ControllerExample.java

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,19 +56,11 @@ public static void main(String[] args) throws IOException {
5656
SharedIndexInformer<V1Node> nodeInformer =
5757
informerFactory.sharedIndexInformerFor(
5858
(CallGeneratorParams params) -> {
59-
return coreV1Api.listNodeCall(
60-
null,
61-
null,
62-
null,
63-
null,
64-
null,
65-
null,
66-
params.resourceVersion,
67-
null,
68-
null,
69-
params.timeoutSeconds,
70-
params.watch,
71-
null);
59+
return coreV1Api.listNode()
60+
.resourceVersion(params.resourceVersion)
61+
.timeoutSeconds(params.timeoutSeconds)
62+
.watch(params.watch)
63+
.buildCall(null);
7264
},
7365
V1Node.class,
7466
V1NodeList.class);

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/DeployRolloutRestartExample.java

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public static void main(String[] args) throws IOException, ApiException {
6464
.name(deploymentName)
6565
.image(imageName))))));
6666
appsV1Api.createNamespacedDeployment(
67-
namespace, deploymentBuilder.build(), null, null, null, null);
67+
namespace, deploymentBuilder.build()).execute();
6868

6969
// Wait until example deployment is ready
7070
Wait.poll(
@@ -74,7 +74,8 @@ public static void main(String[] args) throws IOException, ApiException {
7474
try {
7575
System.out.println("Waiting until example deployment is ready...");
7676
return appsV1Api
77-
.readNamespacedDeployment(deploymentName, namespace, null)
77+
.readNamespacedDeployment(deploymentName, namespace)
78+
.execute()
7879
.getStatus()
7980
.getReadyReplicas()
8081
> 0;
@@ -87,7 +88,7 @@ public static void main(String[] args) throws IOException, ApiException {
8788

8889
// Trigger a rollout restart of the example deployment
8990
V1Deployment runningDeployment =
90-
appsV1Api.readNamespacedDeployment(deploymentName, namespace, null);
91+
appsV1Api.readNamespacedDeployment(deploymentName, namespace).execute();
9192

9293
// Explicitly set "restartedAt" annotation with current date/time to trigger rollout when patch
9394
// is applied
@@ -102,16 +103,12 @@ public static void main(String[] args) throws IOException, ApiException {
102103
PatchUtils.patch(
103104
V1Deployment.class,
104105
() ->
105-
appsV1Api.patchNamespacedDeploymentCall(
106+
appsV1Api.patchNamespacedDeployment(
106107
deploymentName,
107108
namespace,
108-
new V1Patch(deploymentJson),
109-
null,
110-
null,
111-
"kubectl-rollout",
112-
null,
113-
null,
114-
null),
109+
new V1Patch(deploymentJson))
110+
.fieldManager("kubectl-rollout")
111+
.buildCall(null),
115112
V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH,
116113
client);
117114

@@ -123,7 +120,8 @@ public static void main(String[] args) throws IOException, ApiException {
123120
try {
124121
System.out.println("Waiting until example deployment restarted successfully...");
125122
return appsV1Api
126-
.readNamespacedDeployment(deploymentName, namespace, null)
123+
.readNamespacedDeployment(deploymentName, namespace)
124+
.execute()
127125
.getStatus()
128126
.getReadyReplicas()
129127
> 0;

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/Example.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public static void main(String[] args) throws IOException, ApiException {
3535
Configuration.setDefaultApiClient(client);
3636

3737
CoreV1Api api = new CoreV1Api();
38-
V1PodList list =
39-
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
38+
V1PodList list = api.listPodForAllNamespaces()
39+
.execute();
4040
for (V1Pod item : list.getItems()) {
4141
System.out.println(item.getMetadata().getName());
4242
}

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/ExpandedExample.java

Lines changed: 21 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ public static void main(String[] args) {
101101
*/
102102
public static List<String> getAllNameSpaces() throws ApiException {
103103
V1NamespaceList listNamespace =
104-
COREV1_API.listNamespace(
105-
null, null, null, null, null, null, null, null, null, null, null);
104+
COREV1_API.listNamespace().execute();
106105
List<String> list =
107106
listNamespace.getItems().stream()
108107
.map(v1Namespace -> v1Namespace.getMetadata().getName())
@@ -118,8 +117,7 @@ public static List<String> getAllNameSpaces() throws ApiException {
118117
*/
119118
public static List<String> getPods() throws ApiException {
120119
V1PodList v1podList =
121-
COREV1_API.listPodForAllNamespaces(
122-
null, null, null, null, null, null, null, null, null, null, null);
120+
COREV1_API.listPodForAllNamespaces().execute();
123121
List<String> podList =
124122
v1podList.getItems().stream()
125123
.map(v1Pod -> v1Pod.getMetadata().getName())
@@ -159,18 +157,11 @@ public static List<String> getNamespacedPod(String namespace) throws ApiExceptio
159157
public static List<String> getNamespacedPod(String namespace, String label) throws ApiException {
160158
V1PodList listNamespacedPod =
161159
COREV1_API.listNamespacedPod(
162-
namespace,
163-
null,
164-
null,
165-
null,
166-
null,
167-
label,
168-
null,
169-
null,
170-
null,
171-
null,
172-
TIME_OUT_VALUE,
173-
Boolean.FALSE);
160+
namespace)
161+
.labelSelector(label)
162+
.timeoutSeconds(TIME_OUT_VALUE)
163+
.watch(false)
164+
.execute();
174165
List<String> listPods =
175166
listNamespacedPod.getItems().stream()
176167
.map(v1pod -> v1pod.getMetadata().getName())
@@ -186,19 +177,10 @@ public static List<String> getNamespacedPod(String namespace, String label) thro
186177
*/
187178
public static List<String> getServices() throws ApiException {
188179
V1ServiceList listNamespacedService =
189-
COREV1_API.listNamespacedService(
190-
DEFAULT_NAME_SPACE,
191-
null,
192-
null,
193-
null,
194-
null,
195-
null,
196-
null,
197-
null,
198-
null,
199-
null,
200-
TIME_OUT_VALUE,
201-
Boolean.FALSE);
180+
COREV1_API.listNamespacedService(DEFAULT_NAME_SPACE)
181+
.timeoutSeconds(TIME_OUT_VALUE)
182+
.watch(false)
183+
.execute();
202184
return listNamespacedService.getItems().stream()
203185
.map(v1service -> v1service.getMetadata().getName())
204186
.collect(Collectors.toList());
@@ -217,18 +199,9 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
217199
appsV1Api.setApiClient(COREV1_API.getApiClient());
218200
V1DeploymentList listNamespacedDeployment =
219201
appsV1Api.listNamespacedDeployment(
220-
DEFAULT_NAME_SPACE,
221-
null,
222-
null,
223-
null,
224-
null,
225-
null,
226-
null,
227-
null,
228-
null,
229-
null,
230-
null,
231-
Boolean.FALSE);
202+
DEFAULT_NAME_SPACE)
203+
.watch(false)
204+
.execute();
232205

233206
List<V1Deployment> appsV1DeploymentItems = listNamespacedDeployment.getItems();
234207
Optional<V1Deployment> findedDeployment =
@@ -243,7 +216,7 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
243216
V1DeploymentSpec newSpec = deploy.getSpec().replicas(numberOfReplicas);
244217
V1Deployment newDeploy = deploy.spec(newSpec);
245218
appsV1Api.replaceNamespacedDeployment(
246-
deploymentName, DEFAULT_NAME_SPACE, newDeploy, null, null, null, null);
219+
deploymentName, DEFAULT_NAME_SPACE, newDeploy).execute();
247220
} catch (ApiException ex) {
248221
LOGGER.warn("Scale the pod failed for Deployment:" + deploymentName, ex);
249222
}
@@ -260,18 +233,12 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
260233
public static void printLog(String namespace, String podName) throws ApiException {
261234
// https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/CoreV1Api.md#readNamespacedPodLog
262235
String readNamespacedPodLog =
263-
COREV1_API.readNamespacedPodLog(
264-
podName,
265-
namespace,
266-
null,
267-
Boolean.FALSE,
268-
null,
269-
Integer.MAX_VALUE,
270-
null,
271-
Boolean.FALSE,
272-
Integer.MAX_VALUE,
273-
40,
274-
Boolean.FALSE);
236+
COREV1_API.readNamespacedPodLog(podName, namespace)
237+
.follow(false)
238+
.limitBytes(Integer.MAX_VALUE)
239+
.sinceSeconds(Integer.MAX_VALUE)
240+
.tailLines(40)
241+
.execute();
275242
System.out.println(readNamespacedPodLog);
276243
}
277244
}

examples/examples-release-19/src/main/java/io/kubernetes/client/examples/FluentExample.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static void main(String[] args) throws IOException, ApiException {
5454
.endSpec()
5555
.build();
5656

57-
api.createNamespacedPod("default", pod, null, null, null, null);
57+
api.createNamespacedPod("default", pod).execute();
5858

5959
V1Pod pod2 =
6060
new V1Pod()
@@ -63,11 +63,10 @@ public static void main(String[] args) throws IOException, ApiException {
6363
new V1PodSpec()
6464
.containers(Arrays.asList(new V1Container().name("www").image("nginx"))));
6565

66-
api.createNamespacedPod("default", pod2, null, null, null, null);
66+
api.createNamespacedPod("default", pod2).execute();
6767

6868
V1PodList list =
69-
api.listNamespacedPod(
70-
"default", null, null, null, null, null, null, null, null, null, null, null);
69+
api.listNamespacedPod("default").execute();
7170
for (V1Pod item : list.getItems()) {
7271
System.out.println(item.getMetadata().getName());
7372
}

0 commit comments

Comments
 (0)