用gcloud --filter进行模式匹配

时间:2019-10-25 09:30:13

标签: gcloud

我想获取与特定模式匹配的标签列表,并使用以下命令执行此操作:

gcloud container images list-tags gcr.io/project/reposiory --format="json" --filter="tags:*_master"

但我收到此警告:

WARNING: --filter : operator evaluation is changing for consistency across Google APIs. tags:*_master currently matches but will not match in the near future. Run `gcloud topic filters` for details.

我已经搜索了一下,但是找不到前进的方向。有人知道我如何以这种方式匹配模式,即所有以“ _master”结尾的标签吗?

2 个答案:

答案 0 :(得分:1)

documentation中所述,您可以使用正则表达式。

要使用正则表达式,请使用--filter="key ~ value。在这种情况下,key将是“标签”。对于value,您需要匹配以'_master'结尾的任何内容。您可以在正则表达式中使用$来锚定到字符串的末尾。

结合所有这些,您的新过滤器将是:--filter="tags ~ _master$"

答案 1 :(得分:0)

来自 Documentation 。您的警告消息是由于以下原因引起的:

  

为了确保各个Google API的一致性,运营商评估正在发生变化。当前默认值已弃用,不久将被删除。当--filter表达式将使用已弃用的实现和新实现返回不同的匹配项时,将显示警告。

请参考前面提到的 documentation ,以确保您使用的是正确的匹配项。