Nano-library which provides the ability to define typesafe (!) configuration templates for applications.

Overview

Configur8 Build Status Coverage Status Download Watch

Nano-library which provides the ability to define typesafe (!) Configuration templates for applications.

Concept:

A Configuration is a set of named and typed Property instances, which are defined using a ConfigurationTemplate. Each defined Property can be set with a default value, or be blank with a requirement to be overridden. At runtime, the template is reified into a concrete Configuration object, but if any properties are missing this process will throw a Misconfiguration error.

Assuming that the reification process is successful, property values can be retrieved in an (actually) type-safe manner, and are applied in the following descending order of precedence:

  1. JVM system property
  2. Named environment property
  3. Default value

Quick example

This is from the Kotlin version, but the Scala and Java APIs are broadly the same:

// simple typed values
val USER = Property.string("USER")
val AGE = Property.int("AGE")

// provide custom mapping functions to convert from strings to domain
val PATIENCE_LEVEL = Property("DURATION", { i: String -> Duration.parse(i) }, { it.describe() })

// build your template
val configTemplate = ConfigurationTemplate()
      .requiring(USER) // will be supplied by the environment
      .withProp(AGE, 2) // falls back to a default typed value
      .withProp(PATIENCE_LEVEL, Duration(10)) // custom typed property with default

// attempting to build a configuration with missing values will fail with a Misconfiguration exception
val config = configTemplate.reify()

// retrieval of values in a typesafe way
val patience: Duration = config.valueOf[PATIENCE_LEVEL]

Get it:

Currently, the library is published in Java, Kotlin and Scala versions in JCenter (and synced to Maven Central).

Maven:

Java:

<dependency>
  <groupId>io.github.daviddenton</groupId>
  <artifactId>configur8</artifactId>
  <version>1.7.0</version>
</dependency>

Kotlin:

<dependency>
  <groupId>io.github.daviddenton</groupId>
  <artifactId>konfigur8</artifactId>
  <version>1.7.0</version>
</dependency>

SBT:

libraryDependencies += "io.github.daviddenton" %% "configur8" % "1.7.0"

See it:

See the example code in scala or java or kotlin

Comments
  • Allow configuration from map instead of env

    Allow configuration from map instead of env

    This allows for better testability of http4k serverless applications that use the AppLoader. Adds a new method reifyFrom that reifies the configuration template from a map instead of getting the values from env/sysprops.

    object AWSLambda : AppLoader {
        override fun invoke(env: Map<String, String>): HttpHandler {
            val config = ConfigurationTemplate().reifyFrom(env)
            
            return routes("/api" bind API(config))
        }
    }
    opened by joscha-alisch 0
  • Making configuration template immutable.

    Making configuration template immutable.

    Sorry I've only done this for the java version - am happy to have a crack at the kotlin & scala versions. The test isn't as clean as it maybe could be.

    opened by stuartervine 0
  • Bump handlebars from 4.1.0 to 4.7.6 in /javascript

    Bump handlebars from 4.1.0 to 4.7.6 in /javascript

    Bumps handlebars from 4.1.0 to 4.7.6.

    Changelog

    Sourced from handlebars's changelog.

    v4.7.6 - April 3rd, 2020

    Chore/Housekeeping:

    Compatibility notes:

    • Restored Node.js compatibility

    Commits

    v4.7.5 - April 2nd, 2020

    Chore/Housekeeping:

    • Node.js version support has been changed to v6+ Reverted in 4.7.6

    Compatibility notes:

    • Node.js < v6 is no longer supported Reverted in 4.7.6

    Commits

    v4.7.4 - April 1st, 2020

    Chore/Housekeeping:

    Compatibility notes:

    • No incompatibilities are to be expected

    Commits

    v4.7.3 - February 5th, 2020

    Chore/Housekeeping:

    • #1644 - Download links to aws broken on handlebarsjs.com - access denied (@Tea56)
    • Fix spelling and punctuation in changelog - d78cc73

    Bugfixes:

    • Add Type Definition for Handlebars.VERSION, Fixes #1647 - 4de51fe
    • Include Type Definition for runtime.js in Package - a32d05f

    Compatibility notes:

    Commits
    Maintainer changes

    This version was pushed to npm by erisds, a new releaser for handlebars since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump acorn from 5.7.3 to 5.7.4 in /javascript

    Bump acorn from 5.7.3 to 5.7.4 in /javascript

    Bumps acorn from 5.7.3 to 5.7.4.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump lodash from 4.17.11 to 4.17.20 in /javascript

    Bump lodash from 4.17.11 to 4.17.20 in /javascript

    Bumps lodash from 4.17.11 to 4.17.20.

    Commits
    Maintainer changes

    This version was pushed to npm by bnjmnt4n, a new releaser for lodash since your current version.


    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • The Property class is the key of the Map in Configuration class but it doesn't override hashcode and equals methods.

    The Property class is the key of the Map in Configuration class but it doesn't override hashcode and equals methods.

    It is not possible to retrieve a property's value from the Configuration object if the reference to the original property object used in ConfigurationTemplate is lost.

    eg: fun main(args: Array) { val config = ConfigurationTemplate().withProp(Property.string("MY_PROP"),"myprop").reify() val propValue = config.get(Property.string("MY_PROP")) println(propValue) }

    gives Exception in thread "main" io.github.konfigur8.Misconfiguration: Unknown configuration key 'MY_PROP' Instead, it should provide the value from environment or the default "myprop"

    opened by gitika-bansal 0
  • What's the behavior for hyphenated properties?

    What's the behavior for hyphenated properties?

    What does a property foo-bar translate to in the code? Typesafe config encourages hyphenated properties over camelcase, but I couldn't find the answer to this question.

    opened by asarkar 0
