Skip to content

Commit

Permalink
add missing changes
Browse files Browse the repository at this point in the history
Signed-off-by: ShutingZhao <[email protected]>
  • Loading branch information
realshuting committed Dec 20, 2023
1 parent 89f8958 commit 357caa7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pkg/policy/policy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package policy
import (
"context"
"fmt"
"os"
"time"

"github.com/go-logr/logr"
Expand Down Expand Up @@ -154,6 +155,18 @@ func (pc *policyController) canBackgroundProcess(p kyvernov1.PolicyInterface) bo
return false
}

if p.GetSpec().IsMutateExisting() {
val := os.Getenv("BACKGROUND_SCAN_INTERVAL")
interval, err := time.ParseDuration(val)
if err != nil {
logger.Error(err, "failed to parse BACKGROUND_SCAN_INTERVAL env variable, skip[ing the policy event")
return false
}
if p.GetCreationTimestamp().Add(interval).After(time.Now()) {
return p.GetSpec().GetMutateExistingOnPolicyUpdate()
}
}

return true
}

Expand Down

0 comments on commit 357caa7

Please sign in to comment.