use of io.fabric8.maven.core.service.ApplyService in project fabric8 by jboss-fuse.
the class Controller method applyService.
public void applyService(Service service, String sourceName) throws Exception {
String namespace = getNamespace();
String id = getName(service);
Objects.notNull(id, "No name for " + service + " " + sourceName);
if (isIgnoreServiceMode()) {
LOG.debug("Ignoring Service: " + namespace + ":" + id);
return;
}
Service old = kubernetesClient.services().inNamespace(namespace).withName(id).get();
if (isRunning(old)) {
if (UserConfigurationCompare.configEqual(service, old)) {
LOG.info("Service has not changed so not doing anything");
} else {
if (isRecreateMode()) {
LOG.info("Deleting Service: " + id);
kubernetesClient.services().inNamespace(namespace).withName(id).delete();
doCreateService(service, namespace, sourceName);
} else {
LOG.info("Updating a Service from " + sourceName);
try {
Object answer = kubernetesClient.services().inNamespace(namespace).withName(id).replace(service);
logGeneratedEntity("Updated Service: ", namespace, service, answer);
} catch (Exception e) {
onApplyError("Failed to update Service from " + sourceName + ". " + e + ". " + service, e);
}
}
}
} else {
if (!isAllowCreate()) {
LOG.warn("Creation disabled so not creating a Service from " + sourceName + " namespace " + namespace + " name " + getName(service));
} else {
doCreateService(service, namespace, sourceName);
}
}
}
use of io.fabric8.maven.core.service.ApplyService in project fabric8-maven-plugin by fabric8io.
the class ApplyService method applyService.
public void applyService(Service service, String sourceName) throws Exception {
String namespace = getNamespace(service);
String id = getName(service);
Objects.requireNonNull(id, "No name for " + service + " " + sourceName);
if (isIgnoreServiceMode()) {
log.debug("Ignoring Service: " + namespace + ":" + id);
return;
}
Service old = kubernetesClient.services().inNamespace(namespace).withName(id).get();
if (isRunning(old)) {
if (UserConfigurationCompare.configEqual(service, old)) {
log.info("Service has not changed so not doing anything");
} else {
if (isRecreateMode()) {
log.info("Deleting Service: " + id);
kubernetesClient.services().inNamespace(namespace).withName(id).delete();
doCreateService(service, namespace, sourceName);
} else {
log.info("Updating a Service from " + sourceName);
try {
Object answer = patchService.compareAndPatchEntity(namespace, service, old);
logGeneratedEntity("Updated Service: ", namespace, service, answer);
} catch (Exception e) {
onApplyError("Failed to update Service from " + sourceName + ". " + e + ". " + service, e);
}
}
}
} else {
if (!isAllowCreate()) {
log.warn("Creation disabled so not creating a Service from " + sourceName + " namespace " + namespace + " name " + getName(service));
} else {
doCreateService(service, namespace, sourceName);
}
}
}
Aggregations