Skip to content
Permalink
Browse files

fix: properties now always override annotations.

  • Loading branch information...
iocanel committed Aug 28, 2019
1 parent ec8eef1 commit de41d5608daf2abc7edd3cd42d83f8a6efbe785d
Showing with 814 additions and 41 deletions.
  1. +2 −1 ...ion-annotations/src/main/java/io/dekorate/application/generator/ApplicationResourceGenerator.java
  2. +5 −3 annotations/crd-annotations/src/main/java/io/dekorate/crd/generator/CustomResourceGenerator.java
  3. +5 −3 ...ns/halkyon-annotations/src/main/java/io/dekorate/halkyon/generator/CapabilityConfigGenerator.java
  4. +5 −3 ...ons/halkyon-annotations/src/main/java/io/dekorate/halkyon/generator/ComponentConfigGenerator.java
  5. +5 −3 annotations/halkyon-annotations/src/main/java/io/dekorate/halkyon/generator/LinkConfigGenerator.java
  6. +5 −3 annotations/jaeger-annotations/src/main/java/io/dekorate/jaeger/generator/JaegerAgentGenerator.java
  7. +5 −0 ...ubernetes-annotations/src/main/java/io/dekorate/kubernetes/apt/KubernetesAnnotationProcessor.java
  8. +4 −2 ...es-annotations/src/main/java/io/dekorate/kubernetes/generator/KubernetesApplicationGenerator.java
  9. +4 −2 ...hift-annotations/src/main/java/io/dekorate/openshift/generator/OpenshiftApplicationGenerator.java
  10. +4 −2 annotations/option-annotations/src/main/java/io/dekorate/option/generator/JvmOptionsGenerator.java
  11. +5 −3 ...rometheus-annotations/src/main/java/io/dekorate/prometheus/generator/ServiceMonitorGenerator.java
  12. +5 −3 ...talog-annotations/src/main/java/io/dekorate/servicecatalog/generator/ServiceCatalogGenerator.java
  13. +2 −2 core/src/main/java/io/dekorate/AbstractKubernetesHandler.java
  14. +32 −5 core/src/main/java/io/dekorate/Configurators.java
  15. +40 −0 core/src/main/java/io/dekorate/config/AnnotationConfiguration.java
  16. +6 −2 core/src/main/java/io/dekorate/config/ConfigurationSupplier.java
  17. +38 −0 core/src/main/java/io/dekorate/config/PropertyConfiguration.java
  18. +9 −1 core/src/main/java/io/dekorate/kubernetes/decorator/AddServiceDecorator.java
  19. +276 −0 core/src/main/java/io/dekorate/utils/Beans.java
  20. +173 −0 core/src/test/java/io/dekorate/utils/BeansTest.java
  21. +71 −0 frameworks/spring-boot/src/it/issue-331-annotation-combined-with-properties/pom.xml
  22. +35 −0 ...annotation-combined-with-properties/src/main/java/io/dekorate/annotationless/DemoApplication.java
  23. +8 −0 ...ot/src/it/issue-331-annotation-combined-with-properties/src/main/resources/application.properties
  24. +55 −0 ...31-annotation-combined-with-properties/src/test/java/io/dekorate/annotationless/Issue331Test.java
  25. +10 −0 frameworks/spring-boot/src/main/java/io/dekorate/spring/apt/SpringBootApplicationProcessor.java
  26. +5 −3 incubator/istio-annotations/src/main/java/io/dekorate/istio/generator/IstioConfigGenerator.java
@@ -23,6 +23,7 @@
import io.dekorate.application.config.ApplicationConfigBuilder;
import io.dekorate.application.handler.ApplicationHandler;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;

import javax.lang.model.element.Element;
import java.util.Map;
@@ -37,7 +38,7 @@ default void add(Map map) {
default void add(Element element) {
EnableApplicationResource info = element.getAnnotation(EnableApplicationResource.class);
ApplicationConfigBuilder builder = ApplicationConfigAdapter.newBuilder(info);
add(new ConfigurationSupplier<>(builder));
add(new AnnotationConfiguration<>(builder));
}

default void add(ConfigurationSupplier<?> config) {
@@ -19,6 +19,8 @@
import io.dekorate.Session;
import io.dekorate.WithSession;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.crd.adapter.CustomResourceConfigAdapter;
import io.dekorate.crd.annotation.CustomResource;
import io.dekorate.crd.confg.Keys;
@@ -38,7 +40,7 @@

@Override
default void add(Map map) {
on(new ConfigurationSupplier<>(CustomResourceConfigAdapter.newBuilder(propertiesMap(map, CustomResource.class))));
on(new PropertyConfiguration<>(CustomResourceConfigAdapter.newBuilder(propertiesMap(map, CustomResource.class))));
}

@Override
@@ -49,8 +51,8 @@ default void add(Element element) {
String className = ModelUtils.getClassName(element);

on(customResource != null
? new ConfigurationSupplier<CustomResourceConfig>(CustomResourceConfigAdapter.newBuilder(customResource).addToAttributes(Keys.TYPE_DEFINITION, definition).accept(new AddClassNameConfigurator(className)))
: new ConfigurationSupplier<CustomResourceConfig>(new CustomResourceConfigBuilder().addToAttributes(Keys.TYPE_DEFINITION, definition).accept(new AddClassNameConfigurator(className))));
? new AnnotationConfiguration<CustomResourceConfig>(CustomResourceConfigAdapter.newBuilder(customResource).addToAttributes(Keys.TYPE_DEFINITION, definition).accept(new AddClassNameConfigurator(className)))
: new AnnotationConfiguration<CustomResourceConfig>(new CustomResourceConfigBuilder().addToAttributes(Keys.TYPE_DEFINITION, definition).accept(new AddClassNameConfigurator(className))));
}
}

