From abef61e5f9251ec16c0d4260abee7a748cbd6c79 Mon Sep 17 00:00:00 2001 From: Don Date: Wed, 17 Jun 2020 09:18:55 -0700 Subject: [PATCH] Add additional logging --- go.mod | 1 + plugin/impl.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/go.mod b/go.mod index 65b1188..a062ba3 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.14 require ( github.com/drone-plugins/drone-plugin-lib v0.3.1 github.com/joho/godotenv v1.3.0 + github.com/sirupsen/logrus v1.6.0 github.com/urfave/cli/v2 v2.2.0 golang.org/x/sys v0.0.0-20200519105757-fe76b779f299 // indirect ) diff --git a/plugin/impl.go b/plugin/impl.go index a84eecb..b58b0ea 100644 --- a/plugin/impl.go +++ b/plugin/impl.go @@ -17,6 +17,8 @@ import ( "path" "path/filepath" "strings" + + "github.com/sirupsen/logrus" ) // Settings for the plugin. @@ -84,6 +86,11 @@ func (p *Plugin) Execute() error { return nil } + logrus.WithFields(logrus.Fields{ + "source": p.settings.Source, + "destination": p.settings.destination, + }).Info("Downloading file") + resp, err := client.Do(req) if err != nil { return fmt.Errorf("executing request failed: %w", err) @@ -106,17 +113,21 @@ func (p *Plugin) Execute() error { } var h hash.Hash + alg := "" exp := "" if p.settings.SHA256 != "" { exp = p.settings.SHA256 + alg = "SHA256" h = sha256.New() } else if p.settings.MD5 != "" { exp = p.settings.MD5 + alg = "MD5" h = md5.New() } if exp != "" { + logrus.WithField("hash", alg).Info("Computing checksum") target.Seek(0, 0) if _, err := io.Copy(h, target); err != nil { @@ -130,6 +141,7 @@ func (p *Plugin) Execute() error { defer os.Remove(target.Name()) return fmt.Errorf("checksum doesn't match, got %s and expected %s", check, exp) } + logrus.WithField("checksum", check).Info("Checksum matched") } return nil