forked from tencentyun/tsf-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
laneRule.go
61 lines (54 loc) · 1.64 KB
/
laneRule.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
package lane
import (
"time"
"github.com/bjxujiang/tsf-go/pkg/sys/tag"
)
type LaneRule struct {
ID string `yaml:"ruleId"` //本身LaneRule的ID
Name string `yaml:"ruleName"`
Enable bool `yaml:"enable"`
LaneID string `yaml:"laneId"` //对于的泳道信息的ID,不是LaneRuleID
Priority int64 `yaml:"priority"`
TagList []TagRule `yaml:"ruleTagList"`
Relationship string `yaml:"ruleTagRelationship"`
CreateTime time.Time `yaml:"createTime"`
}
type TagRule struct {
ID string `yaml:"tagId"` //本身tag的ID
Name string `yaml:"tagName"`
Operator string `yaml:"tagOperator"`
Value string `yaml:"tagValue"`
}
func (rule LaneRule) toCommonTagRule() tag.Rule {
var tagRule tag.Rule
tagRule.ID = rule.ID
if rule.Relationship == "RELEATION_OR" {
tagRule.Expression = tag.OR
} else {
tagRule.Expression = tag.AND
}
for _, routeTag := range rule.TagList {
var t tag.Tag
t.Field = routeTag.Name
t.Operator = routeTag.Operator
t.Type = tag.TypeUser
t.Value = routeTag.Value
tagRule.Tags = append(tagRule.Tags, t)
}
return tagRule
}
type LaneInfo struct {
ID string `yaml:"laneId"`
Name string `yaml:"laneName"`
GroupList []LaneGroup `yaml:"laneGroupList"`
CreateTime time.Time `yaml:"createTime"`
}
type LaneGroup struct {
ApplicationID string `yaml:"applicationId"`
ApplicationName string `yaml:"applicationName"`
ClusterType string `yaml:"clusterType"`
Entrance bool `yaml:"entrance"`
GroupID string `yaml:"groupId"`
NamespaceID string `yaml:"namespaceId"`
GroupName string `yaml:"groupName"`
}