Skip to content
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

Document devtool property file profile restrictions #19972

Closed
ddcruver opened this issue Jan 28, 2020 · 7 comments
Closed

Document devtool property file profile restrictions #19972

ddcruver opened this issue Jan 28, 2020 · 7 comments
Labels
type: documentation A documentation update
Milestone

Comments

@ddcruver
Copy link

While loading of YAML files in home directory was fixed in #19081 it appears it is ignoring the profiles defined by the spring.profiles property and loading in all YAML documents (the sections in a YAML file) as property sources.

When running the example application with the example spring-boot-devtools.yaml with no profiles activate I would expect only one YAML document to be loaded, the top one which should be "default" property scope.

Example Project:
devtools-profile-loading.zip
I have added log statements to enumerate the loading property sources and just by starting up the example project you can see that all documents in spring-boot-devtools.yaml are loaded.

./mvn spring-boot-run

Example ~/.config/spring-boot/spring-boot-devtools.yaml:
spring-boot-devtools.yaml.txt

default.profile.property: "Default Profile Property"

---

spring:
  profiles: p1

p1.profile.property: "from p1"

---

spring:
  profiles: p2

p2.profile.property: "from p2"

---

spring:
  profiles: p3

p2.profile.property: "from p3"
---

spring:
  profiles: p1 & p2

p1-p2.profile.property: "from p1 & p2"

---

spring:
  profiles: p2 & p3

p2-p3.profile.property: "from p2 & p3"

---

spring:
  profiles: p1 & p3

p1-p3.profile.property: "from p1 & p3"

---

spring:
  profiles:
    - p1
    - p2
    - p3

p1-or-p2-or-p3.profile.property: "from p1 | p2 | p3"
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 28, 2020
@mbhave
Copy link
Contributor

mbhave commented Jan 28, 2020

You're right @ddcruver. I don't think the DevtoolsEnvironmentPostProcessor takes active profiles into account when loading the spring-boot-devtools.yaml. I don't think we should support this since there's no equivalent way to this with spring-boot-devtools.properties unless we added support for -{profile}.properties. Spring Boot originally supported only the .properties format for DevTools and .yml was added as a convenience. Let's see what the rest of the team thinks.

@mbhave mbhave added the for: team-attention An issue we'd like other members of the team to review label Jan 28, 2020
@ddcruver
Copy link
Author

The fact that spring-boot-devtools.properties does not support multiple profiles is why I wanted to use the spring-boot-devtools.yaml variation.

I would argue the fact that DevTool YAML files work differently than YAML configuration files in other places causes more inconsistency.

Also spring-boot-devtools.properties have their own configuration directory ~/.config/spring-boot/ now support for multiple files can be done without adding to a users home directory files.

Some people prefer one or the other format so seeing continued support for both would be good and since these files are local to a developer they have more freedom to use whichever they want in their development environment.

@wilkinsona
Copy link
Member

wilkinsona commented Jan 29, 2020

I agree with Madhura that we should not support this.

The documentation already contains a note about profiles:

Profiles activated in the above files will not affect the loading of profile-specific configuration files.

We should expand upon this to note that profile-specific configuration is not supported in general. That feels consistent to me as this isn’t an application.(properties|yaml) file.

Also spring-boot-devtools.properties have their own configuration directory ~/.config/spring-boot/ now support for multiple files can be done without adding to a users home directory files.

We’ve discussed this before: #16042 (comment). We prefer to align with that standard and use a consistent location across platforms.

@ddcruver
Copy link
Author

ddcruver commented Jan 29, 2020

@wilkinsona I think there is a little miss understanding here.

We’ve discussed this before: #16042 (comment). We prefer to align with that standard and use a consistent location across platforms.

I do agree with it being in ~/.config/spring-boot/ it is cross-platform friendly the reason why I mentioned it was because of the potential of adding -{profile}.properties support to the DevTools home.

The documentation already contains a note about profiles:

Profiles activated in the above files will not affect the loading of profile-specific configuration files.

I am not asking for devtools configuration files to activate any profiles, just that profiles contained in them should be filtered like any other YAML file. I understand that activating profiles would cause confusion and adds lots of complexity to the code. I have been debugging the property loading lately and understand a lot is going on.

Right now you can add an arbitrary YAML file on your spring.config.location and it will support filtering of inactive profile YAML documents. To be clear I am only talking about Multi-profile YAML Documents. Not anything like spring-devtools-{profile}.yaml, ex.). spring-devtools-production.yaml

Also I am not imply that -{profile}.properties be supported in any file that is configured, just the "main" configuration file and the devtool one. But back on that note, if we drop the whole notion of adding support for -{profile}.properties in devtools I wouldn't be effected by that.

I just saw it as a value add for those that don't like YAML and partly because mbhave said this:

I don't think we should support this since there's no equivalent way to this with spring-boot-devtools.properties unless we added support for -{profile}.properties

@ddcruver
Copy link
Author

We have been focusing on what it was doing and what it should be doing but I haven't even expressed my use case:

I would like to have DevTools contain multiple configuration for different environments and allow me to pass the profiles to my Microservices in order to activate one or more but not all of the profiles in my ~/.config/spring-boot/spring-boot-devtools.yaml configuration.

This could be emulated by commenting out lines or swapping in different spring-boot-devtools.yaml files but this would cause friction in my workflow.

@wilkinsona
Copy link
Member

The ~/.config/spring-boot/spring-boot-devtools.(properties|yaml) file is primarily intended for configuring global DevTools settings. You've gone quite a bit beyond that into an area that we do not want to support. If you want profile-specific configuration, you should use application.(properties|yaml) files as that's where profile-specific configuration is provided. You can add additional locations use spring.config.additional-location.

We'll expand the existing note in the documentation to clarify when profile-specific configuration is and is not available.

@wilkinsona wilkinsona added type: documentation A documentation update and removed for: team-attention An issue we'd like other members of the team to review status: waiting-for-triage An issue we've not yet triaged labels Jan 30, 2020
@wilkinsona wilkinsona changed the title Spring Boot DevTools YAML loading ignores profiles Upgrade documentation on DevTools' global settings to make it clear that profile-specific configuration is not supported Jan 30, 2020
@wilkinsona wilkinsona added this to the 2.1.x milestone Jan 30, 2020
@wilkinsona wilkinsona changed the title Upgrade documentation on DevTools' global settings to make it clear that profile-specific configuration is not supported Update documentation on DevTools' global settings to make it clear that profile-specific configuration is not supported Jan 30, 2020
@ddcruver
Copy link
Author

ddcruver commented Jan 30, 2020

I think it would be a good idea to log a warning if any spring.profiles are found in DevTools YAML files.

@philwebb philwebb changed the title Update documentation on DevTools' global settings to make it clear that profile-specific configuration is not supported Document devtool property file profile restructions Apr 20, 2020
@philwebb philwebb changed the title Document devtool property file profile restructions Document devtool property file profile restrictions Apr 20, 2020
@philwebb philwebb modified the milestones: 2.1.x, 2.1.14 Apr 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

5 participants