move dataset to types

This commit is contained in:
AlteredCoder 2020-05-25 15:32:15 +02:00
parent 907674f10c
commit c02cd538b6
2 changed files with 5 additions and 4 deletions

View file

@ -16,6 +16,7 @@ import (
"path/filepath" "path/filepath"
"strings" "strings"
"github.com/crowdsecurity/crowdsec/pkg/types"
"github.com/enescakir/emoji" "github.com/enescakir/emoji"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"gopkg.in/yaml.v2" "gopkg.in/yaml.v2"
@ -751,7 +752,7 @@ func DownloadItem(target Item, tdir string, overwrite bool, dataFolder string) (
log.Infof("Installing : %+v \n", string(body)) log.Infof("Installing : %+v \n", string(body))
dec := yaml.NewDecoder(bytes.NewReader(body)) dec := yaml.NewDecoder(bytes.NewReader(body))
for { for {
data := &dataSet{} data := &types.DataSet{}
err = dec.Decode(data) err = dec.Decode(data)
if err != nil { if err != nil {
if err == io.EOF { if err == io.EOF {
@ -760,7 +761,7 @@ func DownloadItem(target Item, tdir string, overwrite bool, dataFolder string) (
return target, fmt.Errorf("unable to read file %s data: %s", tdir+"/"+target.RemotePath, err) return target, fmt.Errorf("unable to read file %s data: %s", tdir+"/"+target.RemotePath, err)
} }
} }
err = getData(data.Data, dataFolder) err = types.getData(data.Data, dataFolder)
if err != nil { if err != nil {
return target, fmt.Errorf("unable to get data: %s", err) return target, fmt.Errorf("unable to get data: %s", err)
} }

View file

@ -1,4 +1,4 @@
package cwhub package types
import ( import (
"fmt" "fmt"
@ -15,7 +15,7 @@ type dataSource struct {
DestPath string `yaml:"dest_file"` DestPath string `yaml:"dest_file"`
} }
type dataSet struct { type DataSet struct {
Data []*dataSource `yaml:"data",omitempty` Data []*dataSource `yaml:"data",omitempty`
} }