Owner
David Denton
Polyglot // Open Source // Trainer // Speaker // Kotlin GDE // Co-creator of http4k
David Denton
Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main class. Supporting pure Microservice or Micro-monolith styles.

Microserver A convenient modular engine for Microservices. Microserver plugins offer seamless integration with Spring (core), Jersey, Guava, Tomcat, G

AOL 936 Dec 19, 2022
JHipster is a development platform to quickly generate, develop, & deploy modern web applications & microservice architectures.

Greetings, Java Hipster! Full documentation and information is available on our website at https://www.jhipster.tech/ Please read our guidelines befor

JHipster 20.2k Jan 5, 2023
Examples and server integrations for generating the Swagger API Specification, which enables easy access to your REST API

Swagger Core NOTE: If you're looking for Swagger Core 1.5.X and OpenAPI 2.0, please refer to 1.5 branch. NOTE: Since version 2.1.7 Swagger Core suppor

Swagger 7.1k Jan 5, 2023
A damn simple library for building production-ready RESTful web services.

Dropwizard Dropwizard is a sneaky way of making fast Java web applications. It's a little bit of opinionated glue code which bangs together a set of l

Dropwizard 8.3k Jan 5, 2023
Library for OpenAPI 3 with spring-boot

Full documentation Acknowledgements springdoc-openapi is made possible thanks to all of its contributors. Introduction The springdoc-openapi Java libr

springdoc-openapi 2.3k Jan 5, 2023
Spring HATEOAS - Library to support implementing representations for hyper-text driven REST web services.

Spring HATEOAS This project provides some APIs to ease creating REST representations that follow the HATEOAS principle when working with Spring and es

Spring 996 Dec 28, 2022
Spring HATEOAS - Library to support implementing representations for hyper-text driven REST web services.

Spring HATEOAS This project provides some APIs to ease creating REST representations that follow the HATEOAS principle when working with Spring and es

Spring 920 Mar 8, 2021
🪖 A library for counting queries for Spring Data JPA application

?? Query-Counter Query-Counter is a library for counting queries for Spring Data JPA application, currently supporting Hibernate only. It aims to help

Jinhong 3 Dec 12, 2021
Fluent builders with typesafe API for the JCA

Security Builders This library implements a set of "fluent" API builders for the java.security classes, and provides more typesafe, intuitive API to a

Terse Systems 44 Sep 13, 2022
Logic-less and semantic Mustache templates with Java

Handlebars.java Logic-less and semantic Mustache templates with Java Handlebars handlebars = new Handlebars(); Template template = handlebars.compile

Edgar Espina 1.3k Dec 23, 2022
Define Java service providers by annotating them directly

Annotated Service Provider Define JVM service providers by annotating the provider class directly. This annotation processor will add to the class-pat

Emily 5 Oct 31, 2021
Deploy this 🔥🔥🔥 BLAZING FAST 🔥🔥🔥 API to get instant access to ✨✨✨ INNOVATIVE ✨✨✨ API to quickly define whether the numbers are odd or even.

Is Odd API This ?? is ?? ?? a ?? simple API that ?? returns ?? whether ?? ?? a ?? number ?? ?? is ?? ?? odd ?? or ?? not. ♂ With ?? ?? this ?? ?? API

rferee 5 Sep 23, 2022
Jason Lee 3 Oct 11, 2022
A library for JavaFX that gives you the ability to show progress on the Windows taskbar.

A clean and easy way to implement this amazing native Windows taskbar-progressbar functionality in javaFX Background Since Windows 7 there is a taskba

Daniel Gyoerffy 77 Nov 28, 2022
KickAss Configuration. An annotation-based configuration system for Java and Kotlin

KAConf 2016-2020 Mario Macías KickAss Configuration v0.9.0 is an Annotation-based configuration system inspired in the wonderful Spring Boot. Its stro

Mario Macías 53 Nov 21, 2022
This plugin disables commands specified in the configuration and prevents granting the "OP" authority to people not authorized in the plugin configuration.

Ares This plugin disables commands specified in the configuration and prevents granting the "OP" authority to people not authorized in the plugin conf

ᴠᴀʟᴇɴᴛɪɴ ᴢʜᴇʟᴇᴠ 6 Aug 30, 2022
Apollo is a reliable configuration management system suitable for microservice configuration management scenarios.

English | 中文 Apollo - A reliable configuration management system Apollo is a reliable configuration management system. It can centrally manage the con

Apollo 27.6k Jan 5, 2023
A simple configuration library for Java applications providing a node structure, a variety of formats, and tools for transformation

Configurate Configurate is a simple configuration library for Java applications that provides a node-based representation of data, able to handle a wi

SpongePowered 274 Jan 3, 2023