use of io.dekorate.config.ConfigurationSupplier in project dekorate by dekorateio.
the class GeneratorConfigGenerator method configurePaths.
default void configurePaths(String defaultInputPath, String defaultOutputPath) {
final String inputPath = System.getProperty(INPUT_DIR, defaultInputPath);
final String outputPath = Optional.ofNullable(System.getProperty(OUTPUT_DIR)).map(path -> {
resolve(path).mkdirs();
return path;
}).orElse(defaultOutputPath);
if (isInputPathValid(inputPath)) {
applyToProject(p -> p.withDekorateInputDir(inputPath));
getSession().getConfigurationRegistry().add(new ConfigurationSupplier<>(new GeneratorConfigBuilder()));
}
if (isOutputPathValid(outputPath)) {
applyToProject(p -> p.withDekorateOutputDir(outputPath));
getSession().setWriter(new SimpleFileWriter(getProject().getBuildInfo().getClassOutputDir().resolve(getProject().getDekorateMetaDir()), resolve(outputPath).toPath()));
}
}
use of io.dekorate.config.ConfigurationSupplier in project dekorate by dekorateio.
the class SpringBootApplicationGenerator method addConfiguration.
default void addConfiguration(Map map) {
Session session = getSession();
session.getConfigurationRegistry().add(new ConfigurationSupplier(new SpringApplicationConfigBuilder()));
session.getConfigurationRegistry().add(new SetSpringBootRuntime());
session.getConfigurationRegistry().add(new SetSpringBootVersion());
session.getManifestGenerators().add(new ManifestGenerator() {
@Override
public int order() {
return 410;
}
@Override
public String getKey() {
return "spring";
}
@Override
public void generate(Configuration config) {
LOGGER.info("Processing service monitor config.");
session.getResourceRegistry().decorate(new EndpointPathDecorator("http", "/actuator/prometheus"));
}
@Override
public boolean accepts(Class config) {
return SpringApplicationConfig.class.equals(config) || EditableServiceMonitorConfig.class.equals(config);
}
});
if (isActuatorAvailable()) {
// Users configuration should take priority, so add but don't overwrite.
session.getConfigurationRegistry().add(new AddLivenessProbeConfigurator(new ProbeBuilder().withHttpActionPath("/actuator/info").build(), false));
session.getConfigurationRegistry().add(new AddReadinessProbeConfigurator(new ProbeBuilder().withHttpActionPath("/actuator/health").build(), false));
}
if (isSpringCloudKubernetesAvailable()) {
session.getManifestGenerators().add(new ManifestGenerator() {
@Override
public int order() {
// We just want to run right after KubernetesManifestGenerator or OpenshiftManifestGenerator.
return 310;
}
@Override
public String getKey() {
return "spring";
}
@Override
public void generate(Configuration config) {
LOGGER.info("Detected spring cloud kubernetes.");
session.getResourceRegistry().decorate(new ApplyServiceAccountNamedDecorator());
session.getResourceRegistry().decorate(new AddServiceAccountResourceDecorator());
session.getResourceRegistry().decorate(new AddRoleBindingResourceDecorator("view"));
}
@Override
public boolean accepts(Class config) {
return SpringApplicationConfig.class.isAssignableFrom(config);
}
});
}
}
Aggregations