~egtann/inv2config

inv2config/README.md -rw-r--r-- 1.0 KiB
f27c93b9 — Evan Tann rename module to inv2config, remove up dependency 3 months ago

#inventory2config

Takes an inventory.json and a service-based SRP config file as inputs and outputs an SRP config file pointing at specific IPs.

Example inventory.json:

{"10.128.0.1":["my-app"]}

Example service-based SRP config file:

{
	"Services": {
		"www.example.com": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3000
		},
		"www-example.internal": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3001
		}
	}
}

To use:

inventory2config -i inventory.json -c config_service.json > config.json

This outputs a config.json with backends populated with the correct ip:port combinations like so:

{
	"Services": {
		"www.example.com": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3000,
			"Backends": ["10.128.0.1:3000"]
		},
		"www-example.internal": {
			"HealthPath": "/health",
			"Service": "my-app",
			"Port": 3001,
			"Backends": ["10.128.0.1:3001"]
		}
	}
}

SRP will ignore the Service and Port. They are added for this tool only.