use of oracle.kubernetes.operator.helpers.CallBuilderFactory in project weblogic-kubernetes-operator by oracle.
the class DomainStatusUpdater method doDomainUpdate.
private static NextAction doDomainUpdate(Domain dom, DomainPresenceInfo info, Packet packet, Step conflictStep, Step next) {
V1ObjectMeta meta = dom.getMetadata();
NextAction na = new NextAction();
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
na.invoke(factory.create().replaceDomainAsync(meta.getName(), meta.getNamespace(), dom, new ResponseStep<Domain>(next) {
@Override
public NextAction onFailure(Packet packet, ApiException e, int statusCode, Map<String, List<String>> responseHeaders) {
if (statusCode == CallBuilder.NOT_FOUND) {
// Just ignore update
return doNext(packet);
}
return super.onFailure(conflictStep, packet, e, statusCode, responseHeaders);
}
@Override
public NextAction onSuccess(Packet packet, Domain result, int statusCode, Map<String, List<String>> responseHeaders) {
info.setDomain(result);
return doNext(packet);
}
}), packet);
return na;
}
use of oracle.kubernetes.operator.helpers.CallBuilderFactory in project weblogic-kubernetes-operator by oracle.
the class RestBackendImpl method getDomainsList.
private List<Domain> getDomainsList() {
CallBuilderFactory factory = ContainerResolver.getInstance().getContainer().getSPI(CallBuilderFactory.class);
Collection<List<Domain>> c = new ArrayList<List<Domain>>();
try {
for (String ns : targetNamespaces) {
DomainList dl = factory.create().listDomain(ns);
if (dl != null) {
c.add(dl.getItems());
}
}
return c.stream().flatMap(Collection::stream).collect(Collectors.toList());
} catch (ApiException e) {
throw handleApiException(e);
}
}
use of oracle.kubernetes.operator.helpers.CallBuilderFactory in project weblogic-kubernetes-operator by oracle.
the class HealthCheckHelperTest method createNamespace.
// Create a named namespace
private V1Namespace createNamespace(String name) throws Exception {
CallBuilderFactory factory = new CallBuilderFactory(null);
try {
V1Namespace existing = factory.create().readNamespace(name);
if (existing != null)
return existing;
} catch (ApiException ignore) {
// Just ignore and try to create it
}
V1Namespace body = new V1Namespace();
// Set the required api version and kind of resource
body.setApiVersion("v1");
body.setKind("Namespace");
// Setup the standard object metadata
V1ObjectMeta meta = new V1ObjectMeta();
meta.setName(name);
body.setMetadata(meta);
return factory.create().createNamespace(body);
}
use of oracle.kubernetes.operator.helpers.CallBuilderFactory in project weblogic-kubernetes-operator by oracle.
the class SecretHelperTest method createInvalidSecret.
// Create a named secret with no username / password in specified namespace
private V1Secret createInvalidSecret(String name, String namespace) throws Exception {
CallBuilderFactory factory = new CallBuilderFactory(null);
try {
V1Secret existing = factory.create().readSecret(name, namespace);
if (existing != null)
return existing;
} catch (ApiException ignore) {
// Just ignore and try to create it
}
if (isVersion18)
return null;
V1Secret body = new V1Secret();
// Set the required api version and kind of resource
body.setApiVersion("v1");
body.setKind("Secret");
// Setup the standard object metadata
V1ObjectMeta meta = new V1ObjectMeta();
meta.setName(name);
meta.setNamespace(namespace);
body.setMetadata(meta);
return factory.create().createSecret(namespace, body);
}
use of oracle.kubernetes.operator.helpers.CallBuilderFactory in project weblogic-kubernetes-operator by oracle.
the class ServiceHelperTest method createReadListUpdate.
@Test
public void createReadListUpdate() throws Exception {
CallBuilderFactory factory = new CallBuilderFactory(null);
// Domain
Domain dom = new Domain();
V1ObjectMeta metadata = new V1ObjectMeta();
metadata.setResourceVersion("12345");
metadata.setNamespace("tests");
dom.setMetadata(metadata);
DomainSpec spec = new DomainSpec();
spec.setDomainUID("domain-uid");
spec.setDomainName("base_domain");
dom.setSpec(spec);
// Create a new service.
System.out.println("Creating service");
Step s = ServiceHelper.createForServerStep(null);
Engine e = new Engine("ServiceHelperTest");
Packet p = new Packet();
DomainPresenceInfo info = new DomainPresenceInfo(dom);
p.getComponents().put(ProcessingConstants.DOMAIN_COMPONENT_NAME, Component.createFor(info));
p.put(ProcessingConstants.SERVER_NAME, "admin");
p.put(ProcessingConstants.PORT, Integer.valueOf(7001));
Fiber f = e.createFiber();
f.start(s, p, null);
f.get();
// Read the service we just created.
System.out.println("Reading service");
V1Service service = factory.create().readService("domain-uid-admin", "tests");
checkService(service, false);
// Get a list of services.
System.out.println("Listing services");
V1ServiceList serviceList = factory.create().listService("tests");
boolean serviceFound = false;
for (V1Service item : serviceList.getItems()) {
if (item.getMetadata().getName().equals("domain-uid-admin")) {
serviceFound = true;
break;
}
}
Assert.assertTrue("Expected service domain-uid-admin not found in list", serviceFound);
// Add a second selector to this service.
Map<String, String> selector = service.getSpec().getSelector();
selector.put("domain", "domain-uid");
service.getSpec().setSelector(selector);
// TODO: uncomment out when bug calling replace service is fixed.
// System.out.println("Replacing service");
// service = serviceHelper.replace("domain-uid-admin", service);
// checkService(service, true);
}
Aggregations