releaser(aws): remove type assertion on errors

Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
This commit is contained in:
CrazyMax 2024-11-07 10:51:16 +01:00
parent fbf879c97f
commit b759ac65bb
No known key found for this signature in database
GPG Key ID: ADE44D8C9D44FBE4
1 changed files with 4 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"archive/zip"
"bytes"
"encoding/json"
"errors"
"fmt"
"log"
"os"
@ -143,13 +144,14 @@ func (s *AwsCloudfrontUpdateCmd) Run() error {
FunctionName: aws.String(s.Function),
})
if err != nil {
if aerr, ok := err.(awserr.Error); ok && aerr.Code() != lambda.ErrCodeResourceNotFoundException {
var aerr awserr.Error
if errors.As(err, &aerr) && aerr.Code() != lambda.ErrCodeResourceNotFoundException {
return fmt.Errorf("cannot find lambda function %q: %w", s.Function, err)
}
_, err = svc.CreateFunction(&lambda.CreateFunctionInput{
FunctionName: aws.String(s.Function),
})
if aerr, ok := err.(awserr.Error); ok && aerr.Code() != lambda.ErrCodeResourceConflictException {
if errors.As(err, &aerr) && aerr.Code() != lambda.ErrCodeResourceConflictException {
return err
}
}