Skip to content

Commit

Permalink
createdb review fixes 7970
Browse files Browse the repository at this point in the history
  • Loading branch information
nadavsteindler committed Aug 1, 2024
1 parent ba796d9 commit dec212a
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/actions/lua/storage/aws/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"encoding/json"
"errors"

Check failure on line 6 in pkg/actions/lua/storage/aws/glue.go

View workflow job for this annotation

GitHub Actions / Run Linters and Checkers

File is not `goimports`-ed (goimports)

"github.com/Shopify/go-lua"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
Expand Down Expand Up @@ -233,7 +232,7 @@ func createDatabase(c *GlueClient) lua.Function {

var createDBInput *glue.CreateDatabaseInput
errorOnAlreadyExists := true
if !l.IsNone(2) {
if !l.IsNoneOrNil(2) {
lua.CheckType(l, 2, lua.TypeTable)
l.Field(2, "error_on_already_exists")
l.Field(2, "create_db_input")
Expand Down Expand Up @@ -266,7 +265,7 @@ func createDatabase(c *GlueClient) lua.Function {
// AWS API call
_, err := client.CreateDatabase(c.ctx, createDBInput)
if err != nil {
if !errorOnAlreadyExists {
if !errorOnAlreadyExists && isAlreadyExistsErr(err) {
return 0
}
lua.Errorf(l, "%s", err.Error())
Expand All @@ -276,6 +275,11 @@ func createDatabase(c *GlueClient) lua.Function {
}
}

func isAlreadyExistsErr(err error) bool {
var errExists *types.AlreadyExistsException
return errors.As(err, &errExists)
}

func deleteDatabase(c *GlueClient) lua.Function {
return func(l *lua.State) int {
client := c.client()
Expand Down

0 comments on commit dec212a

Please sign in to comment.