@@ -27,7 +27,7 @@ type ImportOptions struct {
27
27
}
28
28
29
29
// Parse parse an exportentities.workflow and return the parsed workflow
30
- func Parse (ctx context.Context , proj sdk.Project , ew exportentities.Workflow ) (* sdk.Workflow , error ) {
30
+ func Parse (ctx context.Context , proj sdk.Project , oldW * sdk. Workflow , ew exportentities.Workflow ) (* sdk.Workflow , error ) {
31
31
log .Info (ctx , "Parse>> Parse workflow %s in project %s" , ew .GetName (), proj .Key )
32
32
log .Debug (ctx , "Parse>> Workflow: %+v" , ew )
33
33
@@ -39,11 +39,17 @@ func Parse(ctx context.Context, proj sdk.Project, ew exportentities.Workflow) (*
39
39
w .ProjectID = proj .ID
40
40
w .ProjectKey = proj .Key
41
41
42
- // Get permission from project if needed
43
- if len (w .Groups ) == 0 {
42
+ // Get permission from old workflow if needed
43
+ if oldW != nil && len (w .Groups ) == 0 {
44
+ w .Groups = make ([]sdk.GroupPermission , 0 , len (oldW .Groups ))
45
+ for _ , g := range oldW .Groups {
46
+ perm := sdk.GroupPermission {Group : sdk.Group {Name : g .Group .Name }, Permission : g .Permission }
47
+ w .Groups = append (w .Groups , perm )
48
+ }
49
+ } else if len (w .Groups ) == 0 {
44
50
w .Groups = make ([]sdk.GroupPermission , 0 , len (proj .ProjectGroups ))
45
- for _ , gp := range proj .ProjectGroups {
46
- perm := sdk.GroupPermission {Group : sdk.Group {Name : gp .Group .Name }, Permission : gp .Permission }
51
+ for _ , g := range proj .ProjectGroups {
52
+ perm := sdk.GroupPermission {Group : sdk.Group {Name : g .Group .Name }, Permission : g .Permission }
47
53
w .Groups = append (w .Groups , perm )
48
54
}
49
55
}
@@ -58,7 +64,7 @@ func ParseAndImport(ctx context.Context, db gorpmapper.SqlExecutorWithTx, store
58
64
log .Info (ctx , "ParseAndImport>> Import workflow %s in project %s (force=%v)" , ew .GetName (), proj .Key , opts .Force )
59
65
60
66
//Parse workflow
61
- w , err := Parse (ctx , proj , ew )
67
+ w , err := Parse (ctx , proj , oldW , ew )
62
68
if err != nil {
63
69
return nil , nil , err
64
70
}
0 commit comments