Skip to content

Use configuration imports in Dropwizard instead of copy-pasting files for each environment

License

Notifications You must be signed in to change notification settings

vvondra/dropwizard-config-importable

Repository files navigation

dropwizard-config-importable

Build Status

Use configuration imports in Dropwizard instead of copy-pasting files for each environment.

In foodpanda, we've been missing a popular Symfony2 feature which allows to import another file directly from your configuration file.

This can be used to:

  • split a large configuration file into multiple smaller snippets
  • override environment-dependent values

Installation

Maven

<dependencies>
    <dependency>
        <groupId>com.foodpanda</groupId>
        <artifactId>dropwizard-config-importable</artifactId>
        <version>${current.version}</version>
    </dependency>
</dependencies>

Gradle

compile 'com.foodpanda:dropwizard-config-importable:1.0.1'

Setup

Find your HelloApplication.java class and in the initialize method add this line:

bootstrap.setConfigurationFactoryFactory(new ImportableConfigurationFactoryFactory<>());

Example

base.yml:

database:
    driverClass: org.postgresql.Driver
    logValidationErrors: true

dev.yml:

imports:
   - base.yml

database:
   user: postgres

prod.yml:

imports:
   - base.yml

database:
   user: ${PROD_DB_USER}
   logValidationErrors: false

TODO

  • Circular reference detection
  • Support for other than local file resource types

About

Use configuration imports in Dropwizard instead of copy-pasting files for each environment

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages