如何解决AWS ECR ListImages结果的顺序奇怪
我正在尝试使用ListImages从AWS ECR获取最近推送的最近5张图像的列表。但是,我观察到结果的排序不是我期望的。
例如:
我有一个具有以下标记的ECR存储库some-service
:0.1.0
,0.2.0
... 0.6.0
,0.6.1
,它们已被推送按按时间顺序的顺序。
当我尝试列出图像的标签时,AWS ECR以某种方式给了我奇怪的排序。
$ aws ecr list-images --repository-name some-service | jq '.imageIds[] | .imageTag'
"0.3.0"
"0.6.1"
"0.3.1"
"0.2.0"
"0.6.2"
"0.6.0"
"0.4.0"
"0.1.0"
"0.5.0"
当我尝试使用maxResults
时,结果一致:
$ aws ecr list-images --max-results 5 --repository-name some-service | jq '.imageIds[] | .imageTag'
"0.3.0"
"0.6.1"
"0.3.1"
"0.2.0"
"0.6.2"
排序似乎与DescribeImages一致。我试图查看API使用了哪些数据作为排序键,但找不到任何数据。
$ aws ecr describe-images --max-result 5 \
--repository-name some-service \
| jq '.imageDetails[] | {imageTags,imageDigest,imageSizeInBytes,imagePushedAt}'
{
"imageTags": [
"0.3.0"
],"imageDigest": "sha256:4497e8d...","imageSizeInBytes": 190502899,"imagePushedAt": "2020-05-20T15:58:32+07:00"
}
{
"imageTags": [
"0.6.1"
],"imageDigest": "sha256:45a1be8...","imageSizeInBytes": 218137213,"imagePushedAt": "2020-07-27T18:48:05+07:00"
}
{
"imageTags": [
"0.3.1"
],"imageDigest": "sha256:4b96a8ab...","imageSizeInBytes": 190502957,"imagePushedAt": "2020-06-18T17:30:52+07:00"
}
{
"imageTags": [
"0.2.0"
],"imageDigest": "sha256:168e14fb6...","imageSizeInBytes": 193764109,"imagePushedAt": "2020-05-11T18:57:26+07:00"
}
{
"imageTags": [
"0.6.2"
],"imageDigest": "sha256:2f24f...","imageSizeInBytes": 218146252,"imagePushedAt": "2020-08-06T19:43:00+07:00"
}
- 有人在内部知道AWS ECR API如何对图像进行排序吗?
- 是否有一种无需使用
--query
即可实现我想要的功能的方法(因为我实际上是使用AWS Python SDK来完成任务的。)
非常感谢您的时间!
Genzer
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。