我想要做的是SELECT metadata->name, metadata->namespace
,但前提是spec.volumes
包含一个secretName = 'test-secret'
来自如下对象列表的对象:
{
"kind": "PodList",
"apiVersion": "v1",
"metadata": {
"selfLink": "/api/v1/pods",
},
"items": [
{
"metadata": {
"name": "pod1",
"namespace": "namespace1"
},
"spec": {
"volumes": [
{
"name": "default-token",
"secret": {
"secretName": "default-token"
}
}
],
"nodeName": "node-1"
}
}
{
"metadata": {
"name": "pod2",
"namespace": "namespace2"
},
"spec": {
"volumes": [
{
"name": "default-token",
"secret": {
"secretName": "default-token"
}
}
],
"nodeName": "node-2"
}
},
{
"metadata": {
"name": "chosen-pod",
"namespace": "namespace3",
},
"spec": {
"volumes": [
{
"name": "pod-storage",
},
{
"name": "test-data",
"secret": {
"secretName": "test-secret"
}
}
],
"nodeName": "node-2",
}
}
]
}
这个列表被插入到一个表中;
CREATE TABLE pods (node TEXT, metadata Object, spec Object)
我认为这是我最接近的一次;
SELECT metadata->name, metadata->namespace, spec->volumes AS volumes FROM pods WHERE (SELECT COUNT(*) FROM ? WHERE secret->secretName = 'test-data') > 0
但这会引发错误:
TypeError: Cannot read property '0' of undefined
at Object.eval [as datafn] (eval at <anonymous> (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:7487:20), <anonymous>:3:40)
at ~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:6100:19
at Array.forEach (native)
at queryfn (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:6097:16)
at Array.statement (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:7121:14)
at eval [as wherefn] (eval at <anonymous> (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:7899:11), <anonymous>:3:56)
at doJoin (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:6615:12)
at doJoin (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:6687:8)
at queryfn3 (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:6174:2)
at queryfn2 (~/Documents/myproject/node_modules/alasql/dist/alasql.fs.js:6149:9)
WHERE
嗯,我的条款有错误吗?不,> 0
从最后删除它会引发相同的异常。
我也尝试过从这个问题/答案向后工作;
SEARCH / AS @a
UNION ALL(
spec->volumes AS @v
RETURN(@a->metadata->name AS name,
@a->metadata->namespace AS namespace,
@v->secret->secretName AS [secretNames]
)
)
FROM pods
但@v->secret->secretName AS [secretNames]
正义的收益undefined
;
[ 'pod1', 'namespace1', undefined ]
[ 'pod2', 'namespace2', undefined ]
[ 'chosen-pod', 'namespace3', undefined ]
返回裸@v
数组让我回到了以前的位置——一行有一个我似乎无法过滤的数组。