Skip to content

Commit

Permalink
added kuttl test and linter fix
Browse files Browse the repository at this point in the history
Signed-off-by: SANSKARJAIN2 <[email protected]>
  • Loading branch information
SANSKARJAIN2 committed Nov 16, 2022
1 parent f320904 commit c9a02bd
Show file tree
Hide file tree
Showing 14 changed files with 120 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/webhooks/resource/generation/generation.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ func (h *generationHandler) handleUpdateGenerateTargetResource(request *admissio
h.log.Error(err, "failed to convert object resource to unstructured format")
return
}
var policyKind = kyvernov1beta1.PolicyKindCluster
policyKind := kyvernov1beta1.PolicyKindCluster
policyName := resLabels["policy.kyverno.io/policy-name"]

if resLabels["policy.kyverno.io/policy-kind"] == kyvernov1beta1.PolicyKindNamespace {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- manifests.yaml
- namespace-policy.yaml
assert:
- namespace-policy-ready.yaml
- required-resources-ready.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- configmap.yaml
assert:
- resource-assert.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: kuttl.dev/v1beta1
kind: TestStep
apply:
- update-generated-resource.yaml
assert:
- synchronized-generated-resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

apiVersion: kuttl.dev/v1beta1
kind: TestStep
commands:
- command: kubectl delete -f manifests.yaml --force --wait=true --ignore-not-found=true
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
data:
test: test
kind: ConfigMap
metadata:
name: cm-2
namespace: poltest
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

apiVersion: v1
kind: Namespace
metadata:
name: poltest
---
apiVersion: v1
data:
foo: YmFy
kind: Secret
metadata:
name: regcred
namespace: poltest
type: Opaque
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: kyverno.io/v1
kind: Policy
metadata:
name: pol-sync-clone
namespace: poltest
status:
conditions:
- reason: Succeeded
status: "True"
type: Ready
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
apiVersion: kyverno.io/v2beta1
kind: Policy
metadata:
name: pol-sync-clone
namespace: poltest
spec:
rules:
- name: gen-zk
match:
any:
- resources:
kinds:
- ConfigMap
generate:
apiVersion: v1
kind: Secret
name: myclonedsecret
namespace: poltest
synchronize: true
clone:
namespace: poltest
name: regcred
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: Secret
metadata:
name: regcred
namespace: poltest
---
apiVersion: v1
kind: Namespace
metadata:
name: poltest
status:
phase: Active
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: cm-2
namespace: poltest
---
apiVersion: v1
kind: Secret
metadata:
name: myclonedsecret
namespace: poltest
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

apiVersion: v1
kind: Secret
data:
foo: YmFy
metadata:
name: myclonedsecret
namespace: poltest
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

apiVersion: v1
data:
foo: dGVzdDIk
kind: Secret
metadata:
name: myclonedsecret
namespace: poltest
type: Opaque
1 change: 1 addition & 0 deletions test/conformance/kuttl/kuttl-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ testDirs:
- ./test/conformance/kuttl/generate/clusterpolicy/standard/data/sync
- ./test/conformance/kuttl/generate/clusterpolicy/standard/data/nosync
- ./test/conformance/kuttl/generate/clusterpolicy/cornercases
- ./test/conformance/kuttl/generate/namespacePolicy/standard/clone/sync/
# Mutate tests
- ./test/conformance/kuttl/mutate/clusterpolicy/standard
- ./test/conformance/kuttl/mutate/clusterpolicy/standard/existing
Expand Down

0 comments on commit c9a02bd

Please sign in to comment.