GithubHelp home page GithubHelp logo

xebialabs-community / placeholders-mustachifier-maven-plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bmoussaud/placeholders-mustachifier-maven-plugin

2.0 20.0 4.0 671 KB

Transform a text file full of {{placeholder:value}} into a file with only {{placeholders}} or only values.

Home Page: http://bmoussaud.github.io/placeholders-mustachifier-maven-plugin/0.4

Java 98.93% Dockerfile 1.07%

placeholders-mustachifier-maven-plugin's Introduction

Maven Plugin : Placeholders Mustachifier

Overview

XL Deploy simplifies configuration management by removing environment specific values from configuration files. During deployment, XL Deploy will apply configurations with values appropriate for the deployment environment.

To leverage this capability, configuration files have 'mustachified' property placeholders instead of values. In XL Deploy, you create a dictionary that maps property placeholders to a value. Dictionaries are assigned to environments.

For example, it is common for database connection information to vary from one environment to another. In a configuration file set up for XL Deploy configuration management, the configuration might look like this:

<Connector id="Default JDBC Database">
    JdbcDriver org.postgresql.Driver
    JdbcUrl jdbc:postgresql://{{DB_URL}}/{{DB_NAME}}
    UserName {{DB_USERNAME}}
    Password {{DB_PASSWORD}}
</Connector>

A dictionary in XL Deploy would map these placeholders, DB_URL, DB_NAME, DB_USERNAME, and DB_PASSWORD to actual values. During deployment, XL Deploy will scan the configuration file and replace the placeholder token with the correct value for the environment.

So far so good. However, this causes a problem for developers. Generally configuration files are managed in a source code repository along with other code. During development, programmers will check out the code, do work, build locally and test. However the application won't run with property placeholders in the configuration files. That's where this plugin comes in.

Usage

There are two ways you can use this plugin to solve the 'property placeholder development' problem. Specify default values in the configuration or use a separate property file for local values.

Method 1 : Default Values

This plugin can produce configuration files with either property keys or property values. For example, you can create your configuration files to have property placeholder keys with a default value like this...

<Connector id="Default JDBC Database">
    JdbcDriver org.postgresql.Driver
    JdbcUrl jdbc:postgresql://{{DB_URL:localhost}}/{{DB_NAME:mydb}}
    UserName {{DB_USERNAME:scott}}
    Password {{DB_PASSWORD:tiger}}
</Connector>

When you run a build for local testing, use the 'mustache-tovalue' mode and the plugin will generate a configuration like this...

<Connector id="Default JDBC Database">
    JdbcDriver org.postgresql.Driver
    JdbcUrl jdbc:postgresql://localhost/mydb
    UserName scott
    Password tiger
</Connector>

When building for an XL Deploy deployment, use the 'mustache-tokey' mode and the plugin will generate a configuration like this...

<Connector id="Default JDBC Database">
    JdbcDriver org.postgresql.Driver
    JdbcUrl jdbc:postgresql://{{DB_URL}}/{{DB_NAME}}
    UserName {{DB_USERNAME}}
    Password {{DB_PASSWORD}}
</Connector>

Pros

  • Developers do not have to manage a local property file.

Cons

  • All developers would need local development environments configured the same way.

Method 2 : Local Properties File

If your developers tend to have their own local configurations, this plugin can do a property placeholder substitution, much like XL Deploy, using a local properties file. Taking the above example ready for XL Deploy...

<Connector id="Default JDBC Database">
    JdbcDriver org.postgresql.Driver
    JdbcUrl jdbc:postgresql://{{DB_URL}}/{{DB_NAME}}
    UserName {{DB_USERNAME}}
    Password {{DB_PASSWORD}}
</Connector>

The developer could create a local properties file like this...

DB_URL=localhost
DB_NAME=mydb
DB_USERNAME=scott
DB_PASSWORD=tiger

Running the plugin 'mustache-tovalue' goal would generate a configuration file like this...

<Connector id="Default JDBC Database">
    JdbcDriver org.postgresql.Driver
    JdbcUrl jdbc:postgresql://localhost/mydb
    UserName scott
    Password tiger
</Connector>

Pros

  • Developers have full control over their local configurations.

Cons

  • Developers need to maintain their own local properties file.

More information here: http://xebialabs-community.github.io/placeholders-mustachifier-maven-plugin/0.5-SNAPSHOT/

Development

The unit test uses a nice tool called Restito https://github.com/mkotsur/restito to mock the REST calls

Docker

The docker folder contains two images to build the plugin using java7 or java8

Install Locally

By default jar is signed after packaging and before installation. To skip that (testing):

mvn -Dgpg.skip install

placeholders-mustachifier-maven-plugin's People

Contributors

ndebuhr avatar t-j-f avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.