15
15
* to the current version of the project delivered to anyone in the future.
16
16
*/
17
17
18
+ // Package types defines cmdb data syncer types
18
19
package types
19
20
20
21
import (
@@ -38,30 +39,58 @@ const (
38
39
HostRelation ResType = "host_relation"
39
40
// ObjectInstance is the object instance synchronize resource type
40
41
ObjectInstance ResType = "object_instance"
42
+ // QuotedInstance is the quoted instance synchronize resource type
43
+ QuotedInstance ResType = "quoted_instance"
41
44
// InstAsst is the instance association synchronize resource type
42
45
InstAsst ResType = "inst_asst"
46
+ // ServiceInstance is the service instance synchronize resource type
47
+ ServiceInstance ResType = "service_instance"
48
+ // Process is the process synchronize resource type
49
+ Process ResType = "process"
50
+ // ProcessRelation is the process relation synchronize resource type
51
+ ProcessRelation ResType = "process_relation"
43
52
)
44
53
45
- // AllResTypeMap stores all synchronize resource type
46
- var AllResTypeMap = map [ResType ]struct {}{
47
- Biz : {},
48
- Set : {},
49
- Module : {},
50
- Host : {},
51
- HostRelation : {},
52
- ObjectInstance : {},
53
- InstAsst : {},
54
+ var (
55
+ // allResType is all synchronize resource type in the order of dependency
56
+ allResType = []ResType {Biz , ObjectInstance , Set , Module , Host , HostRelation , InstAsst , ServiceInstance , Process ,
57
+ ProcessRelation , QuotedInstance }
58
+ allResTypeMap = make (map [ResType ]struct {})
59
+ )
60
+
61
+ func init () {
62
+ for _ , resType := range allResType {
63
+ allResTypeMap [resType ] = struct {}{}
64
+ }
65
+ }
66
+
67
+ // ListAllResType list all synchronize resource type
68
+ func ListAllResType () []ResType {
69
+ return allResType
70
+ }
71
+
72
+ // ListAllResTypeForIncrSync list all synchronize resource type for incremental sync
73
+ func ListAllResTypeForIncrSync () []ResType {
74
+ incrResTypes := make ([]ResType , 0 )
75
+ for _ , resType := range allResType {
76
+ if resType == QuotedInstance {
77
+ continue
78
+ }
79
+ incrResTypes = append (incrResTypes , resType )
80
+ }
81
+ return incrResTypes
54
82
}
55
83
56
84
// ResTypeWithSubResMap stores all synchronize resource type with sub resource
57
85
var ResTypeWithSubResMap = map [ResType ]struct {}{
58
86
ObjectInstance : {},
59
87
InstAsst : {},
88
+ QuotedInstance : {},
60
89
}
61
90
62
91
// Validate resource type
63
92
func (r ResType ) Validate (subRes string ) ccErr.RawErrorInfo {
64
- _ , exists := AllResTypeMap [r ]
93
+ _ , exists := allResTypeMap [r ]
65
94
if ! exists {
66
95
return ccErr.RawErrorInfo {
67
96
ErrCode : common .CCErrCommParamsIsInvalid ,
0 commit comments