-
Notifications
You must be signed in to change notification settings - Fork 0
/
jq_service_parser.go
113 lines (110 loc) · 2.75 KB
/
jq_service_parser.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
package opslevel_jq_parser
type JQServiceParser struct {
aliases *JQArrayParser
description *JQFieldParser
framework *JQFieldParser
language *JQFieldParser
lifecycle *JQFieldParser
name *JQFieldParser
owner *JQFieldParser
product *JQFieldParser
properties JQDictParser
repositories *JQRepositoryParser
system *JQFieldParser
tags *JQTagsParser
tier *JQFieldParser
tools *JQToolsParser
}
func NewJQServiceParser(cfg ServiceRegistrationConfig) *JQServiceParser {
return &JQServiceParser{
aliases: NewJQArrayParser(cfg.Aliases),
description: NewJQFieldParser(cfg.Description),
framework: NewJQFieldParser(cfg.Framework),
language: NewJQFieldParser(cfg.Language),
lifecycle: NewJQFieldParser(cfg.Lifecycle),
name: NewJQFieldParser(cfg.Name),
owner: NewJQFieldParser(cfg.Owner),
product: NewJQFieldParser(cfg.Product),
properties: NewJQDictParser(cfg.Properties),
repositories: NewJQRepositoryParser(cfg.Repositories),
system: NewJQFieldParser(cfg.System),
tags: NewJQTagsParser(cfg.Tags),
tier: NewJQFieldParser(cfg.Tier),
tools: NewJQToolsParser(cfg.Tools),
}
}
func (p *JQServiceParser) Run(json string) (*ServiceRegistration, error) {
aliases, err := p.aliases.Run(json)
if err != nil {
return nil, err
}
description, err := p.description.Run(json)
if err != nil {
return nil, err
}
framework, err := p.framework.Run(json)
if err != nil {
return nil, err
}
language, err := p.language.Run(json)
if err != nil {
return nil, err
}
lifecycle, err := p.lifecycle.Run(json)
if err != nil {
return nil, err
}
name, err := p.name.Run(json)
if err != nil {
return nil, err
}
owner, err := p.owner.Run(json)
if err != nil {
return nil, err
}
product, err := p.product.Run(json)
if err != nil {
return nil, err
}
properties, err := p.properties.Run(json)
if err != nil {
return nil, err
}
repositories, err := p.repositories.Run(json)
if err != nil {
return nil, err
}
system, err := p.system.Run(json)
if err != nil {
return nil, err
}
tagCreates, tagAssigns, err := p.tags.Run(json)
if err != nil {
return nil, err
}
tier, err := p.tier.Run(json)
if err != nil {
return nil, err
}
tools, err := p.tools.Run(json)
if err != nil {
return nil, err
}
return &ServiceRegistration{
Aliases: aliases,
Description: description,
Framework: framework,
Language: language,
Lifecycle: lifecycle,
Name: name,
Owner: owner,
Product: product,
Properties: properties,
Repositories: repositories,
System: system,
TagAssigns: tagAssigns,
TagCreates: tagCreates,
Tier: tier,
Tools: tools,
}, nil
}