From 50e5f8435c4a1cc1b5ebc9144de0b41318b00679 Mon Sep 17 00:00:00 2001 From: chenshangmin Date: Tue, 14 Sep 2021 20:49:18 +0800 Subject: [PATCH] =?UTF-8?q?[PDR-14800][feat]logkit-pro=E6=94=AF=E6=8C=81.g?= =?UTF-8?q?zip=E6=A0=BC=E5=BC=8F=E6=96=87=E4=BB=B6=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- reader/extract/reader.go | 8 ++++---- reader/read.go | 1 + reader/utils.go | 2 +- sender/sender.go | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 reader/read.go diff --git a/reader/extract/reader.go b/reader/extract/reader.go index 9e7efd0bf..60b37d2f9 100644 --- a/reader/extract/reader.go +++ b/reader/extract/reader.go @@ -57,10 +57,10 @@ func NewReader(meta *reader.Meta, path string, opt Opts) (*Reader, error) { return nil, err } tp = "tar" - } else if strings.HasSuffix(path, ".gz") { + } else if strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".gzip") { rd, err = NewGZ(path, opt) if err != nil { - log.Errorf("New .gz err %v", err) + log.Errorf("New .gz or .gzip err %v", err) return nil, err } tp = "gz" @@ -303,8 +303,8 @@ type GZ struct { } func NewGZ(path string, opt Opts) (*GZ, error) { - if !strings.HasSuffix(path, ".gz") { - return nil, fmt.Errorf("%s is not .gz format", path) + if !(strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".gzip")) { + return nil, fmt.Errorf("%s is not .gz or .gzip format", path) } f, err := os.Open(path) if err != nil { diff --git a/reader/read.go b/reader/read.go new file mode 100644 index 000000000..a6561bbc8 --- /dev/null +++ b/reader/read.go @@ -0,0 +1 @@ +package reader diff --git a/reader/utils.go b/reader/utils.go index 9dd97b1e9..d18fb0b9d 100644 --- a/reader/utils.go +++ b/reader/utils.go @@ -144,7 +144,7 @@ func getTags(tagFile string) (tags map[string]interface{}, err error) { } func CompressedFile(path string) bool { - if strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".tar") || strings.HasSuffix(path, ".zip") { + if strings.HasSuffix(path, ".gzip") || strings.HasSuffix(path, ".gz") || strings.HasSuffix(path, ".tar") || strings.HasSuffix(path, ".zip") { return true } return false diff --git a/sender/sender.go b/sender/sender.go index 6c3a4f1fc..1614760e1 100644 --- a/sender/sender.go +++ b/sender/sender.go @@ -9,6 +9,7 @@ import ( . "github.com/qiniu/logkit/utils/models" ) + // Sender send data to pandora, prometheus such different destinations type Sender interface { Name() string