小编Dha*_*ade的帖子

如何在 GraphQL 中使用嵌套对象过滤数据

query {
    comp(func: eq(dgraph.type,"ServiceTemplate")) {
    topologytemplate{
        nodetemplates { 
             name
             namespace @filter (eq(url,"a_url")){
                    url
            }
         }
      }   
   }
}
Run Code Online (Sandbox Code Playgroud)

使用上面的查询,我想过滤节点模板对象具有我们在查询中传递的匹配 URL 的数据,我们得到所有节点模板的列表,但我得到的结果如下:

{
  "data": {
    "comp": [
      {
        "topologytemplate": {
          "nodetemplates": [
            {
              "name": "a",
              "namespace": {
                "url": "a_url"
              }
            },
            {
              "name": "b"
            },
            {
              "name": "c"
            },
            {
              "name": "d"
            },
            {
              "name": "e"
            },
            {
              "name": "f",
              "namespace": {
                "url": "b_url"
              }
            },
            {
              "name": "g"
            }
          ]
        }
      }
    ]
  },
}
Run Code Online (Sandbox Code Playgroud)

但我只想要那些具有我们将使用 graphQL 过滤的 URL 的节点模板。知道如何过滤它。

database graph dql graphql dgraph

5
推荐指数
1
解决办法
338
查看次数

Ansible 错误:模板化字符串时出现模板错误:预期标记“打印语句结束”,得到“字符串”

kubectl get -n istio-system secret istio-ca -ogo-template='{{index .data "tls.crt"}}' | base64 -d > ca.pem
Run Code Online (Sandbox Code Playgroud)

如何在 ansible playbook 中运行上述命令?

我尝试按如下方式使用它:

- name: Apply secret istio-ca
  shell: kubectl get -n istio-system secret istio-ca -ogo-template='{{index .data "tls.crt"}}' | base64 -d > ca.pem
  register: sout
Run Code Online (Sandbox Code Playgroud)

但这给了我一个错误,如下所示:

fatal: [172.31.20.135]: FAILED! => {"msg": "template error while templating string: expected token 'end of print statement', got 'string'. String: kubectl get -n istio-system secret istio-ca -ogo-template='{{index .data \"tls.crt\"}}' | base64 -d > ca.pem"}
Run Code Online (Sandbox Code Playgroud)

ansible kubernetes kubectl

0
推荐指数
1
解决办法
3874
查看次数

标签 统计

ansible ×1

database ×1

dgraph ×1

dql ×1

graph ×1

graphql ×1

kubectl ×1

kubernetes ×1