1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-04-08 18:15:48 +00:00

NK-31: Implemented the application of policies in order of their creation timestamps.

This commit is contained in:
belyshevdenis 2019-03-13 12:57:04 +02:00
parent 85c84046af
commit 647985ed80

View file

@ -4,6 +4,7 @@ import (
"errors"
"log"
"os"
"sort"
"time"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@ -82,6 +83,10 @@ func (c *PolicyController) GetPolicies() []types.Policy {
policies = append(policies, *elem.DeepCopy())
}
sort.Slice(policies, func(i, j int) bool {
return policies[i].CreationTimestamp.Time.Before(policies[j].CreationTimestamp.Time)
})
return policies
}