Open coord-e opened 2 months ago
It seems the current implementation uses the EvaluateAnonymousSnippet
function which is likely the reason it does not attempt to import other files. EvaluateFile
also exists which likely has the desired behavior but doesn't work well with the conftest's parser interface. Additional investigation and testing will be needed before we can add this.
After some testing, it looks like the import path in the jsonnet config is relative to $PWD, not main.jsonnet
. If you import ./config/data.libsonnet
it works as expected.
it looks like the import path in the jsonnet config is relative to $PWD, not main.jsonnet. If you import ./config/data.libsonnet it works as expected.
that is indeed behavior of conftest's jsonnet parser, but isn't that of the most jsonnet CLI implementation (such as google/go-jsonnet, google/jsonnet, etc). my request is to align conftest's import behavior to accept the exactly same jsonnet configuration as the known existing jsonnet implementation accepts.
I would welcome a PR.
Jsonnet has an
import
construct to load other jsonnet files. The following configuration successfully evaluates as follows:However, conftest cannot handle relative
import
s (in directories other than.
).Although the specification seems not specifying how the
import
-ed relative paths are resolved, most jsonnet implementations handle these paths as if they're relative to theimport
-ing file.We can work around this by
jsonnet config/main.jsonnet | conftest test -
, but native support is better in context ofdata.conftest.file
support, nicer error reportings, etc.Version information