Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

config: add extensible "Extra" field, use it ActiveConfig #6056

Merged
merged 1 commit into from Jun 28, 2023

Conversation

srenatus
Copy link
Contributor

Previously, extra keys in the OPA config file would be ignored in the /v1/config API, but included when evaluating opa.runtime().config.

With this change, they'll be collected into the Extra field, and included in the response of an API call to /v1/config, too.

馃懀 Trying out the change

Put this file on disk,

# foo.yml
foo: bar
baz:
  quz: 100
decision_logger:
  console: true

and start OPA via opa run -a 127.0.0.1:8181 -c foo.yml -s.

OPA 0.53.1

$ curl "http://127.0.0.1:8181/v1/config?pretty"            
{
  "result": {
    "default_authorization_decision": "/system/authz/allow",
    "default_decision": "/system/main",
    "labels": {
      "id": "617ef51a-5f78-42ec-ba04-d7ca758c307f",
      "version": "0.53.1"
    }
  }
}
$ curl "http://127.0.0.1:8181/v1/query?pretty" -d '{"query": "x = opa.runtime().config"}'
{
  "result": [
    {
      "x": {
        "baz": {
          "quz": 100
        },
        "decision_logger": {
          "console": true
        },
        "foo": "bar"
      }
    }
  ]
}

This PR

$ curl "http://127.0.0.1:8181/v1/config?pretty"
{
  "result": {
    "baz": {
      "quz": 100
    },
    "decision_logger": {
      "console": true
    },
    "default_authorization_decision": "/system/authz/allow",
    "default_decision": "/system/main",
    "foo": "bar",
    "labels": {
      "id": "4f8394a8-2157-4d5e-a000-07eb6b7abe19",
      "version": "0.54.0-dev"
    }
  }
}
$ curl "http://127.0.0.1:8181/v1/query?pretty" -d '{"query": "x = opa.runtime().config"}'
{
  "result": [
    {
      "x": {
        "baz": {
          "quz": 100
        },
        "decision_logger": {
          "console": true
        },
        "foo": "bar"
      }
    }
  ]
}

Previously, extra keys in the OPA config file would be ignored in the /v1/config
API, but included when evaluating `opa.runtime().config`.

With this change, they'll be collected into the Extra field, and included in the
response of an API call to `/v1/config`, too.

Signed-off-by: Stephan Renatus <stephan@styra.com>
@srenatus srenatus marked this pull request as ready for review June 28, 2023 12:15
Copy link
Member

@anderseknert anderseknert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@srenatus srenatus merged commit ab7bead into open-policy-agent:main Jun 28, 2023
27 checks passed
@srenatus srenatus deleted the sr/extensible-config branch June 28, 2023 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants