-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.go
58 lines (52 loc) · 1.74 KB
/
seed.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
package importutil
import (
"encoding/json"
configV1 "github.com/nlnwa/veidemann-api/go/config/v1"
)
type SeedDesc struct {
EntityId string `json:"entityId,omitempty" yaml:"entityId,omitempty"`
EntityName string `json:"entityName,omitempty" yaml:"entityName,omitempty"`
EntityDescription string `json:"entityDescription,omitempty" yaml:"entityDescription,omitempty"`
EntityLabel []*configV1.Label `json:"entityLabel,omitempty" yaml:"entityLabel,omitempty"`
Uri string `json:"uri,omitempty" yaml:"uri,omitempty"`
SeedDescription string `json:"seedDescription,omitempty" yaml:"seedDescription,omitempty"`
SeedLabel []*configV1.Label `json:"seedLabel,omitempty" yaml:"seedLabel,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
CrawlJobRef []*configV1.ConfigRef
}
func (sd *SeedDesc) String() string {
b, _ := json.Marshal(sd)
return string(b)
}
func (sd *SeedDesc) ToEntity() *configV1.ConfigObject {
return &configV1.ConfigObject{
ApiVersion: "v1",
Kind: configV1.Kind_crawlEntity,
Id: sd.EntityId,
Meta: &configV1.Meta{
Name: sd.EntityName,
Description: sd.EntityDescription,
Label: sd.EntityLabel,
},
}
}
func (sd *SeedDesc) ToSeed() *configV1.ConfigObject {
return &configV1.ConfigObject{
ApiVersion: "v1",
Kind: configV1.Kind_seed,
Meta: &configV1.Meta{
Name: sd.Uri,
Description: sd.SeedDescription,
Label: sd.SeedLabel,
},
Spec: &configV1.ConfigObject_Seed{
Seed: &configV1.Seed{
EntityRef: &configV1.ConfigRef{
Kind: configV1.Kind_crawlEntity,
Id: sd.EntityId,
},
JobRef: sd.CrawlJobRef,
},
},
}
}