diff --git a/examples/BUILD b/examples/BUILD index 1d4cf71..131da59 100644 --- a/examples/BUILD +++ b/examples/BUILD @@ -120,14 +120,15 @@ jsonnet_to_json_test( jsonnet_library( name = "code_library_lib", srcs = ["code_library.libsonnet"], - deps = [":workflow"] + data = [":test_str_files"], + deps = [":workflow"], ) jsonnet_to_json_test( name = "extvar_code_library_test", size = "small", src = "extvar_code_library.jsonnet", - ext_code_libraries = { ":code_library_lib": "codefile" }, + ext_code_libraries = {":code_library_lib": "codefile"}, golden = "extvar_files_library_golden.json", ) @@ -135,8 +136,8 @@ jsonnet_to_json_test( name = "tla_code_library_test", size = "small", src = "tla_code_library.jsonnet", - tla_code_libraries = { ":code_library_lib": "tla_code" }, golden = "tla_code_library_golden.json", + tla_code_libraries = {":code_library_lib": "tla_code"}, ) jsonnet_to_json_test( diff --git a/examples/extvar_code_library.jsonnet b/examples/extvar_code_library.jsonnet index 159e903..d3c9829 100644 --- a/examples/extvar_code_library.jsonnet +++ b/examples/extvar_code_library.jsonnet @@ -1,6 +1,8 @@ local codefile = std.extVar('codefile'); +local data = importstr 'file.txt'; { job: codefile.workflow.Job, shJob: codefile.workflow.ShJob, + data: data, } diff --git a/examples/extvar_files_library_golden.json b/examples/extvar_files_library_golden.json index e4da3ff..e6cd247 100644 --- a/examples/extvar_files_library_golden.json +++ b/examples/extvar_files_library_golden.json @@ -1,16 +1,17 @@ { - "job": { - "deps": [ ], - "inputs": [ ], - "outputs": [ ], - "type": "base" - }, - "shJob": { - "command": "", - "deps": [ ], - "inputs": [ ], - "outputs": [ ], - "type": "sh", - "vars": { } - } + "job": { + "deps": [], + "inputs": [], + "outputs": [], + "type": "base" + }, + "shJob": { + "command": "", + "deps": [], + "inputs": [], + "outputs": [], + "type": "sh", + "vars": {} + }, + "data": "this is great\n" } diff --git a/jsonnet/jsonnet.bzl b/jsonnet/jsonnet.bzl index 5b8c632..4544071 100644 --- a/jsonnet/jsonnet.bzl +++ b/jsonnet/jsonnet.bzl @@ -297,9 +297,15 @@ def _jsonnet_to_json_impl(ctx): outputs.append(compiled_json) command += [ctx.file.src.path, "-o", compiled_json.path] - transitive_data = depset(transitive = [dep.data_runfiles.files for dep in ctx.attr.deps] + - [l.files for l in jsonnet_tla_code_files.keys()] + - [l.files for l in jsonnet_tla_str_files.keys()]) + transitive_data = depset( + transitive = + [dep.data_runfiles.files for dep in ctx.attr.deps] + + [l.files for l in jsonnet_tla_code_files.keys()] + + [l.files for l in jsonnet_tla_str_files.keys()] + + [l[DefaultInfo].data_runfiles.files for l in jsonnet_tla_code_libraries.keys()] + + [l[DefaultInfo].data_runfiles.files for l in jsonnet_ext_code_libraries.keys()], + ) + # NB(sparkprime): (1) transitive_data is never used, since runfiles is only # used when .files is pulled from it. (2) This makes sense - jsonnet does # not need transitive dependencies to be passed on the commandline. It @@ -502,7 +508,9 @@ def _jsonnet_to_json_test_impl(ctx): transitive_data = depset( transitive = [dep.data_runfiles.files for dep in ctx.attr.deps] + [l.files for l in jsonnet_tla_code_files.keys()] + - [l.files for l in jsonnet_tla_str_files.keys()], + [l.files for l in jsonnet_tla_str_files.keys()] + + [l[DefaultInfo].data_runfiles.files for l in jsonnet_tla_code_libraries.keys()] + + [l[DefaultInfo].data_runfiles.files for l in jsonnet_ext_code_libraries.keys()], ) test_inputs = (