-
Notifications
You must be signed in to change notification settings - Fork 305
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development
: POC for improving Spring configuration via properties/profiles
#10336
base: develop
Are you sure you want to change the base?
Conversation
…to determine existence of buildagent
…tions to determine existence of athena
…guration instead of a "raw" condition
…nto (logical) groups
@@ -0,0 +1,10 @@ | |||
artemis: | |||
athena: | |||
enabled: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this files is placed next to the packaged JAR and overrides the default config from application.yml-files within the packaged JAR
version-control: | ||
url: https://gitlab.artemis.cit.tum.de # assuming we are using GitLab and have a different URL (than localVC as default) | ||
|
||
info: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
room for user-configs, explained in documentation
new ConfigValidationPostProcessor().attachTo(app); | ||
new PropertyOverridePostProcessor().attachTo(app); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
registers listener after environment has been created, but before context initialization (beans etc.)
@@ -16,7 +14,7 @@ | |||
import org.springframework.stereotype.Component; | |||
|
|||
@Component | |||
@Profile(PROFILE_ATHENA) | |||
@ConditionalOnBean(AthenaConfiguration.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of relying on the profile, we rely on the existence of the AthenaConfiguration
(which checks the environment)
/** | ||
* This class is necessary to avoid using Jersey (which has an issue deserializing Eureka responses) after the spring boot upgrade. | ||
* It provides the RestClientTransportClientFactories and RestClientDiscoveryClientOptionalArgs that would normally not be instantiated | ||
* when Jersey is found by Eureka. | ||
*/ | ||
@Profile({ PROFILE_CORE, PROFILE_BUILDAGENT }) | ||
@Conditional(BuildAgentOrCoreCondition.class) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting case: If we want to define more complex conditions based on profile AND/OR properties, we can do that with nested properties like BuildAgentOrCoreCondition
* This bridges the gap between the condition classes and the actual property values. | ||
* WIP: make methods non-static | ||
*/ | ||
public class ArtemisConfigHelper { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to discuss whether we directly use this class in the respective Condition
s or if we want to create a new layer of abstraction for when using from within the initialized spring context. (like ArtemisConfigServer
with @service)
A reason could be to decouple application-logic from reading the properties and profiles. So we could also mock it and in general, have a clearer separation of concerns
@@ -117,7 +118,9 @@ artemis: | |||
short-name: "artemis-build-agent-1" | |||
display-name: "Artemis Build Agent 1" | |||
|
|||
|
|||
version-control: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When removing the buildagent profile/yaml, we need to set those as defaults here
@@ -87,6 +87,7 @@ artemis: | |||
name: Artemis | |||
email: artemis@xcit.tum.de | |||
athena: | |||
enabled: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default is that athena is enabled, opt-out instead of opt-in
…wiring instead of AthenaConfiguration
This PR acts as a POC outlining approaches on how to improve the Spring configuration.
Identified Problems:
Proposed Solutions:
See here for more details. If you don't have access, feel free to reach out to me.