Skip to content

Commit 310186a

Browse files
authored
Merge pull request #1903 from wind57/drop_unused_k8s_client_it_methods
Drop unused k8s client it methods
2 parents 877505e + 760317f commit 310186a

File tree

1 file changed

+0
-81
lines changed
  • spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client

1 file changed

+0
-81
lines changed

spring-cloud-kubernetes-test-support/src/main/java/org/springframework/cloud/kubernetes/integration/tests/commons/native_client/Util.java

Lines changed: 0 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.util.concurrent.TimeUnit;
3030
import java.util.stream.Collectors;
3131

32-
import io.kubernetes.client.custom.V1Patch;
3332
import io.kubernetes.client.openapi.ApiClient;
3433
import io.kubernetes.client.openapi.ApiException;
3534
import io.kubernetes.client.openapi.Configuration;
@@ -40,7 +39,6 @@
4039
import io.kubernetes.client.openapi.apis.RbacAuthorizationV1Api;
4140
import io.kubernetes.client.openapi.models.V1APIService;
4241
import io.kubernetes.client.openapi.models.V1ClusterRole;
43-
import io.kubernetes.client.openapi.models.V1ClusterRoleBinding;
4442
import io.kubernetes.client.openapi.models.V1ConfigMap;
4543
import io.kubernetes.client.openapi.models.V1Deployment;
4644
import io.kubernetes.client.openapi.models.V1DeploymentCondition;
@@ -55,7 +53,6 @@
5553
import io.kubernetes.client.openapi.models.V1Service;
5654
import io.kubernetes.client.openapi.models.V1ServiceAccount;
5755
import io.kubernetes.client.util.Config;
58-
import io.kubernetes.client.util.PatchUtils;
5956
import io.kubernetes.client.util.Yaml;
6057
import jakarta.annotation.Nullable;
6158
import org.apache.commons.logging.Log;
@@ -335,49 +332,6 @@ public void setUp(String namespace) {
335332

336333
}
337334

338-
public void setUpClusterWideClusterRoleBinding(String serviceAccountNamespace) {
339-
340-
try {
341-
V1ServiceAccount serviceAccount = (V1ServiceAccount) yaml("cluster/service-account.yaml");
342-
CheckedSupplier<V1ServiceAccount> accountSupplier = () -> coreV1Api
343-
.readNamespacedServiceAccount(serviceAccount.getMetadata().getName(), serviceAccountNamespace, null);
344-
CheckedSupplier<V1ServiceAccount> accountDefaulter = () -> coreV1Api
345-
.createNamespacedServiceAccount(serviceAccountNamespace, serviceAccount, null, null, null, null);
346-
notExistsHandler(accountSupplier, accountDefaulter);
347-
348-
V1ClusterRole clusterRole = (V1ClusterRole) yaml("cluster/cluster-role.yaml");
349-
notExistsHandler(() -> rbacApi.readClusterRole(clusterRole.getMetadata().getName(), null),
350-
() -> rbacApi.createClusterRole(clusterRole, null, null, null, null));
351-
352-
V1ClusterRoleBinding clusterRoleBinding = (V1ClusterRoleBinding) yaml("cluster/cluster-role-binding.yaml");
353-
notExistsHandler(() -> rbacApi.readClusterRoleBinding(clusterRoleBinding.getMetadata().getName(), null),
354-
() -> rbacApi.createClusterRoleBinding(clusterRoleBinding, null, null, null, null));
355-
}
356-
catch (Exception e) {
357-
e.printStackTrace();
358-
throw new RuntimeException(e);
359-
}
360-
361-
}
362-
363-
public void deleteClusterWideClusterRoleBinding(String serviceAccountNamespace) {
364-
try {
365-
V1ServiceAccount serviceAccount = (V1ServiceAccount) yaml("cluster/service-account.yaml");
366-
V1ClusterRole clusterRole = (V1ClusterRole) yaml("cluster/cluster-role.yaml");
367-
V1ClusterRoleBinding clusterRoleBinding = (V1ClusterRoleBinding) yaml("cluster/cluster-role-binding.yaml");
368-
369-
coreV1Api.deleteNamespacedServiceAccount(serviceAccount.getMetadata().getName(), serviceAccountNamespace,
370-
null, null, null, null, null, null);
371-
rbacApi.deleteClusterRole(clusterRole.getMetadata().getName(), null, null, null, null, null, null);
372-
rbacApi.deleteClusterRoleBinding(clusterRoleBinding.getMetadata().getName(), null, null, null, null, null,
373-
null);
374-
}
375-
catch (Exception e) {
376-
e.printStackTrace();
377-
throw new RuntimeException(e);
378-
}
379-
}
380-
381335
public void setUpClusterWide(String serviceAccountNamespace, Set<String> namespaces) {
382336

383337
try {
@@ -517,41 +471,6 @@ public void wiremock(String namespace, String path, Phase phase, boolean withIng
517471

518472
}
519473

520-
public static void patchWithMerge(String deploymentName, String namespace, String patchBody,
521-
Map<String, String> podLabels) {
522-
try {
523-
PatchUtils.patch(V1Deployment.class,
524-
() -> new AppsV1Api().patchNamespacedDeploymentCall(deploymentName, namespace,
525-
new V1Patch(patchBody), null, null, null, null, null, null),
526-
V1Patch.PATCH_FORMAT_STRATEGIC_MERGE_PATCH, new CoreV1Api().getApiClient());
527-
}
528-
catch (ApiException e) {
529-
LOG.error("error : " + e.getResponseBody());
530-
throw new RuntimeException(e);
531-
}
532-
533-
waitForDeploymentAfterPatch(deploymentName, namespace, podLabels);
534-
}
535-
536-
public static void patchWithReplace(String imageName, String deploymentName, String namespace, String patchBody,
537-
Map<String, String> podLabels) {
538-
String body = patchBody.replace("image_name_here", imageName);
539-
540-
try {
541-
PatchUtils.patch(V1Deployment.class,
542-
() -> new AppsV1Api().patchNamespacedDeploymentCall(deploymentName, namespace, new V1Patch(body),
543-
null, null, null, null, null, null),
544-
V1Patch.PATCH_FORMAT_JSON_MERGE_PATCH, new CoreV1Api().getApiClient());
545-
}
546-
catch (ApiException e) {
547-
LOG.error("error : " + e.getResponseBody());
548-
throw new RuntimeException(e);
549-
}
550-
551-
waitForDeploymentAfterPatch(deploymentName, namespace, podLabels);
552-
553-
}
554-
555474
private String deploymentName(V1Deployment deployment) {
556475
return deployment.getMetadata().getName();
557476
}

0 commit comments

Comments
 (0)