Skip to content

Commit

Permalink
fix: add check for log level
Browse files Browse the repository at this point in the history
  • Loading branch information
davhdavh authored Oct 30, 2024
1 parent 09ccaf4 commit 426ba9d
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions plan/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ type UpsertOnlyPolicy struct{}

// Apply applies the upsert-only policy which strips out any deletions.
func (p *UpsertOnlyPolicy) Apply(changes *Changes) *Changes {
for _, ep := range changes.Delete {
if log.GetLevel() == log.DebugLevel {
for _, ep := range changes.Delete {
log.Debugf(`Skipping deletion of endpoint %v due to "upsert-only" policy`, ep)
}
}
return &Changes{
Create: changes.Create,
Expand All @@ -60,14 +62,16 @@ type CreateOnlyPolicy struct{}

// Apply applies the create-only policy which strips out updates and deletions.
func (p *CreateOnlyPolicy) Apply(changes *Changes) *Changes {
for _, ep := range changes.Delete {
log.Debugf(`Skipping deletion of endpoint %v due to "create-only" policy`, ep)
}
for _, ep := range changes.UpdateOld {
log.Debugf(`Skipping update-old of endpoint %v due to "create-only" policy`, ep)
}
for _, ep := range changes.UpdateNew {
log.Debugf(`Skipping update-new of endpoint %v due to "create-only" policy`, ep)
if log.GetLevel() == log.DebugLevel {
for _, ep := range changes.Delete {
log.Debugf(`Skipping deletion of endpoint %v due to "create-only" policy`, ep)
}
for _, ep := range changes.UpdateOld {
log.Debugf(`Skipping update-old of endpoint %v due to "create-only" policy`, ep)
}
for _, ep := range changes.UpdateNew {
log.Debugf(`Skipping update-new of endpoint %v due to "create-only" policy`, ep)
}
}
return &Changes{
Create: changes.Create,
Expand Down

0 comments on commit 426ba9d

Please sign in to comment.