Skip to content

Commit

Permalink
chore: remove braces.dev/errtrace dependency
Browse files Browse the repository at this point in the history
- Remove `braces.dev/errtrace` dependency from `go.mod`
- Remove `braces.dev/errtrace` import from `main.go`
- Replace `errtrace.Wrap` with direct `plugin.Exec()` return in `main.go`
- Replace `errtrace.Wrap` with direct error returns in `plugin.go`

Signed-off-by: appleboy <[email protected]>
  • Loading branch information
appleboy committed Jun 27, 2024
1 parent d5eae01 commit e07ead6
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/appleboy/drone-lambda
go 1.19

require (
braces.dev/errtrace v0.3.0
github.com/aws/aws-sdk-go v1.54.7
github.com/gookit/goutil v0.6.15
github.com/joho/godotenv v1.5.1
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
braces.dev/errtrace v0.3.0 h1:pzfd6LcWgfWtXLaNFWRnxV/7NP+FSOlIjRLwDuHfPxs=
braces.dev/errtrace v0.3.0/go.mod h1:YQpXdo+u5iimgQdZzFoic8AjedEDncXGpp6/2SfazzI=
github.com/andybalholm/brotli v1.0.1/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
Expand Down
3 changes: 1 addition & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strconv"
"time"

"braces.dev/errtrace"
"github.com/joho/godotenv"
_ "github.com/joho/godotenv/autoload"
"github.com/urfave/cli/v2"
Expand Down Expand Up @@ -249,5 +248,5 @@ func run(c *cli.Context) error {
},
}

return errtrace.Wrap(plugin.Exec())
return plugin.Exec()
}
23 changes: 11 additions & 12 deletions plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"path/filepath"
"strings"

"braces.dev/errtrace"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/awserr"
"github.com/aws/aws-sdk-go/aws/credentials"
Expand Down Expand Up @@ -89,7 +88,7 @@ func (p Plugin) Exec() error { //nolint:gocyclo
p.dump(p.Config)

if p.Config.FunctionName == "" {
return errtrace.Wrap(errors.New("missing lambda function name"))
return errors.New("missing lambda function name")
}

sources := trimValues(p.Config.Source)
Expand All @@ -98,7 +97,7 @@ func (p Plugin) Exec() error { //nolint:gocyclo
len(sources) == 0 &&
p.Config.ZipFile == "" &&
p.Config.ImageURI == "" {
return errtrace.Wrap(errors.New("missing zip source or s3 bucket/key or image uri"))
return errors.New("missing zip source or s3 bucket/key or image uri")
}

// Create Lambda service client
Expand Down Expand Up @@ -157,7 +156,7 @@ func (p Plugin) Exec() error { //nolint:gocyclo
zip := archiver.NewZip()
if len(files) != 0 {
if err := zip.Archive(files, path); err != nil {
return errtrace.Wrap(err)
return err
}

p.Config.ZipFile = path
Expand All @@ -167,7 +166,7 @@ func (p Plugin) Exec() error { //nolint:gocyclo
if p.Config.ZipFile != "" {
contents, err := os.ReadFile(p.Config.ZipFile)
if err != nil {
return errtrace.Wrap(err)
return err
}

input.SetZipFile(contents)
Expand Down Expand Up @@ -235,7 +234,7 @@ func (p Plugin) Exec() error { //nolint:gocyclo
// UpdateFunctionConfiguration API operation for AWS Lambda.
log.Println("Update function configuration ...")
if err := p.checkStatus(svc); err != nil {
return errtrace.Wrap(err)
return err
}
lambdaConfig, err := svc.UpdateFunctionConfiguration(cfg)
if err != nil {
Expand All @@ -261,15 +260,15 @@ func (p Plugin) Exec() error { //nolint:gocyclo
// Message from an error.
log.Println(err.Error())
}
return errtrace.Wrap(err)
return err
}

p.dump(lambdaConfig)
}

log.Println("Update function code ...")
if err := p.checkStatus(svc); err != nil {
return errtrace.Wrap(err)
return err
}
lambdaConfig, err := svc.UpdateFunctionCode(input)
if err != nil {
Expand Down Expand Up @@ -297,7 +296,7 @@ func (p Plugin) Exec() error { //nolint:gocyclo
// Message from an error.
log.Println(err.Error())
}
return errtrace.Wrap(err)
return err
}

p.dump(lambdaConfig)
Expand All @@ -312,7 +311,7 @@ func (p *Plugin) checkStatus(svc *lambda.Lambda) error {
FunctionName: aws.String(p.Config.FunctionName),
})
if err != nil {
return errtrace.Wrap(err)
return err
}
log.Println("Current State:", aws.StringValue(lambdaConfig.State))
if aws.StringValue(lambdaConfig.State) != lambda.StateActive {
Expand All @@ -327,7 +326,7 @@ func (p *Plugin) checkStatus(svc *lambda.Lambda) error {
request.WithWaiterMaxAttempts(p.Config.MaxAttempts),
); err != nil {
log.Println(err.Error())
return errtrace.Wrap(err)
return err
}
}

Expand All @@ -344,7 +343,7 @@ func (p *Plugin) checkStatus(svc *lambda.Lambda) error {
request.WithWaiterMaxAttempts(p.Config.MaxAttempts),
); err != nil {
log.Println(err.Error())
return errtrace.Wrap(err)
return err
}
}

Expand Down

0 comments on commit e07ead6

Please sign in to comment.