use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.
the class SpringBootGenerator method getDefaultWebPort.
@Override
protected String getDefaultWebPort() {
Properties properties = SpringBootUtil.getSpringBootApplicationProperties(SpringBootUtil.getSpringBootActiveProfile(getProject()), JKubeProjectUtil.getClassLoader(getProject()));
SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getProject()));
return properties.getProperty(propertyHelper.getServerPortPropertyKey(), super.getDefaultWebPort());
}
use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.
the class AbstractSpringBootHealthCheckEnricherTestSupport method init.
@Before
public void init() {
String version = getSpringBootVersion();
this.propertyHelper = new SpringBootConfigurationHelper(Optional.of(version));
new Expectations() {
{
context.getDependencyVersion(SpringBootConfigurationHelper.SPRING_BOOT_GROUP_ID, SpringBootConfigurationHelper.SPRING_BOOT_ARTIFACT_ID);
result = Optional.of(version);
}
};
}
use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.
the class SpringBootHealthCheckEnricher method buildProbe.
protected Probe buildProbe(Properties springBootProperties, Integer initialDelay, Integer period, Integer timeout, Integer failureTh, Integer successTh) {
SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(getContext().getDependencyVersion(SpringBootConfigurationHelper.SPRING_BOOT_GROUP_ID, SpringBootConfigurationHelper.SPRING_BOOT_ARTIFACT_ID));
Integer managementPort = propertyHelper.getManagementPort(springBootProperties);
boolean usingManagementPort = managementPort != null;
Integer port = managementPort;
if (port == null) {
port = propertyHelper.getServerPort(springBootProperties);
}
String scheme;
String prefix;
if (usingManagementPort) {
scheme = StringUtils.isNotBlank(springBootProperties.getProperty(propertyHelper.getManagementKeystorePropertyKey())) ? SCHEME_HTTPS : SCHEME_HTTP;
prefix = springBootProperties.getProperty(propertyHelper.getManagementContextPathPropertyKey(), "");
} else {
scheme = StringUtils.isNotBlank(springBootProperties.getProperty(propertyHelper.getServerKeystorePropertyKey())) ? SCHEME_HTTPS : SCHEME_HTTP;
prefix = springBootProperties.getProperty(propertyHelper.getServerContextPathPropertyKey(), "");
prefix += springBootProperties.getProperty(propertyHelper.getServletPathPropertyKey(), "");
prefix += springBootProperties.getProperty(propertyHelper.getManagementContextPathPropertyKey(), "");
}
String actuatorBasePathKey = propertyHelper.getActuatorBasePathPropertyKey();
String actuatorBasePath = propertyHelper.getActuatorDefaultBasePath();
if (actuatorBasePathKey != null) {
actuatorBasePath = springBootProperties.getProperty(actuatorBasePathKey, actuatorBasePath);
}
// lets default to adding a spring boot actuator health check
ProbeBuilder probeBuilder = new ProbeBuilder().withNewHttpGet().withNewPort(port).withPath(normalizeMultipleSlashes(prefix + actuatorBasePath + Configs.asString(getConfig(Config.PATH)))).withScheme(scheme).endHttpGet();
if (initialDelay != null) {
probeBuilder = probeBuilder.withInitialDelaySeconds(initialDelay);
}
if (period != null) {
probeBuilder = probeBuilder.withPeriodSeconds(period);
}
if (timeout != null) {
probeBuilder.withTimeoutSeconds(timeout);
}
if (failureTh != null) {
probeBuilder.withFailureThreshold(failureTh);
}
if (successTh != null) {
probeBuilder.withSuccessThreshold(successTh);
}
return probeBuilder.build();
}
use of org.eclipse.jkube.kit.common.util.SpringBootConfigurationHelper in project jkube by eclipse.
the class SpringBootWatcher method getPortForwardUrl.
String getPortForwardUrl(final String namespace, final Collection<HasMetadata> resources) {
LabelSelector selector = KubernetesHelper.extractPodLabelSelector(resources);
if (selector == null) {
log.warn("Unable to determine a selector for application pods");
return null;
}
Properties properties = SpringBootUtil.getSpringBootApplicationProperties(JKubeProjectUtil.getClassLoader(getContext().getBuildContext().getProject()));
SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getContext().getBuildContext().getProject()));
int localHostPort = IoUtil.getFreeRandomPort();
int containerPort = propertyHelper.getServerPort(properties);
portForwardService.forwardPortAsync(selector, namespace, containerPort, localHostPort);
return createForwardUrl(propertyHelper, properties, localHostPort);
}
Aggregations