Skip to content

Commit 2ed09f8

Browse files
committed
Use call factory for custom resource definition calls
1 parent 59bac25 commit 2ed09f8

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

operator/src/main/java/oracle/kubernetes/operator/helpers/CallBuilder.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ public Step replaceDomainAsync(String name, String namespace, Domain body, Respo
250250
public V1beta1CustomResourceDefinition readCustomResourceDefinition(String name) throws ApiException {
251251
ApiClient client = helper.take();
252252
try {
253-
return new ApiextensionsV1beta1Api(client).readCustomResourceDefinition(name, pretty, exact, export);
253+
return CALL_FACTORY.readCustomResourceDefinition(client, name, pretty, exact, export);
254254
} finally {
255255
helper.recycle(client);
256256
}
@@ -266,7 +266,7 @@ public V1beta1CustomResourceDefinition createCustomResourceDefinition(V1beta1Cus
266266
throws ApiException {
267267
ApiClient client = helper.take();
268268
try {
269-
return new ApiextensionsV1beta1Api(client).createCustomResourceDefinition(body, pretty);
269+
return CALL_FACTORY.createCustomResourceDefinition(client, body, pretty);
270270
} finally {
271271
helper.recycle(client);
272272
}
@@ -968,6 +968,16 @@ private <T> Step createRequestAsync(ResponseStep<T> next, RequestParams requestP
968968

969969

970970
public static class SynchronousCallFactoryImpl implements SynchronousCallFactory {
971+
@Override
972+
public V1beta1CustomResourceDefinition readCustomResourceDefinition(ApiClient client, String name, String pretty, Boolean exact, Boolean export) throws ApiException {
973+
return new ApiextensionsV1beta1Api(client).readCustomResourceDefinition(name, pretty, exact, export);
974+
}
975+
976+
@Override
977+
public V1beta1CustomResourceDefinition createCustomResourceDefinition(ApiClient client, V1beta1CustomResourceDefinition body, String pretty) throws ApiException {
978+
return new ApiextensionsV1beta1Api(client).createCustomResourceDefinition(body, pretty);
979+
}
980+
971981
@Override
972982
public V1SelfSubjectRulesReview createSelfSubjectRulesReview(ApiClient client, V1SelfSubjectRulesReview body, String pretty) throws ApiException {
973983
return new AuthorizationV1Api(client).createSelfSubjectRulesReview(body, pretty);

operator/src/main/java/oracle/kubernetes/operator/helpers/SynchronousCallFactory.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@
44
import io.kubernetes.client.ApiException;
55
import io.kubernetes.client.models.V1PersistentVolumeList;
66
import io.kubernetes.client.models.V1SelfSubjectRulesReview;
7+
import io.kubernetes.client.models.V1beta1CustomResourceDefinition;
78
import io.kubernetes.client.models.VersionInfo;
89
import oracle.kubernetes.weblogic.domain.v1.DomainList;
910

1011
public interface SynchronousCallFactory {
1112

13+
V1beta1CustomResourceDefinition readCustomResourceDefinition(ApiClient client, String name, String pretty, Boolean exact, Boolean export) throws ApiException;
14+
15+
V1beta1CustomResourceDefinition createCustomResourceDefinition(ApiClient client, V1beta1CustomResourceDefinition body, String pretty) throws ApiException;
16+
1217
V1SelfSubjectRulesReview createSelfSubjectRulesReview(ApiClient client, V1SelfSubjectRulesReview body, String pretty) throws ApiException;
1318

1419
V1PersistentVolumeList listPersistentVolumes(String _continue, ApiClient client, String pretty, String fieldSelector, Boolean includeUninitialized, String labelSelector, Integer limit, String resourceVersion, Integer timeoutSeconds, Boolean watch) throws ApiException;

operator/src/test/java/oracle/kubernetes/operator/builders/StubWatchFactory.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static List<Map<String, String>> getRecordedParameters() {
6969
public <T> WatchI<T> createWatch(Pool<ApiClient> pool, CallParams callParams, Class<?> responseBodyType, BiFunction<ApiClient, CallParams, Call> function) throws ApiException {
7070
getRecordedParameters().add(recordedParams(callParams));
7171

72-
if (exceptionOnNext == null && hasDefinedCallResponses())
72+
if (exceptionOnNext == null)
7373
return new WatchStub<T>((List)calls.remove(0));
7474
else try {
7575
return new ExceptionThrowingWatchStub<T>(exceptionOnNext);
@@ -78,10 +78,6 @@ public <T> WatchI<T> createWatch(Pool<ApiClient> pool, CallParams callParams, Cl
7878
}
7979
}
8080

81-
private boolean hasDefinedCallResponses() {
82-
return calls != null && !calls.isEmpty();
83-
}
84-
8581
private Map<String,String> recordedParams(CallParams callParams) {
8682
Map<String,String> result = new HashMap<>();
8783
if (callParams.getResourceVersion() != null)

0 commit comments

Comments
 (0)