mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-31 03:45:17 +00:00
e2e test for mutate policy (#3383)
Signed-off-by: slayer321 <sachin.maurya7666@gmail.com> Signed-off-by: slayer321 <sachin.maurya7666@gmail.com>
This commit is contained in:
parent
c74209f6c5
commit
bec5632344
3 changed files with 61 additions and 1 deletions
|
@ -108,6 +108,16 @@ var tests = []struct {
|
|||
ResourceRaw: kyverno_2971_resource,
|
||||
ExpectedPatternRaw: kyverno_2971_pattern,
|
||||
},
|
||||
{
|
||||
TestDescription: "checks if the imagePullSecrets is set or not",
|
||||
PolicyName: "set-image-pull-secret",
|
||||
PolicyRaw: setImagePullSecret,
|
||||
ResourceName: "nginx",
|
||||
ResourceNamespace: "test-run",
|
||||
ResourceGVR: podGVR,
|
||||
ResourceRaw: podWithNoSecrets,
|
||||
ExpectedPatternRaw: podWithNoSecretPattern,
|
||||
},
|
||||
{
|
||||
TestDescription: "checks the global anchor variables for emptyDir",
|
||||
PolicyName: "add-safe-to-evict",
|
||||
|
|
|
@ -112,7 +112,7 @@ func Test_Mutate_Sets(t *testing.T) {
|
|||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(cmRes.GetLabels()["kyverno.key/copy-me"]).To(Equal("sample-value"))
|
||||
|
||||
//CleanUp Resources
|
||||
// CleanUp Resources
|
||||
e2eClient.CleanClusterPolicies(policyGVR)
|
||||
|
||||
// Clear Namespace
|
||||
|
|
|
@ -625,6 +625,56 @@ spec:
|
|||
<(path): "*"
|
||||
`)
|
||||
|
||||
var setImagePullSecret = []byte(`
|
||||
apiVersion: kyverno.io/v1
|
||||
kind: ClusterPolicy
|
||||
metadata:
|
||||
name: set-image-pull-secret
|
||||
spec:
|
||||
background: false
|
||||
rules:
|
||||
- name: set-image-pull-secret
|
||||
match:
|
||||
resources:
|
||||
kinds:
|
||||
- Pod
|
||||
mutate:
|
||||
patchStrategicMerge:
|
||||
spec:
|
||||
containers:
|
||||
# match images that are from our registry
|
||||
- <(image): "registry.corp.com/*"
|
||||
# set the imagePullSecrets
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
`)
|
||||
|
||||
var podWithNoSecrets = []byte(`
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: test-run
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: registry.corp.com/nginx:1.14.2
|
||||
`)
|
||||
|
||||
var podWithNoSecretPattern = []byte(`
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: nginx
|
||||
namespace: test-run
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: registry.corp.com/nginx:1.14.2
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
`)
|
||||
|
||||
var podWithEmptyDirAsVolume = []byte(`
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
|
|
Loading…
Add table
Reference in a new issue