Skip to content

Commit

Permalink
feat: add logs for policy ignores
Browse files Browse the repository at this point in the history
  • Loading branch information
davhdavh authored Oct 17, 2024
1 parent 59b2438 commit 09ccaf4
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions plan/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ limitations under the License.

package plan

import (
log "github.com/sirupsen/logrus"
)

// Policy allows to apply different rules to a set of changes.
type Policy interface {
Apply(changes *Changes) *Changes
Expand All @@ -41,6 +45,9 @@ 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 {
log.Debugf(`Skipping deletion of endpoint %v due to "upsert-only" policy`, ep)
}
return &Changes{
Create: changes.Create,
UpdateOld: changes.UpdateOld,
Expand All @@ -53,6 +60,15 @@ 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)
}
return &Changes{
Create: changes.Create,
}
Expand Down

0 comments on commit 09ccaf4

Please sign in to comment.