Skip to content

Commit 0b4f5e2

Browse files
committed
split config in two parts
1 parent bb71350 commit 0b4f5e2

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

bundle/direct/bundle_plan.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ func addPerFieldActions(ctx context.Context, adapter *dresources.Adapter, change
379379
// Empty map in config should not cause drift when remote has values
380380
ch.Action = deployplan.Skip
381381
ch.Reason = deployplan.ReasonEmptyMap
382-
} else if action := getActionFromConfig(cfg, pathString); action != deployplan.Undefined {
382+
} else if action := shouldIgnore(cfg, pathString); action != deployplan.Undefined {
383383
ch.Action = action
384384
ch.Reason = deployplan.ReasonBuiltinRule
385385
} else if ch.New == nil && ch.Old == nil && ch.Remote != nil && path.IsDotString() {
@@ -389,6 +389,9 @@ func addPerFieldActions(ctx context.Context, adapter *dresources.Adapter, change
389389
// Note, we only consider struct fields here. Adding/removing elements to/from maps and slices should trigger updates.
390390
ch.Action = deployplan.Skip
391391
ch.Reason = deployplan.ReasonServerSideDefault
392+
} else if action := shouldUpdateOrRecreate(cfg, pathString); action != deployplan.Undefined {
393+
ch.Action = action
394+
ch.Reason = deployplan.ReasonBuiltinRule
392395
} else {
393396
ch.Action = deployplan.Update
394397
}
@@ -402,9 +405,7 @@ func addPerFieldActions(ctx context.Context, adapter *dresources.Adapter, change
402405
return nil
403406
}
404407

405-
// getActionFromConfig returns the action for a field path based on resource config.
406-
// Returns Undefined if no config applies.
407-
func getActionFromConfig(cfg *dresources.ResourceLifecycleConfig, pathString string) deployplan.ActionType {
408+
func shouldIgnore(cfg *dresources.ResourceLifecycleConfig, pathString string) deployplan.ActionType {
408409
if cfg == nil {
409410
return deployplan.Undefined
410411
}
@@ -413,6 +414,13 @@ func getActionFromConfig(cfg *dresources.ResourceLifecycleConfig, pathString str
413414
return deployplan.Skip
414415
}
415416
}
417+
return deployplan.Undefined
418+
}
419+
420+
func shouldUpdateOrRecreate(cfg *dresources.ResourceLifecycleConfig, pathString string) deployplan.ActionType {
421+
if cfg == nil {
422+
return deployplan.Undefined
423+
}
416424
for _, p := range cfg.RecreateOnChanges {
417425
if structpath.HasPrefix(pathString, p.String()) {
418426
return deployplan.Recreate

0 commit comments

Comments
 (0)