@@ -36,6 +36,7 @@ type State interface {
3636 SetShouldSkipEntitlementsAndGrants ()
3737 ShouldSkipGrants () bool
3838 SetShouldSkipGrants ()
39+ GetCompletedActionsCount () uint64
3940}
4041
4142// ActionOp represents a sync operation.
@@ -156,6 +157,7 @@ type state struct {
156157 shouldFetchRelatedResources bool
157158 shouldSkipEntitlementsAndGrants bool
158159 shouldSkipGrants bool
160+ completedActionsCount uint64
159161}
160162
161163// serializedToken is used to serialize the token to JSON. This separate object is used to avoid having exported fields
@@ -169,7 +171,7 @@ type serializedToken struct {
169171 ShouldFetchRelatedResources bool `json:"should_fetch_related_resources,omitempty"`
170172 ShouldSkipEntitlementsAndGrants bool `json:"should_skip_entitlements_and_grants,omitempty"`
171173 ShouldSkipGrants bool `json:"should_skip_grants,omitempty"`
172- ShouldSkipEntitlements bool `json:"should_skip_entitlements ,omitempty"`
174+ CompletedActionsCount uint64 `json:"completed_actions_count ,omitempty"`
173175}
174176
175177// push adds a new action to the stack. If there is no current state, the action is directly set to current, else
@@ -197,6 +199,7 @@ func (st *state) pop() *Action {
197199 }
198200
199201 ret := * st .currentAction
202+ st .completedActionsCount ++
200203
201204 if len (st .actions ) > 0 {
202205 st .currentAction = & st .actions [len (st .actions )- 1 ]
@@ -243,10 +246,12 @@ func (st *state) Unmarshal(input string) error {
243246 st .shouldSkipEntitlementsAndGrants = token .ShouldSkipEntitlementsAndGrants
244247 st .shouldSkipGrants = token .ShouldSkipGrants
245248 st .shouldFetchRelatedResources = token .ShouldFetchRelatedResources
249+ st .completedActionsCount = token .CompletedActionsCount
246250 } else {
247251 st .actions = nil
248252 st .entitlementGraph = nil
249253 st .currentAction = & Action {Op : InitOp }
254+ st .completedActionsCount = 0
250255 }
251256
252257 return nil
@@ -266,6 +271,7 @@ func (st *state) Marshal() (string, error) {
266271 ShouldFetchRelatedResources : st .shouldFetchRelatedResources ,
267272 ShouldSkipEntitlementsAndGrants : st .shouldSkipEntitlementsAndGrants ,
268273 ShouldSkipGrants : st .shouldSkipGrants ,
274+ CompletedActionsCount : st .completedActionsCount ,
269275 })
270276 if err != nil {
271277 return "" , err
@@ -406,3 +412,9 @@ func (st *state) ParentResourceTypeID(ctx context.Context) string {
406412
407413 return c .ParentResourceTypeID
408414}
415+
416+ func (st * state ) GetCompletedActionsCount () uint64 {
417+ st .mtx .RLock ()
418+ defer st .mtx .RUnlock ()
419+ return st .completedActionsCount
420+ }
0 commit comments