"compress/gzip"
"context"
"fmt"
- jsoniter "github.com/json-iterator/go"
- "github.com/minio/minio-go/v7"
- "github.com/minio/minio-go/v7/pkg/credentials"
- log "github.com/sirupsen/logrus"
"io"
"main/common/dataTypes"
"main/components/xmltransform"
"os"
"strings"
"time"
+
+ jsoniter "github.com/json-iterator/go"
+ "github.com/minio/minio-go/v7"
+ "github.com/minio/minio-go/v7/pkg/credentials"
+ log "github.com/sirupsen/logrus"
)
-func Xml_to_json_conv(evt_data *dataTypes.XmlFileEventHeader) string {
+// nolint
+func XmlToJsonConv(evtData *dataTypes.XmlFileEventHeader) string {
filestoreUser := os.Getenv("FILESTORE_USER")
filestorePwd := os.Getenv("FILESTORE_PWD")
filestoreServer := os.Getenv("FILESTORE_SERVER")
log.Fatalln(err)
}
expiry := time.Second * 24 * 60 * 60 // 1 day.
- objectName := evt_data.Name
- bucketName := evt_data.ObjectStoreBucket
- compresion := evt_data.Compression
+ objectName := evtData.Name
+ bucketName := evtData.ObjectStoreBucket
+ compresion := evtData.Compression
reqParams := make(url.Values)
- xmlh, err := jsoniter.Marshal(evt_data)
+ xmlh, err := jsoniter.Marshal(evtData)
if err != nil {
fmt.Printf("Error: %s", err)
return ""
if err != nil {
log.Fatalln(err)
}
- file_bytes := xmltransform.Convert(presignedURL.String(), compresion, string(xmlh))
+ fileBytes := xmltransform.Convert(presignedURL.String(), compresion, string(xmlh))
newObjectName := objectName + "kafka-producer-pm-xml2json-0.json.gz"
var buf bytes.Buffer
- err = gzipWrite(&buf, &file_bytes)
- upload_object(s3Client, buf.Bytes(), newObjectName, "pm-files-json")
+ err = gzipWrite(&buf, &fileBytes)
+ uploadObject(s3Client, buf.Bytes(), newObjectName, "pm-files-json")
fmt.Println("")
return newObjectName
}
-func upload_object(mc *minio.Client, b []byte, objectName string, fsbucket string) {
+// nolint
+func uploadObject(mc *minio.Client, b []byte, objectName string, fsbucket string) {
contentType := "application/json"
if strings.HasSuffix(objectName, ".gz") {
contentType = "application/gzip"
// Upload the xml file with PutObject
r := bytes.NewReader(b)
tctx := context.Background()
- if check_minio_bucket(mc, fsbucket) == false {
- err := create_minio_bucket(mc, fsbucket)
+ if checkMinioBucket(mc, fsbucket) == false {
+ err := createMinioBucket(mc, fsbucket)
if err != nil {
log.Error("Cannot create bucket: ", fsbucket, ", ", err)
return
}
}
-func create_minio_bucket(mc *minio.Client, bucket string) error {
+// nolint
+func createMinioBucket(mc *minio.Client, bucket string) error {
tctx := context.Background()
err := mc.MakeBucket(tctx, bucket, minio.MakeBucketOptions{})
if err != nil {
return nil
}
-func check_minio_bucket(mc *minio.Client, bucket string) bool {
+// nolint
+func checkMinioBucket(mc *minio.Client, bucket string) bool {
tctx := context.Background()
exists, err := mc.BucketExists(tctx, bucket)
if err == nil && exists {
}
// Write gzipped data to a Writer
+// nolint
func gzipWrite(w io.Writer, data *[]byte) error {
gw, err1 := gzip.NewWriterLevel(w, gzip.BestSpeed)