MultiIndex
Gem reads an Excel Google Doc containing the multi-index mapping used in the Segmentation system and writes results to output or updates EAS or Config Service with the desired configuration.
Installation
Add this line to your application's Gemfile:
gem 'multi_index'
And then execute:
$ bundle
Or install it yourself as:
$ gem install multi_index
Usage
This gem comes with a command interface. Once installed the multi-index
executable should be on your path. To get help run the command:
multi-index config [SUBCOMMAND] -t, --tier=TIER # Command to retrieve configuration by tier
multi-index help [COMMAND] # Describe available commands or one specific command
The main command here is config. To retrieve help type multi-index help config
(this will show you all options available whereas the example above only shows required options):
Usage:
multi-index config [SUBCOMMAND] -t, --tier=TIER
Options:
-t, --tier=TIER # The tier of the configuration. Use ALL to get all tiers.
# Default: ALL
-p, [--profile=PROFILE] # The profile yaml file for logging into Google Drive and LDAP and key of the Google doc to read from.
Command to retrieve configuration by tier
Subcommands and Getting Help
The gem currently only writes to STDOUT. Writing to local EAS codebase and Config Service is not available yet.
To get help about subcommand run multi-index config help
:
multi-index config help [COMMAND] # Describe subcommands or one specific subcommand
multi-index config write # Write config to a target.
The write subcommand in available. To get help on this command run multi-index config help write
:
Usage:
multi-index write
Options:
-o, [--output=OUTPUT] # The destination to write configuration output to. Allowed: ["EAS", "CONFIG_SERVICE", "stdout"]
# Default: stdout
-f, [--format=FORMAT] # The format of output. Depending on output might be inferred automatically. Allowed: ["yaml", "json", "escaped"]
# Default: yaml
-i, [--invert] # Invert from alias-indices to index-alias map
Write config to a target.
Example Profile File
A profile file will have sensitive information encrypted (such as passwords). This can be generated for example by running the command multi-index config profile -f profile.yml
. This command will prompt you for the fields and then write the data to a profile file for future use, so you don't need to type in your credential everytime.
google_drive:
email: nayyara.samuel@opower.com
password: OpripQ+sdkf78==
key: 0AjHO2wGDCPKcdEF0bWgxV1VvQUx1NzNic2VxWWlNQ1E
sheet: 0
Examples of Runs with Parameters
COMMAND: multi-index config -t dev -p profile.yml write -o stdout -f json -i
******** MULTI-INDEX CONFIGURATION: dev ********
{
"dev": {
"cpau": "segmentation-entity-attributes-qa-1",
"dir": "segmentation-entity-attributes-qa-1",
"otp": "segmentation-entity-attributes-qa-1",
"wmco": "segmentation-entity-attributes-qa-1",
"demo": "segmentation-entity-attributes-qa-1",
"cec": "segmentation-entity-attributes-qa-1",
"ngma": "segmentation-entity-attributes-qa-1",
"pge": "segmentation-entity-attributes-qa-1",
"aepo": "segmentation-entity-attributes-qa-1"
}
}
COMMAND: multi-index config -t ALL -p profile.yml write -o stdout -f yaml
******** MULTI-INDEX CONFIGURATION: ALL ********`
---
dev:
segmentation-entity-attributes-qa-1:
- cpau
- dir
- otp
- wmco
- demo
- cec
- ngma
- pge
- aepo
stage:
segmentation-entity-attributes-stage-1:
- cpau
- dir
- otp
- wmco
- demo
- cec
- ngma
- pge
- aepo
prod:
segmentation-entity-attribute-production-1:
- cpau
- dir
- otp
- wmco
- demo
- cec
- ngma
- pge
- aepo
COMMAND: multi-index config -t ALL -p profile.yml write -o stdout -f yaml -i
_api
******** MULTI-INDEX CONFIGURATION: ALL ********
---
dev:
cpau: segmentation-entity-attributes-qa-1
dir: segmentation-entity-attributes-qa-1
otp: segmentation-entity-attributes-qa-1
wmco: segmentation-entity-attributes-qa-1
demo: segmentation-entity-attributes-qa-1
cec: segmentation-entity-attributes-qa-1
ngma: segmentation-entity-attributes-qa-1
pge: segmentation-entity-attributes-qa-1
aepo: segmentation-entity-attributes-qa-1
stage:
cpau: segmentation-entity-attributes-stage-1
dir: segmentation-entity-attributes-stage-1
otp: segmentation-entity-attributes-stage-1
wmco: segmentation-entity-attributes-stage-1
demo: segmentation-entity-attributes-stage-1
cec: segmentation-entity-attributes-stage-1
ngma: segmentation-entity-attributes-stage-1
pge: segmentation-entity-attributes-stage-1
aepo: segmentation-entity-attributes-stage-1
prod:
cpau: segmentation-entity-attribute-production-1
dir: segmentation-entity-attribute-production-1
otp: segmentation-entity-attribute-production-1
wmco: segmentation-entity-attribute-production-1
demo: segmentation-entity-attribute-production-1
cec: segmentation-entity-attribute-production-1
ngma: segmentation-entity-attribute-production-1
pge: segmentation-entity-attribute-production-1
aepo: segmentation-entity-attribute-production-1
TODO
Contributing
- Fork it ( http://github.com//multi_index/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request