All Projects → Incenteev → Parameterhandler

Incenteev / Parameterhandler

Licence: mit
Composer script handling your ignored parameter file

Projects that are alternatives of or similar to Parameterhandler

config-cpp
C++ Configuration management library inspired by the Viper package for golang.
Stars: ✭ 21 (-97.68%)
Mutual labels:  yaml, environment-variables
Fig
A minimalist Go configuration library
Stars: ✭ 142 (-84.33%)
Mutual labels:  environment-variables, yaml
Mconfig
MCONFIG is a lightweight Golang library for integrating configs files like (json, yml, toml) and environment variables into one config struct.
Stars: ✭ 28 (-96.91%)
Mutual labels:  environment-variables, yaml
goodconf
Transparently load variables from environment or JSON/YAML file.
Stars: ✭ 80 (-91.17%)
Mutual labels:  yaml, environment-variables
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (-97.79%)
Mutual labels:  yaml, environment-variables
paerser
No description or website provided.
Stars: ✭ 38 (-95.81%)
Mutual labels:  yaml, environment-variables
Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+129.8%)
Mutual labels:  environment-variables, yaml
exenv
Exenv makes loading environment variables from external sources easy.
Stars: ✭ 35 (-96.14%)
Mutual labels:  yaml, environment-variables
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (-90.51%)
Mutual labels:  yaml, environment-variables
pyaml env
Parse YAML configuration with environment variables in Python
Stars: ✭ 36 (-96.03%)
Mutual labels:  yaml, environment-variables
Carvel Ytt
YAML templating tool that works on YAML structure instead of text
Stars: ✭ 816 (-9.93%)
Mutual labels:  yaml
Ansible Skeleton
The skeleton to create new ansible roles.
Stars: ✭ 5 (-99.45%)
Mutual labels:  yaml
Ical
iCal-creator for PHP
Stars: ✭ 891 (-1.66%)
Mutual labels:  composer
Composer Asset Plugin
NPM/Bower Dependency Manager for Composer
Stars: ✭ 898 (-0.88%)
Mutual labels:  composer
Kubernetes Examples
Minimal self-contained examples of standard Kubernetes features and patterns in YAML
Stars: ✭ 811 (-10.49%)
Mutual labels:  yaml
Strictyaml
Type-safe YAML parser and validator.
Stars: ✭ 836 (-7.73%)
Mutual labels:  yaml
Yaml.js
Standalone JavaScript YAML 1.2 Parser & Encoder. Works under node.js and all major browsers. Also brings command line YAML/JSON conversion tools.
Stars: ✭ 810 (-10.6%)
Mutual labels:  yaml
Just Api
💥 Test REST, GraphQL APIs
Stars: ✭ 768 (-15.23%)
Mutual labels:  yaml
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (-16.23%)
Mutual labels:  yaml
Aliyun Sts
基于阿里云openapi系列接口中STS最新版本的SDK进行封装的composer package,解耦其他产品SDK,各个产品SDK功能使用组件化加载,减少代码臃肿。
Stars: ✭ 19 (-97.9%)
Mutual labels:  composer

Managing your ignored parameters with Composer

This tool allows you to manage your ignored parameters when running a composer install or update. It works when storing the parameters in a Yaml file under a single top-level key (named parameters by default). Other keys are copied without change.

Build Status Code Coverage Scrutinizer Quality Score SensioLabsInsight Latest Stable Version Latest Unstable Version

Usage

Add the following in your root composer.json file:

{
    "require": {
        "incenteev/composer-parameter-handler": "~2.0"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters"
        ]
    },
    "extra": {
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        }
    }
}

The app/config/parameters.yml will then be created or updated by the composer script, to match the structure of the dist file app/config/parameters.yml.dist by asking you the missing parameters.

By default, the dist file is assumed to be in the same place than the parameters file, suffixed by .dist. This can be changed in the configuration:

{
    "extra": {
        "incenteev-parameters": {
            "file": "app/config/parameters.yml",
            "dist-file": "some/other/folder/to/other/parameters/file/parameters.yml.dist"
        }
    }
}

The script handler will ask you interactively for parameters which are missing in the parameters file, using the value of the dist file as default value. All prompted values are parsed as inline Yaml, to allow you to define true, false, null or numbers easily. If composer is run in a non-interactive mode, the values of the dist file will be used for missing parameters.

Warning: This parameters handler will overwrite any comments or spaces into your parameters.yml file so handle with care. If you want to give format and comments to your parameter's file you should do it on your dist version.

Keeping outdated parameters

Warning: This script removes outdated params from parameters.yml which are not in parameters.yml.dist If you need to keep outdated params you can use keep-outdated param in the configuration:

{
    "extra": {
        "incenteev-parameters": {
            "keep-outdated": true
        }
    }
}

Using a different top-level key

The script handler looks for a parameters key in your dist file. You can change this by using the parameter-key param in the configuration:

{
    "extra": {
        "incenteev-parameters": {
            "parameter-key": "config"
        }
    }
}

Using environment variables to set the parameters

For your prod environment, using an interactive prompt may not be possible when deploying. In this case, you can rely on environment variables to provide the parameters. This is achieved by providing a map between environment variables and the parameters they should fill:

{
    "extra": {
        "incenteev-parameters": {
            "env-map": {
                "my_first_param": "MY_FIRST_PARAM",
                "my_second_param": "MY_SECOND_PARAM"
            }
        }
    }
}

If an environment variable is set, its value will always replace the value set in the existing parameters file.

As environment variables can only be strings, they are also parsed as inline Yaml values to allows specifying null, false, true or numbers easily.

Renaming parameters

If you are renaming a parameter, the new key will be set according to the usual routine (prompt if possible, use environment variables, use default). To have the parameters handler use the value of an (obsolete) parameter, specify a rename-map:

{
    "extra": {
        "incenteev-parameters": {
            "rename-map": {
                "new_param_1": "old_param_1",
                "new_param_2": "old_param_2"
            }
        }
    }
}

This will create the new parameters new_param_1 and new_param_2 while using the values from old_param_1 and old_param_2, respectively. It will not remove the old parameters unless you've also removed them from the dist version.

If the old parameter is no longer present (maybe because it has been renamed and removed already), no parameters are overwritten. You don't need to remove obsolete parameters from the rename map once they have been renamed.

Managing multiple ignored files

The parameter handler can manage multiple ignored files. To use this feature, the incenteev-parameters extra should contain a JSON array with multiple configurations inside it instead of a configuration object:

{
    "extra": {
        "incenteev-parameters": [
            {
                "file": "app/config/parameters.yml",
                "env-map": {}
            },
            {
                "file": "app/config/databases.yml",
                "dist-file": "app/config/databases.dist.yml",
                "parameter-key": "config"
            }
        ]
    }
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].