use of io.fabric8.maven.core.util.SpringBootConfigurationHelper in project fabric8-maven-plugin by fabric8io.
the class SpringBootGenerator method extractPorts.
@Override
protected List<String> extractPorts() {
List<String> answer = new ArrayList<>();
Properties properties = SpringBootUtil.getSpringBootApplicationProperties(this.getProject());
SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getProject()));
String port = properties.getProperty(propertyHelper.getServerPortPropertyKey(), DEFAULT_SERVER_PORT);
addPortIfValid(answer, getConfig(JavaExecGenerator.Config.webPort, port));
addPortIfValid(answer, getConfig(JavaExecGenerator.Config.jolokiaPort));
addPortIfValid(answer, getConfig(JavaExecGenerator.Config.prometheusPort));
return answer;
}
use of io.fabric8.maven.core.util.SpringBootConfigurationHelper in project fabric8-maven-plugin by fabric8io.
the class SpringBootWatcher method getPortForwardUrl.
private String getPortForwardUrl(final Set<HasMetadata> resources) throws Exception {
LabelSelector selector = KubernetesResourceUtil.getPodLabelSelector(resources);
if (selector == null) {
log.warn("Unable to determine a selector for application pods");
return null;
}
Properties properties = SpringBootUtil.getSpringBootApplicationProperties(getContext().getProject());
SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getContext().getProject()));
PortForwardService portForwardService = getContext().getFabric8ServiceHub().getPortForwardService();
int port = IoUtil.getFreeRandomPort();
int containerPort = findSpringBootWebPort(propertyHelper, properties);
portForwardService.forwardPortAsync(getContext().getLogger(), selector, containerPort, port);
return createForwardUrl(propertyHelper, properties, port);
}
use of io.fabric8.maven.core.util.SpringBootConfigurationHelper in project fabric8-maven-plugin by fabric8io.
the class AbstractSpringBootHealthCheckEnricherSupport method init.
@Before
public void init() {
String version = getSpringBootVersion();
this.propertyHelper = new SpringBootConfigurationHelper(version);
final MavenProject project = new MavenProject();
Set<Artifact> artifacts = new HashSet<>();
Artifact a = new DefaultArtifact("org.springframework.boot", "spring-boot", version, "compile", "jar", "", null);
a.setResolved(true);
artifacts.add(a);
project.setArtifacts(artifacts);
new Expectations() {
{
context.getProject();
result = project;
}
};
}
use of io.fabric8.maven.core.util.SpringBootConfigurationHelper in project fabric8-maven-plugin by fabric8io.
the class SpringBootHealthCheckEnricher method buildProbe.
protected Probe buildProbe(Properties springBootProperties, Integer initialDelay, Integer period) {
SpringBootConfigurationHelper propertyHelper = new SpringBootConfigurationHelper(SpringBootUtil.getSpringBootVersion(getContext().getProject()));
Integer managementPort = PropertiesHelper.getInteger(springBootProperties, propertyHelper.getManagementPortPropertyKey());
boolean usingManagementPort = managementPort != null;
Integer port = managementPort;
if (port == null) {
port = PropertiesHelper.getInteger(springBootProperties, propertyHelper.getServerPortPropertyKey(), DEFAULT_SERVER_PORT);
}
String scheme;
String prefix;
if (usingManagementPort) {
scheme = Strings.isNotBlank(springBootProperties.getProperty(propertyHelper.getManagementKeystorePropertyKey())) ? SCHEME_HTTPS : SCHEME_HTTP;
prefix = springBootProperties.getProperty(propertyHelper.getManagementContextPathPropertyKey(), "");
} else {
scheme = Strings.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(prefix + actuatorBasePath + "/health").withScheme(scheme).endHttpGet();
if (initialDelay != null) {
probeBuilder = probeBuilder.withInitialDelaySeconds(initialDelay);
}
if (period != null) {
probeBuilder = probeBuilder.withPeriodSeconds(period);
}
return probeBuilder.build();
}
Aggregations