runtime: Add build commit to runtime info

With #1715 we updated opa.runtime() to include the OPA semantic
version in the output. This change extends that to include the build
commit which is useful for development purposes.

Signed-off-by: Torin Sandall <torinsandall@gmail.com>
This commit is contained in:
Torin Sandall
2019-09-09 21:17:10 -04:00
parent 8879b1f519
commit ccf263c3be
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -391,7 +391,7 @@ In order to trigger the use of HTTPs the user must provide one of the following
### OPA
| Built-in | Description |
| ------- |-------------|
| <span class="opa-keep-it-together">``output := opa.runtime()``</span> | ``opa.runtime`` returns a JSON object ``output`` that describes the runtime environment where OPA is deployed. **Caution**: Policies that depend on the output of ``opa.runtime`` may return different answers depending on how OPA was started. If possible, prefer using an explicit `input` or `data` value instead of `opa.runtime`. The ``output`` of ``opa.runtime`` will include a ``"config"`` key if OPA was started with a configuration file. The ``output`` of ``opa.runtime`` will include a ``"env"`` key containing the environment variables that the OPA process was started with. The ``output`` of ``opa.runtime`` will include a ``"version"`` key containing the version of OPA. |
| <span class="opa-keep-it-together">``output := opa.runtime()``</span> | ``opa.runtime`` returns a JSON object ``output`` that describes the runtime environment where OPA is deployed. **Caution**: Policies that depend on the output of ``opa.runtime`` may return different answers depending on how OPA was started. If possible, prefer using an explicit `input` or `data` value instead of `opa.runtime`. The ``output`` of ``opa.runtime`` will include a ``"config"`` key if OPA was started with a configuration file. The ``output`` of ``opa.runtime`` will include a ``"env"`` key containing the environment variables that the OPA process was started with. The ``output`` of ``opa.runtime`` will include ``"version"`` and ``"commit"`` keys containing the semantic version and build commit of OPA. |
### Debugging
| Built-in | Description |
+1 -1
View File
@@ -51,8 +51,8 @@ func Term(params Params) (*ast.Term, error) {
}
obj.Insert(ast.StringTerm("env"), ast.NewTerm(env))
obj.Insert(ast.StringTerm("version"), ast.StringTerm(version.Version))
obj.Insert(ast.StringTerm("commit"), ast.StringTerm(version.Vcs))
return ast.NewTerm(obj), nil
}