Skip to content

Commit

Permalink
fix: wrong ecr image check logic (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyunsuk Shin authored Dec 19, 2023
1 parent cd445da commit 1e4c83e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions controllers/resources/bentorequest_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import (
yataiclient "github.com/bentoml/yatai-image-builder/yatai-client"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ecr"
)
Expand Down Expand Up @@ -949,13 +950,18 @@ func CheckECRImageExists(imageName string) (bool, error) {
},
}

result, err := svc.DescribeImages(input)
_, err = svc.DescribeImages(input)
if err != nil {
var awsErr awserr.Error
if errors.As(err, &awsErr) {
if awsErr.Code() == "ImageNotFoundException" {
return false, nil
}
}
return false, errors.Wrap(err, "describe ECR images")
}

// If result contains any images, the specified image exists.
return len(result.ImageDetails) > 0, nil
return true, nil
}

type BentoImageBuildEngine string
Expand Down

0 comments on commit 1e4c83e

Please sign in to comment.