use of io.dekorate.kubernetes.decorator.RemoveAnnotationDecorator in project dekorate by dekorateio.
the class OpenshiftManifestGenerator method addDecorators.
protected void addDecorators(String group, OpenshiftConfig config, ImageConfiguration imageConfig) {
super.addDecorators(group, config);
if (config.getReplicas() != 1) {
resourceRegistry.decorate(group, new ApplyReplicasDecorator(config.getName(), config.getReplicas()));
}
resourceRegistry.decorate(group, new ApplyDeploymentTriggerDecorator(config.getName(), imageConfig.getName() + ":" + imageConfig.getVersion()));
resourceRegistry.decorate(group, new AddRouteDecorator(config));
if (config.hasAttribute(RUNTIME_TYPE)) {
resourceRegistry.decorate(group, new AddLabelDecorator(config.getName(), new Label(OpenshiftLabels.RUNTIME, config.getAttribute(RUNTIME_TYPE), new String[0])));
}
resourceRegistry.decorate(group, new RemoveAnnotationDecorator(config.getName(), Annotations.VCS_URL));
Project project = getProject();
Optional<VcsConfig> vcsConfig = configurationRegistry.get(VcsConfig.class);
String remote = vcsConfig.map(VcsConfig::getRemote).orElse(Git.ORIGIN);
boolean httpsPrefered = vcsConfig.map(VcsConfig::isHttpsPreferred).orElse(false);
String vcsUrl = project.getScmInfo() != null && Strings.isNotNullOrEmpty(project.getScmInfo().getRemote().get(Git.ORIGIN)) ? Git.getRemoteUrl(project.getRoot(), remote, httpsPrefered).orElse(Labels.UNKNOWN) : Labels.UNKNOWN;
resourceRegistry.decorate(group, new AddVcsUrlAnnotationDecorator(config.getName(), OpenshiftAnnotations.VCS_URL, vcsUrl));
resourceRegistry.decorate(group, new AddCommitIdAnnotationDecorator());
}
use of io.dekorate.kubernetes.decorator.RemoveAnnotationDecorator in project quarkus by quarkusio.
the class KubernetesCommonHelper method createAnnotationDecorators.
private static List<DecoratorBuildItem> createAnnotationDecorators(Optional<Project> project, String target, String name, PlatformConfiguration config, Optional<MetricsCapabilityBuildItem> metricsConfiguration, List<KubernetesPortBuildItem> ports) {
List<DecoratorBuildItem> result = new ArrayList<>();
ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
project.ifPresent(p -> {
ScmInfo scm = p.getScmInfo();
String vcsUrl = scm != null ? scm.getRemote().get("origin") : null;
String commitId = scm != null ? scm.getCommit() : null;
// Dekorate uses its own annotations. Let's replace them with the quarkus ones.
result.add(new DecoratorBuildItem(target, new RemoveAnnotationDecorator(Annotations.VCS_URL)));
result.add(new DecoratorBuildItem(target, new RemoveAnnotationDecorator(Annotations.COMMIT_ID)));
// Add quarkus vcs annotations
if (commitId != null) {
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, new Annotation(QUARKUS_ANNOTATIONS_COMMIT_ID, commitId, new String[0]))));
}
if (vcsUrl != null) {
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, new Annotation(QUARKUS_ANNOTATIONS_VCS_URL, vcsUrl, new String[0]))));
}
});
if (config.isAddBuildTimestamp()) {
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, new Annotation(QUARKUS_ANNOTATIONS_BUILD_TIMESTAMP, now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd - HH:mm:ss Z")), new String[0]))));
}
if (config.getExposition().isPresent() && config.getExposition().get().expose) {
Map<String, String> expostionAnnotations = config.getExposition().get().annotations;
String kind = "Ingress";
if (config.getTargetPlatformName().equals(OPENSHIFT)) {
kind = "Route";
}
for (Map.Entry<String, String> annotation : expostionAnnotations.entrySet()) {
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, annotation.getKey(), annotation.getValue(), kind)));
}
}
if (config.getPrometheusConfig().annotations) {
// Add metrics annotations
metricsConfiguration.ifPresent(m -> {
String path = m.metricsEndpoint();
String prefix = config.getPrometheusConfig().prefix;
if (!ports.isEmpty() && path != null) {
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, config.getPrometheusConfig().scrape.orElse(prefix + "/scrape"), "true", PROMETHEUS_ANNOTATION_TARGETS)));
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, config.getPrometheusConfig().path.orElse(prefix + "/path"), path, PROMETHEUS_ANNOTATION_TARGETS)));
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, config.getPrometheusConfig().port.orElse(prefix + "/port"), "" + ports.get(0).getPort(), PROMETHEUS_ANNOTATION_TARGETS)));
result.add(new DecoratorBuildItem(target, new AddAnnotationDecorator(name, config.getPrometheusConfig().scheme.orElse(prefix + "/scheme"), "http", PROMETHEUS_ANNOTATION_TARGETS)));
}
});
}
// Add metrics annotations
return result;
}
Aggregations