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

Configuring application using application.yaml should accept directives separator #6297

Closed
x80486 opened this issue Dec 20, 2019 · 4 comments
Labels
area/config kind/enhancement New feature or request
Milestone

Comments

@x80486
Copy link
Contributor

x80486 commented Dec 20, 2019

Description

Support with YAML arrived with version 1.1.0.Final. That's great! Now improving on this, I think it would be great to be able to parse/understand directives separator so we can isolate the profiles in such way, if possible (and applicable).

I understand this separation is already done and we can look at the profiles by their name, but still, I think they are more clear if this is supported...again, if makes sense.

An example file would be like this:

#
# https://quarkus.io/guides/all-config
# https://quarkus.io/guides/config#overriding-properties-at-runtime
---
quarkus:
  datasource:
    driver: org.postgresql.Driver
  flyway:
    migrate-at-start: true
  health:
    extensions:
      enabled: true
  hibernate-orm:
    dialect: org.hibernate.dialect.PostgreSQL10Dialect
  http:
    port: 8080
  log: # ALL > FINEST > FINER > FINE > CONFIG > INFO > WARNING > SEVERE > OFF
    console:
      async: true
      color: true
      enable: true
      format: "%d{yyyy-MM-dd HH:mm:ss,SSS} |- %-5p in %c:%L{3.} [%t] - %s%e%n"
    level: WARNING
  resteasy:
    path: /api
  smallrye-openapi:
    path: /open-api
  swagger-ui:
    always-include: true
    path: /swagger-ui
---
"%dev":
  quarkus:
    datasource:
      password: postgres
      url: jdbc:postgresql://localhost:5432/quarkus_web
      username: postgres
    flyway:
      clean-at-start: true
    hibernate-orm:
      log:
        sql: true
      statistics: true
    log:
      category:
        "io.quarkus.arc.processor":
          level: OFF
        "io.quarkus":
          level: INFO
        "org.acme":
          level: CONFIG
---
"%prod":
  quarkus:
    datasource:
      password: postgres
      url: jdbc:postgresql://localhost:5432/quarkus_web
      username: postgres
    flyway:
      clean-at-start: false
    hibernate-orm:
      database:
        generation: none
      sql-load-script: no-file
---
"%test":
  quarkus:
    datasource:
      password: postgres
      url: jdbc:postgresql://localhost:5432/quarkus_web
      username: postgres
    flyway:
      clean-at-start: true
    log:
      category:
        "io.quarkus":
          level: WARNING
        "org.acme":
          level: WARNING

If used in such way, this error pops up:

14:47:30,257 ERROR [io.qua.dev.DevModeMain] Failed to start Quarkus: expected a single document in the stream
 in 'reader', line 5, column 1:
    quarkus:
    ^
but found another document
 in 'reader', line 31, column 1:
    ---
    ^

	at org.yaml.snakeyaml.composer.Composer.getSingleNode(Composer.java:114)
	at org.yaml.snakeyaml.constructor.BaseConstructor.getSingleData(BaseConstructor.java:141)
	at org.yaml.snakeyaml.Yaml.loadFromReader(Yaml.java:525)
	at org.yaml.snakeyaml.Yaml.loadAs(Yaml.java:519)
	at io.smallrye.config.source.yaml.YamlConfigSource.streamToMap(YamlConfigSource.java:48)
	at io.smallrye.config.source.yaml.YamlConfigSource.<init>(YamlConfigSource.java:33)
	at io.quarkus.config.yaml.runtime.ApplicationYamlProvider.getConfigSources(ApplicationYamlProvider.java:36)
	at io.smallrye.config.SmallRyeConfigBuilder.lambda$discoverSources$0(SmallRyeConfigBuilder.java:78)
	at java.lang.Iterable.forEach(Iterable.java:75)
	at io.smallrye.config.SmallRyeConfigBuilder.discoverSources(SmallRyeConfigBuilder.java:78)
	at io.smallrye.config.SmallRyeConfigBuilder.build(SmallRyeConfigBuilder.java:169)
	at io.quarkus.deployment.ExtensionLoader.loadStepsFrom(ExtensionLoader.java:190)
	at io.quarkus.deployment.ExtensionLoader.loadStepsFrom(ExtensionLoader.java:133)
	at io.quarkus.deployment.QuarkusAugmentor.run(QuarkusAugmentor.java:88)
	at io.quarkus.runner.RuntimeRunner.run(RuntimeRunner.java:113)
	at io.quarkus.dev.DevModeMain.doStart(DevModeMain.java:177)
	at io.quarkus.dev.DevModeMain.start(DevModeMain.java:95)
	at io.quarkus.dev.DevModeMain.main(DevModeMain.java:66)

Another thing could be to move the profile name into its own key within the quarkus "namespace".

@x80486 x80486 added the kind/enhancement New feature or request label Dec 20, 2019
@dmlloyd
Copy link
Member

dmlloyd commented Dec 21, 2019

I'm pretty sure this is doable just by reading all the docs in sequence. It's not exactly the same as separating by profile but it could be used for that.

@famod
Copy link
Member

famod commented Mar 17, 2020

This is possible in Spring Boot btw and would come in handy for Quarkus as well:
https://docs.spring.io/spring-boot/docs/current/reference/html/spring-boot-features.html#boot-features-external-config-multi-profile-yaml

@radcortez
Copy link
Member

In smallrye/smallrye-config#335.

@radcortez
Copy link
Member

The update to SmallRye Config 1.8.4 in #10615 should fix this.

@gsmet gsmet added this to the 1.6.1.Final milestone Jul 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/config kind/enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants