sjsonnet icon indicating copy to clipboard operation
sjsonnet copied to clipboard

Fix Description of `-J`

Open ijrsvt opened this issue 1 year ago • 2 comments

The -J parameter of sjsonnet appears to prefer **left-hand** files over right-hand files. This change in behavior happened between 0.3.0and0.3.1`, so I think it makes sense to change the documentation, not the behavior.[1]

I think that the change happened in https://github.com/databricks/sjsonnet/pull/107, but I'm not 100% sure if I'm reading the Scala correctly. The previous implementation seems to prepend values to the jpath variable [2].

[1]: Create the following files:

/tmp/a/file.jsonnet {value: "a"}
/tmp/b/file.jsonnet {value: "b"}
/tmp/c/file.jsonnet {value: "c"}

and ~/dumb.jsonnet:

local file = import "file.jsonnet";

{
whoami : file.value
}

Run the following commands

curl -L https://github.com/databricks/sjsonnet/releases/download/0.3.0/sjsonnet.jar  > /tmp/sjsonnet30.jar; chmod +x /tmp/sjsonnet30.jar
curl -L https://github.com/databricks/sjsonnet/releases/download/0.3.1/sjsonnet.jar  > /tmp/sjsonnet31.jar; chmod +x /tmp/sjsonnet31.jar

$ /tmp/sjsonnet31.jar /home/ian.rodney/dumb.jsonnet -J /tmp/c/ -J /tmp/a/ -J /tmp/b/ 
{
   "whoami": "c"
}
$ /tmp/sjsonnet30.jar /home/ian.rodney/dumb.jsonnet -J /tmp/c/ -J /tmp/a/ -J /tmp/b/ 
{
   "whoami": "b"
}

[2]:

    Arg[Config, String](
      "jpath", Some('J'),
      "Specify an additional library search dir (right-most wins)",
      (c, v) => c.copy(jpaths = v :: c.jpaths)
    ),

ijrsvt avatar Jan 26 '24 20:01 ijrsvt

Hey @lihaoyi-databricks Could you PTAL at this?

ianrodney-db avatar Mar 08 '24 18:03 ianrodney-db

@carl-db do you think you can help take a look at this? The main question is whether to update the docs to align with the current behavior, or update the current behavior to align with the docs (and I presume the upstream implementation)

IMO updating the behavior to match the docs/upstream is the correct thing to do, but that may have some migration cost/risk, so it's something you guys should probably make the decision for since you own our jsonnet tooling overall

lihaoyi-databricks avatar Mar 08 '24 22:03 lihaoyi-databricks