如何转义 gcloud 格式/过滤器命令中的斜线?

How to escape slash in gcloud format / filter command?

我想通过其容器映像过滤 Cloud 运行 修订版。

当我 运行 这个 gcloud 运行 修改命令时,

gcloud beta run revisions list --service sample-service --region=asia-northeast1 --limit=5 --sort-by="~DEPLOYED" --format="json"

它将输出以下json

[
  {
    "apiVersion": "serving.knative.dev/v1",
    "kind": "Revision",
    "metadata": {
      "annotations": {
        "autoscaling.knative.dev/maxScale": "1",
        "client.knative.dev/user-image": "asia.gcr.io/sample-gcp-project/sample-app:e88597bcfb346aa1",
        "run.googleapis.com/client-name": "gcloud",
        "run.googleapis.com/client-version": "383.0.1", # 

我试图通过 --filter 选项过滤修订,但它引发了一个错误。

gcloud beta run revisions list --service it-sys-watch --region=asia-northeast1 --limit=1 --sort-by="~DEPLOYED" --filter='metadata.annotations.client.knative.dev/user-image=asia.gcr.io/sample-gcp-project/sample-app:e88597bcfb346aa1'
ERROR: (gcloud.beta.run.revisions.list) Non-empty key name expected [metadata.annotations.client.knative.dev *HERE* /user-image=asia.gcr.io/sample-gcp-project/sample-app:e88597bcfb346aa1].

添加反斜杠和双斜杠都不行

gcloud beta run revisions list --service it-sys-watch --region=asia-northeast1 --limit=1 --sort-by="~DEPLOYED" --filter='metadata.annotations.client.knative.dev\/user-image=asia.gcr.io/sample-gcp-project/sample-app:e88597bcfb346aa1'
WARNING: The following filter keys were not present in any resource : metadata.annotations.client.knative.dev\/user-image
Listed 0 items.

gcloud beta run revisions list --service it-sys-watch --region=asia-northeast1 --limit=1 --sort-by="~DEPLOYED" --filter='metadata.annotations.client.knative.dev//user-image=asia.gcr.io/sample-gcp-project/sample-app:e88597bcfb346aa1'
ERROR: (gcloud.beta.run.revisions.list) Non-empty key name expected [metadata.annotations.client.knative.dev *HERE* //user-image=asia.gcr.io/sample-gcp-project/sample-app:e88597bcfb346aa1].

gcloud --format 选项也不适用于反斜杠键。

有什么想法可以帮助过滤带有斜线的键吗?

尝试:

gcloud beta run revisions list \
--service=it-sys-watch \
--region=asia-northeast1 \
--sort-by="~DEPLOYED" \
--filter='metadata.annotations["client.knative.dev/user-image"]="asia.gcr.io/sample-gcp-project/sample-app:e88597bcfb346aa1"'

NOTE You need to drop the --limit=1 too though this conflicts with the documentation that suggests that limit is applied after filter

gcloud ... --filter=... --limit=1 | jq 'length' yields 0

gcloud ... --filter=... | jq 'length' yields 1

Let's see what Google Engineering says: 231192444