GithubHelp home page GithubHelp logo

configuration_tool's Introduction

configuration_tool

Configuration tool creates environment configuration files based on templates.

How to Use

Create the following directory structure:

templates
   < template >.sh and <template >.properties
envs
   env_name
       env.properties

Create templates for .sh and .properties. Use ${VARIABLE_NAME} to substitute a variable value into the environment files. In the template below ${KAFKA_BROKER} is a variable.

kafka.bootstrap.servers=${KAFKA_BROKER}

All other file extensions are copied from the templates directory to the generated config files without any modifications.

Edit the env.properties file and add the values of the variables specific to the environment:

KAFKA_BROKER=mybroker:9092

Build the config program.

cd <repo directory>
mvn clean package

Run the config program.

java -classpath target/configuration_tool-jar-with-dependencies.jar com.example.cybersec.CybersecConfigGenerator <template directory> <env directory containing env.properties>

The generated config files are created in /configs.

Example

# Defining the variables.
 % mkdir -p /tmp/envs/env_nam
 % echo 'KAFKA_BROKER=mykafkabroker:9092' > /tmp/envs/env_name/env.properties com.example.cybersec.CybersecConfigGenerator <template directory> <env directory containing env.properties>
 % cat /tmp/envs/env_name/env.properties 
 KAFKA_BROKER=mykafkabroker:9092

 # Creating the templates
 % mkdir /tmp/templates
 % echo 'kafka.bootstrap.servers=${KAFKA_BROKER}' > /tmp/templates/myproperties.properties
 % cat /tmp/templates/myproperties.properties 
 kafka.bootstrap.servers=${KAFKA_BROKER}

 # Run config tool to populate the template
 % java -classpath target/configuration_tool-jar-with-dependencies.jar com.example.cybersec.CybersecConfigGenerator /tmp/envs/env_name /tmp/templates
   Populating template /tmp/templates/myproperties.properties

 # The KAFKA_BROKER variable is replace with its value
 # config files are in the configs subdirectory of the env dir
 % cat /tmp/envs/env_name/configs/myproperties.properties 
kafka.bootstrap.servers=mykafkabroker:9092

configuration_tool's People

Contributors

carolynduby avatar

Watchers

James Cloos 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.