我import
对 JSONNet 的功能有疑问。我想要的是能够导入一个主libsonnet
文件,该文件本身由多个导入组成,并且能够从一个导入中访问所有内容。
我有以下示例结构:
.
├── library_one
│ └── init.libsonnet
├── library_two
│ └── init.libsonnet
├── init.libsonnet
└── test.jsonnet
每个文件的内容如下:
library_one/init.libsonnet
{
local LibraryOne = self,
some_function(some_argument='default'):: [
'echo "The argument was %s"' % some_argument,
],
}
library_two/init.libsonnet
{
local LibraryTwo = self,
some_other_function(some_other_argument='another_default'):: [
'echo "The other argument was %s"' % some_other_argument,
],
}
最后,根目录下的“主”文件init.libsonnet:
local library_one = import 'library_one/init.libsonnet';
local library_two = import 'library_two/init.libsonnet';
{}
但是,当我使用以下内容运行文件test.jsonnnet时:
local master = import 'init.libsonnet';
{
some_key: master.library_one.some_function,
some_other_key: master.library_two.some_other_function,
}
我得到错误:
RUNTIME ERROR: field does not exist: library_one
test.jsonnet:4:13-31 object <anonymous>
During manifestation
这种继承是不可能的吗?