Git
Styra Load's support for pulling in data from any Git repository makes it possible to use GitOps practices for managing data and have that data available for policy evaluations in Styra Load.
Example Configuration
The Git integration is provided via the data
plugin, and needs to be enabled in Load's configuration.
load-conf.yaml (minimal)
plugins:
data:
git.users:
type: git
url: https://git.internal.corp/data-repository
file_path: users.json
With this minimal configuration, Styra Load will pull in the users.json
file from the
repository's main
branch every 30 seconds.
All of this, and various authentication methods, can be configured using an advanced configuration:
load-conf-advanced.yaml
plugins:
data:
git.users:
type: git
url: https://git.internal.corp/data-repository
file_path: users.json
commit: 73b9d1aefab # if empty, use `branch` (default: none)
branch: prod-branch # if empty, use `reference` (default: none)
reference: ref/heads/main # full git reference
polling_interval: 10m # default: 30s, minimum 10s
username: alice # basic auth
password: wordpass # basic auth
token: personal-access-token # token auth
private_key: path/to/key # SSH key, file path or PEM contents
passphrase: secret # passphrase for protected keys
With a config like this, Styra Load will retrieve the file from the specified repository location, and attempt to parse as any of:
- XML
- YAML
- JSON
The result will then be available to all policy evaluations under data.git.users
.
Example Call
If the referenced Git repository contains a users.json
file with this content,
[
{"username": "alice", "roles": ["admin"]},
{"username": "bob", "roles": []},
{"username": "catherine", "roles": ["viewer"]}
]
then Styra Load's data.git.users
will look like this:
$ curl 'http://127.0.0.1:8181/v1/data/git/users?pretty'
{
"result": [
{
"roles": [
"admin"
],
"username": "alice"
},
{
"roles": [],
"username": "bob"
},
{
"roles": [
"viewer"
],
"username": "catherine"
}
]
}
The key below data
in the configuration (git.users
in the example) can be anything you want,
and determines where the retrieved document will be found in Styra Load's data
hierarchy.