@@ -24,6 +24,8 @@
import io.dekorate.Session;
import io.dekorate.WithProject;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.halkyon.adapter.CapabilityConfigAdapter;
import io.dekorate.halkyon.annotation.HalkyonCapability;
import io.dekorate.halkyon.config.CapabilityConfig;
@@ -35,7 +37,7 @@

@Override
default void add(Map map) {
add(new ConfigurationSupplier<>(
add(new PropertyConfiguration<>(
CapabilityConfigAdapter
.newBuilder(propertiesMap(map, HalkyonCapability.class))));
}
@@ -44,8 +46,8 @@ default void add(Map map) {
default void add(Element element) {
HalkyonCapability capability = element.getAnnotation(HalkyonCapability.class);
add(capability != null
? new ConfigurationSupplier<>(CapabilityConfigAdapter.newBuilder(capability))
: new ConfigurationSupplier<>(CapabilityConfig.newCapabilityConfigBuilder()));
? new AnnotationConfiguration<>(CapabilityConfigAdapter.newBuilder(capability))
: new AnnotationConfiguration<>(CapabilityConfig.newCapabilityConfigBuilder()));
}

default void add(ConfigurationSupplier<CapabilityConfig> config) {
@@ -23,6 +23,8 @@
import io.dekorate.Session;
import io.dekorate.WithProject;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.halkyon.adapter.ComponentConfigAdapter;
import io.dekorate.halkyon.annotation.HalkyonComponent;
import io.dekorate.halkyon.config.ComponentConfig;
@@ -35,7 +37,7 @@

@Override
default void add(Map map) {
add(new ConfigurationSupplier<>(
add(new PropertyConfiguration<>(
ComponentConfigAdapter
.newBuilder(propertiesMap(map, HalkyonComponent.class))
.accept(new ApplyProject(getProject()))));
@@ -45,8 +47,8 @@ default void add(Map map) {
default void add(Element element) {
HalkyonComponent component = element.getAnnotation(HalkyonComponent.class);
add(component != null
? new ConfigurationSupplier<>(ComponentConfigAdapter.newBuilder(component).accept(new ApplyProject(getProject())))
: new ConfigurationSupplier<>(ComponentConfig.newComponentConfigBuilder().accept(new ApplyProject(getProject()))));
? new AnnotationConfiguration<>(ComponentConfigAdapter.newBuilder(component).accept(new ApplyProject(getProject())))
: new AnnotationConfiguration<>(ComponentConfig.newComponentConfigBuilder().accept(new ApplyProject(getProject()))));
}

default void add(ConfigurationSupplier<ComponentConfig> config) {
@@ -23,6 +23,8 @@
import io.dekorate.Session;
import io.dekorate.WithProject;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.halkyon.adapter.LinkConfigAdapter;
import io.dekorate.halkyon.annotation.HalkyonLink;
import io.dekorate.halkyon.config.LinkConfig;
@@ -33,15 +35,15 @@

@Override
default void add(Map map) {
add(new ConfigurationSupplier<>(LinkConfigAdapter.newBuilder(propertiesMap(map, HalkyonLink.class))));
add(new PropertyConfiguration<>(LinkConfigAdapter.newBuilder(propertiesMap(map, HalkyonLink.class))));
}

@Override
default void add(Element element) {
HalkyonLink link = element.getAnnotation(HalkyonLink.class);
add(link != null
? new ConfigurationSupplier<>(LinkConfigAdapter.newBuilder(link))
: new ConfigurationSupplier<>(LinkConfig.newLinkConfigBuilder()));
? new AnnotationConfiguration<>(LinkConfigAdapter.newBuilder(link))
: new AnnotationConfiguration<>(LinkConfig.newLinkConfigBuilder()));
}

default void add(ConfigurationSupplier<LinkConfig> config) {
@@ -19,6 +19,8 @@
import io.dekorate.Session;
import io.dekorate.WithSession;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.jaeger.adapter.JaegerAgentConfigAdapter;
import io.dekorate.jaeger.annotation.EnableJaegerAgent;
import io.dekorate.jaeger.config.AddDefaultPortsToAgentConfigurator;
@@ -33,15 +35,15 @@

@Override
default void add(Map map) {
on(new ConfigurationSupplier<>(JaegerAgentConfigAdapter.newBuilder(propertiesMap(map, EnableJaegerAgent.class))));
on(new PropertyConfiguration<>(JaegerAgentConfigAdapter.newBuilder(propertiesMap(map, EnableJaegerAgent.class))));
}

@Override
default void add(Element element) {
EnableJaegerAgent serviceMonitor = element.getAnnotation(EnableJaegerAgent.class);
on(serviceMonitor != null
? new ConfigurationSupplier<>(JaegerAgentConfigAdapter.newBuilder(serviceMonitor))
: new ConfigurationSupplier<>(new JaegerAgentConfigBuilder()));
? new AnnotationConfiguration<>(JaegerAgentConfigAdapter.newBuilder(serviceMonitor))
: new AnnotationConfiguration<>(new JaegerAgentConfigBuilder()));
}

default void on(ConfigurationSupplier<JaegerAgentConfig> config) {
@@ -17,6 +17,8 @@

import io.dekorate.kubernetes.generator.KubernetesApplicationGenerator;
import io.dekorate.processor.AbstractAnnotationProcessor;
import io.dekorate.Logger;
import io.dekorate.LoggerFactory;
import io.dekorate.doc.Description;

import javax.annotation.processing.SupportedSourceVersion;
@@ -33,13 +35,16 @@
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class KubernetesAnnotationProcessor extends AbstractAnnotationProcessor implements KubernetesApplicationGenerator {

private final Logger LOGGER = LoggerFactory.getLogger();

public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
getSession().close();
return true;
}
for (TypeElement typeElement : annotations) {
for (Element mainClass : roundEnv.getElementsAnnotatedWith(typeElement)) {
LOGGER.info("Found @KubernetesApplication on: " + mainClass.toString());
add(mainClass);
}
}
@@ -28,6 +28,8 @@
import io.dekorate.SessionListener;
import io.dekorate.WithProject;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.deps.kubernetes.api.model.KubernetesList;
import io.dekorate.deps.kubernetes.client.DefaultKubernetesClient;
import io.dekorate.deps.kubernetes.client.KubernetesClient;
@@ -50,7 +52,7 @@

@Override
default void add(Map map) {
add(new ConfigurationSupplier<>(
add(new PropertyConfiguration<>(
KubernetesConfigAdapter
.newBuilder(propertiesMap(map, KubernetesApplication.class))
.accept(new ApplyAutoBuild())
@@ -60,7 +62,7 @@ default void add(Map map) {

default void add(Element element) {
KubernetesApplication application = element.getAnnotation(KubernetesApplication.class);
add(new ConfigurationSupplier<>(
add(new AnnotationConfiguration<>(
KubernetesConfigAdapter
.newBuilder(application)
.accept(new ApplyAutoBuild())
@@ -21,6 +21,8 @@
import io.dekorate.Session;
import io.dekorate.SessionListener;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.openshift.adapter.OpenshiftConfigAdapter;
import io.dekorate.openshift.annotation.OpenshiftApplication;
import io.dekorate.openshift.config.OpenshiftConfig;
@@ -50,14 +52,14 @@ default void add(Element element) {
OpenshiftApplication openshiftApplication = element.getAnnotation(OpenshiftApplication.class);
OpenshiftConfig openshiftConfig = OpenshiftConfigCustomAdapter.newBuilder(getProject(), openshiftApplication).build();

on(new ConfigurationSupplier<>(OpenshiftConfigAdapter.newBuilder(element.getAnnotation(OpenshiftApplication.class))
on(new AnnotationConfiguration<>(OpenshiftConfigAdapter.newBuilder(element.getAnnotation(OpenshiftApplication.class))
.accept(new ApplyProjectInfo(getProject()))
.accept(new ApplySourceToImageHook(openshiftConfig))));
}

default void add(Map map) {
OpenshiftConfig openshiftConfig = OpenshiftConfigAdapter.newBuilder((Map) map.get(OpenshiftApplication.class.getName())).build();
on(new ConfigurationSupplier<>(OpenshiftConfigAdapter.newBuilder(propertiesMap(map, OpenshiftApplication.class))
on(new PropertyConfiguration<>(OpenshiftConfigAdapter.newBuilder(propertiesMap(map, OpenshiftApplication.class))
.accept(new ApplyProjectInfo(getProject()))
.accept(new ApplySourceToImageHook(openshiftConfig))));
}
@@ -18,6 +18,8 @@
import io.dekorate.Generator;
import io.dekorate.Session;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.option.adapter.JvmConfigAdapter;
import io.dekorate.option.annotation.JvmOptions;
import io.dekorate.option.config.JvmConfig;
@@ -32,14 +34,14 @@
default void add(Element element) {
JvmOptions jvmOptions = element.getAnnotation(JvmOptions.class);
if (jvmOptions != null) {
ConfigurationSupplier<JvmConfig> config = new ConfigurationSupplier<>(JvmConfigAdapter.newBuilder(jvmOptions));
AnnotationConfiguration<JvmConfig> config = new AnnotationConfiguration<>(JvmConfigAdapter.newBuilder(jvmOptions));
on(config);
}
}

@Override
default void add(Map map) {
on(new ConfigurationSupplier<>(
on(new PropertyConfiguration<>(
JvmConfigAdapter
.newBuilder(propertiesMap(map, JvmOptions.class))
));
@@ -19,6 +19,8 @@
import io.dekorate.Session;
import io.dekorate.WithSession;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.prometheus.adapter.ServiceMonitorConfigAdapter;
import io.dekorate.prometheus.annotation.EnableServiceMonitor;
import io.dekorate.prometheus.config.ServiceMonitorConfig;
@@ -32,15 +34,15 @@

@Override
default void add(Map map) {
on(new ConfigurationSupplier<>(ServiceMonitorConfigAdapter.newBuilder(propertiesMap(map, EnableServiceMonitor.class))));
on(new PropertyConfiguration<>(ServiceMonitorConfigAdapter.newBuilder(propertiesMap(map, EnableServiceMonitor.class))));
}

@Override
default void add(Element element) {
EnableServiceMonitor serviceMonitor = element.getAnnotation(EnableServiceMonitor.class);
on(serviceMonitor != null
? new ConfigurationSupplier<>(ServiceMonitorConfigAdapter.newBuilder(serviceMonitor))
: new ConfigurationSupplier<>(new ServiceMonitorConfigBuilder()));
? new AnnotationConfiguration<>(ServiceMonitorConfigAdapter.newBuilder(serviceMonitor))
: new AnnotationConfiguration<>(new ServiceMonitorConfigBuilder()));
}

default void on(ConfigurationSupplier<ServiceMonitorConfig> config) {
@@ -19,6 +19,8 @@
import io.dekorate.Generator;
import io.dekorate.Session;
import io.dekorate.config.ConfigurationSupplier;
import io.dekorate.config.AnnotationConfiguration;
import io.dekorate.config.PropertyConfiguration;
import io.dekorate.servicecatalog.adapter.ServiceCatalogConfigAdapter;
import io.dekorate.servicecatalog.annotation.ServiceCatalog;
import io.dekorate.servicecatalog.config.ServiceCatalogConfig;
@@ -32,15 +34,15 @@

@Override
default void add(Map map) {
on(new ConfigurationSupplier<>(ServiceCatalogConfigAdapter.newBuilder(propertiesMap(map, ServiceCatalog.class))));
on(new PropertyConfiguration<>(ServiceCatalogConfigAdapter.newBuilder(propertiesMap(map, ServiceCatalog.class))));
}

@Override
default void add(Element element) {
ServiceCatalog serviceCatalog = element.getAnnotation(ServiceCatalog.class);
on(serviceCatalog != null
? new ConfigurationSupplier<>(ServiceCatalogConfigAdapter.newBuilder(serviceCatalog))
: new ConfigurationSupplier<>(new ServiceCatalogConfigBuilder()));
? new AnnotationConfiguration<>(ServiceCatalogConfigAdapter.newBuilder(serviceCatalog))
: new AnnotationConfiguration<>(new ServiceCatalogConfigBuilder()));
}

default void on(ConfigurationSupplier<ServiceCatalogConfig> config) {
@@ -91,8 +91,8 @@ protected void setApplicationInfo(C config) {
* @param config The config.
*/
protected void addDecorators(String group, C config) {
if (!Strings.isNotNullOrEmpty(config.getServiceAccount())) {
resources.decorate(new ApplyServiceAccountDecorator(config.getName(), config.getServiceAccount()));
if (Strings.isNotNullOrEmpty(config.getServiceAccount())) {
resources.decorate(new ApplyServiceAccountDecorator(config.getName(), config.getServiceAccount()));
}
resources.decorate(group, new ApplyImagePullPolicyDecorator(config.getImagePullPolicy()));

0 comments on commit de41d56

Please sign in to comment.
You can’t perform that action at this time.