google / jsonnet

Jsonnet - The data templating language
http://jsonnet.org
Apache License 2.0
6.92k stars 437 forks source link

How to import local variable from another jsonnet file #1045

Closed XiaosongWen closed 1 year ago

XiaosongWen commented 1 year ago

Hi I have file a.libsonnet:

local panel = {
  new(...)::{... },
  createFromConfig(config)::
    this.new(),
};

local config = std.extVar('config');
panel.createFromConfig(config)

It seams if i only do in another file local panel = import 'a.libsonnet' will also execute panel.createFromConfig(config). Is there a way I can only import panel?

sparkprime commented 1 year ago

Some options:

XiaosongWen commented 1 year ago

@sparkprime Thanks for your suggestion, this is what I finaly did.