Skip to content

Commit

Permalink
Close GCS writer on return
Browse files Browse the repository at this point in the history
  • Loading branch information
Milkshak3s committed Apr 14, 2022
1 parent 323fca8 commit 79c04c9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion outputs/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ func (c *Client) UploadGCS(falcopayload types.FalcoPayload) {
}

key := fmt.Sprintf("%s/%s/%s.json", prefix, t.Format("2006-01-02"), t.Format(time.RFC3339Nano))
_, err := c.GCSStorageClient.Bucket(c.Config.GCP.Storage.Bucket).Object(key).NewWriter(context.Background()).Write(payload)
bucketWriter := c.GCSStorageClient.Bucket(c.Config.GCP.Storage.Bucket).Object(key).NewWriter(context.Background())
defer bucketWriter.Close()
_, err := bucketWriter.Write(payload)
if err != nil {
log.Printf("[ERROR] : GCPStorage - %v - %v\n", "Error while Uploading message", err.Error())
c.Stats.GCPStorage.Add(Error, 1)
Expand Down

0 comments on commit 79c04c9

Please sign in to comment.