env4config

Environment variables resolution for Typesafe Config

License

License

Categories

Categories

config Application Layer Libs Configuration
GroupId

GroupId

com.codacy
ArtifactId

ArtifactId

env4config
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

env4config
Environment variables resolution for Typesafe Config
Project URL

Project URL

https://www.codacy.com
Project Organization

Project Organization

Codacy
Source Code Management

Source Code Management

https://github.com/codacy/env4config

Download env4config

How to add to project

<!-- https://jarcasting.com/artifacts/com.codacy/env4config/ -->
<dependency>
    <groupId>com.codacy</groupId>
    <artifactId>env4config</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.codacy/env4config/
implementation 'com.codacy:env4config:1.0.1'
// https://jarcasting.com/artifacts/com.codacy/env4config/
implementation ("com.codacy:env4config:1.0.1")
'com.codacy:env4config:jar:1.0.1'
<dependency org="com.codacy" name="env4config" rev="1.0.1">
  <artifact name="env4config" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.codacy', module='env4config', version='1.0.1')
)
libraryDependencies += "com.codacy" % "env4config" % "1.0.1"
[com.codacy/env4config "1.0.1"]

Dependencies

provided (1)

Group / Artifact Type Version
com.typesafe : config jar 1.3.3

test (4)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.8
org.jacoco : org.jacoco.agent jar 0.7.9
junit : junit jar 4.11
com.novocode : junit-interface jar 0.11

Project Modules

There are no modules declared in this project.

ENV4CONFIG

Codacy Badge CircleCI Maven Central

This is an alternative config.strategy for Typesafe Config to enable Environment Variable substitution on every configuration key without the need to explicitly bind the substitution in the configuration file.

Please note that this library is published as a road unblocker until this PR find it's way upstream.

Conventions

Each environment variable is transformed as follows:

  • remove the trailing prefix config.env_var_prefix ( Default: CONFIG_FORCE_)
  • trasform all the _ characters into .
  • trasform all the __ characters into -
  • trasform all the ___ characters into _

Usage

Import this library along with Typesafe Config:

libraryDependencies ++= Seq(
  "com.typesafe" % "config" % <typesafe-config-version>,
  "com.codacy" % "env4config" % <version>
)

Then specify the proper config.strategy as a Java property:

java -Dconfig.strategy=com.codacy.config.EnvFirstConfigLoadingStrategy <....>

Rationale

According to the Twelve-factor App the configuration should be passed to the applications via environment variables.

The "de-facto" standard for configuration in Scala application is Typesafe Config and env variables are a supported fallback; still it is not possible to override virtually any configuration of our application if not properly encoded the binding accordingly.

Although Typesafe Config offers an hook as a config.strategy to tune the initial loading order of configurations, leveraging it is possible to load Environment variables first.

This makes it easy to bridge the gap and by having a standard way to convert environment variables into Java system properties make it possible to fully comply with Twelve-factor App.

Compile

You need to have the crystal compiler available in your classpath to succesfully build this utility, otherwise you can compile it statically using a docker image using make buildStatic.

What is Codacy

Codacy is an Automated Code Review Tool that monitors your technical debt, helps you improve your code quality, teaches best practices to your developers, and helps you save time in Code Reviews.

Among Codacy’s features

  • Identify new Static Analysis issues
  • Commit and Pull Request Analysis with GitHub, BitBucket/Stash, GitLab (and also direct git repositories)
  • Auto-comments on Commits and Pull Requests
  • Integrations with Slack, HipChat, Jira, YouTrack
  • Track issues in Code Style, Security, Error Proneness, Performance, Unused Code and other categories

Codacy also helps keep track of Code Coverage, Code Duplication, and Code Complexity.

Codacy supports PHP, Python, Ruby, Java, JavaScript, and Scala, among others.

Free for Open Source

Codacy is free for Open Source projects.

License

env4config is available under the Apache 2 license. See the LICENSE file for more info.

com.codacy

Codacy

Versions

Version
1.0.1
1.0.0
0.2.4
0.2.3
0.2.2
0.2.1
0.1.1
0.1.0