Skip to content

Commit

Permalink
fixes compile issues
Browse files Browse the repository at this point in the history
Signed-off-by: Min Jin <[email protected]>

remove java8 from build action

Signed-off-by: Min Jin <[email protected]>
  • Loading branch information
yue9944882 committed Jan 11, 2024
1 parent 87c890c commit 56449d9
Show file tree
Hide file tree
Showing 62 changed files with 858 additions and 561 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: actions/checkout@v4
with:
path: gen
repository: yue9944882/gen
repository: kubernetes-client/gen
token: ${{ secrets.PAT_TOKEN }}
- name: Generate Branch Name
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
strategy:
matrix:
# Test against the LTS Java versions. TODO: add JDK18 when it becomes available.
java: [ 8.0.x, 11.0.x, 17.0.x ]
java: [ 11.0.x, 17.0.x ]
os: [ macos-latest, windows-latest, ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ private void deleteConfigMapLockResource() throws Exception {
try {
CoreV1Api coreV1Api = new CoreV1Api(apiClient);
coreV1Api.deleteNamespacedConfigMap(
LOCK_RESOURCE_NAME, NAMESPACE, null, null, null, null, null, null);
LOCK_RESOURCE_NAME, NAMESPACE).execute();
} catch (ApiException ex) {
if (ex.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
throw ex;
Expand All @@ -289,7 +289,7 @@ private void deleteEndpointsLockResource() throws Exception {
try {
CoreV1Api coreV1Api = new CoreV1Api(apiClient);
coreV1Api.deleteNamespacedEndpoints(
LOCK_RESOURCE_NAME, NAMESPACE, null, null, null, null, null, null);
LOCK_RESOURCE_NAME, NAMESPACE).execute();
} catch (ApiException ex) {
if (ex.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
throw ex;
Expand All @@ -301,7 +301,7 @@ private void deleteLeaseLockResource() throws Exception {
try {
CoordinationV1Api coordinationV1Api = new CoordinationV1Api(apiClient);
coordinationV1Api.deleteNamespacedLease(
LOCK_RESOURCE_NAME, NAMESPACE, null, null, null, null, null, null);
LOCK_RESOURCE_NAME, NAMESPACE).execute();
} catch (ApiException ex) {
if (ex.getCode() != HttpURLConnection.HTTP_NOT_FOUND) {
throw ex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,11 @@ public static void main(String[] args) throws IOException {
SharedIndexInformer<V1Node> nodeInformer =
informerFactory.sharedIndexInformerFor(
(CallGeneratorParams params) -> {
return coreV1Api.listNodeCall(
null,
null,
null,
null,
null,
null,
params.resourceVersion,
null,
null,
params.timeoutSeconds,
params.watch,
null);
return coreV1Api.listNode()
.resourceVersion(params.resourceVersion)
.timeoutSeconds(params.timeoutSeconds)
.watch(params.watch)
.buildCall(null);
},
V1Node.class,
V1NodeList.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public static void main(String[] args) throws IOException, ApiException {
.name(deploymentName)
.image(imageName))))));
appsV1Api.createNamespacedDeployment(
namespace, deploymentBuilder.build(), null, null, null, null);
namespace, deploymentBuilder.build()).execute();

// Wait until example deployment is ready
Wait.poll(
Expand All @@ -74,7 +74,8 @@ public static void main(String[] args) throws IOException, ApiException {
try {
System.out.println("Waiting until example deployment is ready...");
return appsV1Api
.readNamespacedDeployment(deploymentName, namespace, null)
.readNamespacedDeployment(deploymentName, namespace)
.execute()
.getStatus()
.getReadyReplicas()
> 0;
Expand All @@ -87,7 +88,7 @@ public static void main(String[] args) throws IOException, ApiException {

// Trigger a rollout restart of the example deployment
V1Deployment runningDeployment =
appsV1Api.readNamespacedDeployment(deploymentName, namespace, null);
appsV1Api.readNamespacedDeployment(deploymentName, namespace).execute();

// Explicitly set "restartedAt" annotation with current date/time to trigger rollout when patch
// is applied
Expand All @@ -102,16 +103,12 @@ public static void main(String[] args) throws IOException, ApiException {
PatchUtils.patch(
V1Deployment.class,
() ->
appsV1Api.patchNamespacedDeploymentCall(
appsV1Api.patchNamespacedDeployment(
deploymentName,
namespace,
new V1Patch(deploymentJson),
null,
null,
"kubectl-rollout",
null,
null,
null),
new V1Patch(deploymentJson))
.fieldManager("kubectl-rollout")
.buildCall(null),
V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH,
client);

Expand All @@ -123,7 +120,8 @@ public static void main(String[] args) throws IOException, ApiException {
try {
System.out.println("Waiting until example deployment restarted successfully...");
return appsV1Api
.readNamespacedDeployment(deploymentName, namespace, null)
.readNamespacedDeployment(deploymentName, namespace)
.execute()
.getStatus()
.getReadyReplicas()
> 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static void main(String[] args) throws IOException, ApiException {
Configuration.setDefaultApiClient(client);

CoreV1Api api = new CoreV1Api();
V1PodList list =
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
V1PodList list = api.listPodForAllNamespaces()
.execute();
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ public static void main(String[] args) {
*/
public static List<String> getAllNameSpaces() throws ApiException {
V1NamespaceList listNamespace =
COREV1_API.listNamespace(
null, null, null, null, null, null, null, null, null, null, null);
COREV1_API.listNamespace().execute();
List<String> list =
listNamespace.getItems().stream()
.map(v1Namespace -> v1Namespace.getMetadata().getName())
Expand All @@ -118,8 +117,7 @@ public static List<String> getAllNameSpaces() throws ApiException {
*/
public static List<String> getPods() throws ApiException {
V1PodList v1podList =
COREV1_API.listPodForAllNamespaces(
null, null, null, null, null, null, null, null, null, null, null);
COREV1_API.listPodForAllNamespaces().execute();
List<String> podList =
v1podList.getItems().stream()
.map(v1Pod -> v1Pod.getMetadata().getName())
Expand Down Expand Up @@ -159,18 +157,11 @@ public static List<String> getNamespacedPod(String namespace) throws ApiExceptio
public static List<String> getNamespacedPod(String namespace, String label) throws ApiException {
V1PodList listNamespacedPod =
COREV1_API.listNamespacedPod(
namespace,
null,
null,
null,
null,
label,
null,
null,
null,
null,
TIME_OUT_VALUE,
Boolean.FALSE);
namespace)
.labelSelector(label)
.timeoutSeconds(TIME_OUT_VALUE)
.watch(false)
.execute();
List<String> listPods =
listNamespacedPod.getItems().stream()
.map(v1pod -> v1pod.getMetadata().getName())
Expand All @@ -186,19 +177,10 @@ public static List<String> getNamespacedPod(String namespace, String label) thro
*/
public static List<String> getServices() throws ApiException {
V1ServiceList listNamespacedService =
COREV1_API.listNamespacedService(
DEFAULT_NAME_SPACE,
null,
null,
null,
null,
null,
null,
null,
null,
null,
TIME_OUT_VALUE,
Boolean.FALSE);
COREV1_API.listNamespacedService(DEFAULT_NAME_SPACE)
.timeoutSeconds(TIME_OUT_VALUE)
.watch(false)
.execute();
return listNamespacedService.getItems().stream()
.map(v1service -> v1service.getMetadata().getName())
.collect(Collectors.toList());
Expand All @@ -217,18 +199,9 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
appsV1Api.setApiClient(COREV1_API.getApiClient());
V1DeploymentList listNamespacedDeployment =
appsV1Api.listNamespacedDeployment(
DEFAULT_NAME_SPACE,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
Boolean.FALSE);
DEFAULT_NAME_SPACE)
.watch(false)
.execute();

List<V1Deployment> appsV1DeploymentItems = listNamespacedDeployment.getItems();
Optional<V1Deployment> findedDeployment =
Expand All @@ -243,7 +216,7 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
V1DeploymentSpec newSpec = deploy.getSpec().replicas(numberOfReplicas);
V1Deployment newDeploy = deploy.spec(newSpec);
appsV1Api.replaceNamespacedDeployment(
deploymentName, DEFAULT_NAME_SPACE, newDeploy, null, null, null, null);
deploymentName, DEFAULT_NAME_SPACE, newDeploy).execute();
} catch (ApiException ex) {
LOGGER.warn("Scale the pod failed for Deployment:" + deploymentName, ex);
}
Expand All @@ -260,18 +233,12 @@ public static void scaleDeployment(String deploymentName, int numberOfReplicas)
public static void printLog(String namespace, String podName) throws ApiException {
// https://github.com/kubernetes-client/java/blob/master/kubernetes/docs/CoreV1Api.md#readNamespacedPodLog
String readNamespacedPodLog =
COREV1_API.readNamespacedPodLog(
podName,
namespace,
null,
Boolean.FALSE,
null,
Integer.MAX_VALUE,
null,
Boolean.FALSE,
Integer.MAX_VALUE,
40,
Boolean.FALSE);
COREV1_API.readNamespacedPodLog(podName, namespace)
.follow(false)
.limitBytes(Integer.MAX_VALUE)
.sinceSeconds(Integer.MAX_VALUE)
.tailLines(40)
.execute();
System.out.println(readNamespacedPodLog);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public static void main(String[] args) throws IOException, ApiException {
.endSpec()
.build();

api.createNamespacedPod("default", pod, null, null, null, null);
api.createNamespacedPod("default", pod).execute();

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

api.createNamespacedPod("default", pod2, null, null, null, null);
api.createNamespacedPod("default", pod2).execute();

V1PodList list =
api.listNamespacedPod(
"default", null, null, null, null, null, null, null, null, null, null, null);
api.listNamespacedPod("default").execute();
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void main(String[] args) throws IOException, ApiException {

// invokes the CoreV1Api client
V1PodList list =
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
api.listPodForAllNamespaces().execute();
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,11 @@ public static void main(String[] args) throws Exception {
// HTTPs requests, the effective apiClient is the one specified when constructing
// the informer-factory.
(CallGeneratorParams params) -> {
return coreV1Api.listNodeCall(
null,
null,
null,
null,
null,
null,
params.resourceVersion,
null,
null,
params.timeoutSeconds,
params.watch,
null);
return coreV1Api.listNode()
.resourceVersion(params.resourceVersion)
.watch(params.watch)
.timeoutSeconds(params.timeoutSeconds)
.buildCall(null);
},
V1Node.class,
V1NodeList.class);
Expand Down Expand Up @@ -94,7 +86,7 @@ public void onDelete(V1Node node, boolean deletedFinalStateUnknown) {
V1ObjectMeta metadata = new V1ObjectMeta();
metadata.setName("noxu");
nodeToCreate.setMetadata(metadata);
V1Node createdNode = coreV1Api.createNode(nodeToCreate, null, null, null, null);
V1Node createdNode = coreV1Api.createNode(nodeToCreate).execute();
Thread.sleep(3000);

Lister<V1Node> nodeLister = new Lister<V1Node>(nodeInformer.getIndexer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void main(String[] args) throws IOException, ApiException {

// invokes the CoreV1Api client
V1PodList list =
api.listPodForAllNamespaces(null, null, null, null, null, null, null, null, null, null, null);
api.listPodForAllNamespaces().execute();
for (V1Pod item : list.getItems()) {
System.out.println(item.getMetadata().getName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ public static void main(String[] args) throws IOException, ApiException, Interru
PodLogs logs = new PodLogs();
V1Pod pod =
coreApi
.listNamespacedPod(
"default", "false", null, null, null, null, null, null, null, null, null, null)
.listNamespacedPod("default")
.execute()
.getItems()
.get(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,11 @@ public static void main(String[] args) throws IOException {
new Pager<V1Namespace, V1NamespaceList>(
(Pager.PagerParams param) -> {
try {
return api.listNamespaceCall(
null,
null,
param.getContinueToken(),
null,
null,
param.getLimit(),
null,
null,
null,
1,
null,
null);
return api.listNamespace()
._continue(param.getContinueToken())
.limit(param.getLimit())
.timeoutSeconds(1)
.buildCall(null);
} catch (Exception e) {
throw new RuntimeException(e);
}
Expand Down
Loading

0 comments on commit 56449d9

Please sign in to comment.