I am running a command to filter docker images from my ECR repo.
aws ecr list-images --repository-name {name} --filter "tagStatus=TAGGED" --query 'imageIds[?imageTag==
{some string}]' --output json
If no matches are found, the output is an empty array like so:
[]
If matches are found. the output looks something like this:
[
{
"imageDigest": "sha256:b2adff0....",
"imageTag": "latest"
}
]
The goal is to figure out if the tag I am querying for exists in the output.
I thought I could check check if the resulting array was empty by running if [[ ${#IMAGES[0]} == 0 ]]; then
but both outputs have a length of 1.
I'm not a bash expert so any advice would be greatly appreciated.
Thanks!