Skip to content

Commit

Permalink
chore: move cache enabled label (kyverno#7949)
Browse files Browse the repository at this point in the history
Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Aug 1, 2023
1 parent 9516f45 commit 9dd618c
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 8 deletions.
1 change: 1 addition & 0 deletions api/kyverno/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const (
// Well known labels
LabelAppManagedBy = "app.kubernetes.io/managed-by"
LabelAppComponent = "app.kubernetes.io/component"
LabelCacheEnabled = "cache.kyverno.io/enabled"
LabelCertManagedBy = "cert.kyverno.io/managed-by"
LabelWebhookManagedBy = "webhook.kyverno.io/managed-by"
// Well known annotations
Expand Down
5 changes: 0 additions & 5 deletions pkg/engine/context/resolvers/constants.go

This file was deleted.

3 changes: 2 additions & 1 deletion pkg/engine/context/resolvers/resolvers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"testing"
"time"

"github.com/kyverno/kyverno/api/kyverno"
"github.com/kyverno/kyverno/pkg/engine/api"
"gotest.tools/assert"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -34,7 +35,7 @@ func createConfigMaps(ctx context.Context, client *kubefake.Clientset, addLabel
Data: map[string]string{"configmapkey": "key1"},
}
if addLabel {
cm.ObjectMeta.Labels = map[string]string{LabelCacheKey: "true"}
cm.ObjectMeta.Labels = map[string]string{kyverno.LabelCacheEnabled: "true"}
}
_, err := client.CoreV1().ConfigMaps(namespace).Create(
ctx, cm, metav1.CreateOptions{})
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/context/resolvers/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"errors"
"time"

"github.com/kyverno/kyverno/api/kyverno"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/selection"
Expand All @@ -13,7 +14,7 @@ import (

func GetCacheSelector() (labels.Selector, error) {
selector := labels.Everything()
requirement, err := labels.NewRequirement(LabelCacheKey, selection.Exists, nil)
requirement, err := labels.NewRequirement(kyverno.LabelCacheEnabled, selection.Exists, nil)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion pkg/engine/context/resolvers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/kyverno/kyverno/api/kyverno"
"k8s.io/client-go/kubernetes"
)

Expand All @@ -15,7 +16,7 @@ func TestGetCacheSelector(t *testing.T) {
wantErr bool
}{{
name: "ok",
want: LabelCacheKey,
want: kyverno.LabelCacheEnabled,
}}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 9dd618c

Please sign in to comment.