Skip to content

Commit

Permalink
fix: unit tests (#112)
Browse files Browse the repository at this point in the history
* fix: unit tests

Signed-off-by: Charles-Edouard Brétéché <[email protected]>

* codegen

Signed-off-by: Charles-Edouard Brétéché <[email protected]>

---------

Signed-off-by: Charles-Edouard Brétéché <[email protected]>
  • Loading branch information
eddycharly authored Oct 17, 2023
1 parent d1987b7 commit 4904d99
Show file tree
Hide file tree
Showing 18 changed files with 323 additions and 358 deletions.
2 changes: 1 addition & 1 deletion pkg/data/data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
func TestCrds(t *testing.T) {
data := Crds()
{
file, err := fs.Stat(data, "crds/json.kyverno.io_policies.yaml")
file, err := fs.Stat(data, "crds/json.kyverno.io_validationpolicies.yaml")
assert.NoError(t, err)
assert.NotNil(t, file)
assert.False(t, file.IsDir())
Expand Down
1 change: 0 additions & 1 deletion pkg/engine/template/kyverno/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ var (
objectFromLists = "object_from_lists"
random = "random"
x509_decode = "x509_decode"
imageNormalize = "image_normalize"
)

func GetBareFunctions() []gojmespath.FunctionEntry {
Expand Down
118 changes: 56 additions & 62 deletions schemas/json/_definitions.json
Original file line number Diff line number Diff line change
Expand Up @@ -16458,8 +16458,8 @@
}
}
},
"io.kyverno.json.v1alpha1.Policy": {
"description": "Policy is the resource that contains the policy definition.",
"io.kyverno.json.v1alpha1.ValidationPolicy": {
"description": "ValidationPolicy is the resource that contains the policy definition.",
"type": "object",
"required": [
"spec"
Expand All @@ -16476,7 +16476,7 @@
"description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
"type": "string",
"enum": [
"Policy"
"ValidationPolicy"
]
},
"metadata": {
Expand All @@ -16496,6 +16496,52 @@
"name"
],
"properties": {
"assert": {
"description": "Assert is used to validate matching resources.",
"type": "object",
"properties": {
"all": {
"description": "All allows specifying resources which will be ANDed.",
"type": "array",
"items": {
"type": "object",
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": "string"
}
}
}
},
"any": {
"description": "Any allows specifying resources which will be ORed.",
"type": "array",
"items": {
"type": "object",
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": "string"
}
}
}
}
}
},
"context": {
"description": "Context defines variables and data sources that can be used during rule execution.",
"type": "array",
Expand Down Expand Up @@ -16561,58 +16607,6 @@
"description": "Name is a label to identify the rule, It must be unique within the policy.",
"type": "string",
"maxLength": 63
},
"validate": {
"description": "Validation is used to validate matching resources.",
"type": "object",
"properties": {
"assert": {
"description": "Assert specifies an overlay-style pattern used to check resources.",
"type": "object",
"properties": {
"all": {
"description": "All allows specifying resources which will be ANDed.",
"type": "array",
"items": {
"type": "object",
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": "string"
}
}
}
},
"any": {
"description": "Any allows specifying resources which will be ORed.",
"type": "array",
"items": {
"type": "object",
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": "string"
}
}
}
}
}
}
}
}
}
}
Expand All @@ -16623,13 +16617,13 @@
"x-kubernetes-group-version-kind": [
{
"group": "json.kyverno.io",
"kind": "Policy",
"kind": "ValidationPolicy",
"version": "v1alpha1"
}
]
},
"io.kyverno.json.v1alpha1.PolicyList": {
"description": "PolicyList is a list of Policy",
"io.kyverno.json.v1alpha1.ValidationPolicyList": {
"description": "ValidationPolicyList is a list of ValidationPolicy",
"type": "object",
"required": [
"items"
Expand All @@ -16643,17 +16637,17 @@
]
},
"items": {
"description": "List of policies. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md",
"description": "List of validationpolicies. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md",
"type": "array",
"items": {
"$ref": "#/definitions/io.kyverno.json.v1alpha1.Policy"
"$ref": "#/definitions/io.kyverno.json.v1alpha1.ValidationPolicy"
}
},
"kind": {
"description": "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
"type": "string",
"enum": [
"PolicyList"
"ValidationPolicyList"
]
},
"metadata": {
Expand All @@ -16664,7 +16658,7 @@
"x-kubernetes-group-version-kind": [
{
"group": "json.kyverno.io",
"kind": "PolicyList",
"kind": "ValidationPolicyList",
"version": "v1alpha1"
}
]
Expand Down
4 changes: 2 additions & 2 deletions schemas/json/all.json
Original file line number Diff line number Diff line change
Expand Up @@ -1492,10 +1492,10 @@
"$ref": "_definitions.json#/definitions/io.k8s.kube-aggregator.pkg.apis.apiregistration.v1.ServiceReference"
},
{
"$ref": "_definitions.json#/definitions/io.kyverno.json.v1alpha1.Policy"
"$ref": "_definitions.json#/definitions/io.kyverno.json.v1alpha1.ValidationPolicy"
},
{
"$ref": "_definitions.json#/definitions/io.kyverno.json.v1alpha1.PolicyList"
"$ref": "_definitions.json#/definitions/io.kyverno.json.v1alpha1.ValidationPolicyList"
}
]
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"description": "Policy is the resource that contains the policy definition.",
"description": "ValidationPolicy is the resource that contains the policy definition.",
"type": "object",
"required": [
"spec"
Expand All @@ -22,7 +22,7 @@
"null"
],
"enum": [
"Policy"
"ValidationPolicy"
]
},
"metadata": {
Expand Down Expand Up @@ -291,6 +291,73 @@
"name"
],
"properties": {
"assert": {
"description": "Assert is used to validate matching resources.",
"type": [
"object",
"null"
],
"properties": {
"all": {
"description": "All allows specifying resources which will be ANDed.",
"type": [
"array",
"null"
],
"items": {
"type": [
"object",
"null"
],
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": [
"string",
"null"
]
}
}
}
},
"any": {
"description": "Any allows specifying resources which will be ORed.",
"type": [
"array",
"null"
],
"items": {
"type": [
"object",
"null"
],
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": [
"string",
"null"
]
}
}
}
}
}
},
"context": {
"description": "Context defines variables and data sources that can be used during rule execution.",
"type": [
Expand Down Expand Up @@ -380,82 +447,6 @@
"description": "Name is a label to identify the rule, It must be unique within the policy.",
"type": "string",
"maxLength": 63
},
"validate": {
"description": "Validation is used to validate matching resources.",
"type": [
"object",
"null"
],
"properties": {
"assert": {
"description": "Assert specifies an overlay-style pattern used to check resources.",
"type": [
"object",
"null"
],
"properties": {
"all": {
"description": "All allows specifying resources which will be ANDed.",
"type": [
"array",
"null"
],
"items": {
"type": [
"object",
"null"
],
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": [
"string",
"null"
]
}
}
}
},
"any": {
"description": "Any allows specifying resources which will be ORed.",
"type": [
"array",
"null"
],
"items": {
"type": [
"object",
"null"
],
"required": [
"check"
],
"properties": {
"check": {
"description": "Check is the assertion check definition.",
"x-kubernetes-preserve-unknown-fields": true
},
"message": {
"description": "Message is the variable associated message.",
"type": [
"string",
"null"
]
}
}
}
}
}
}
}
}
}
}
Expand All @@ -466,7 +457,7 @@
"x-kubernetes-group-version-kind": [
{
"group": "json.kyverno.io",
"kind": "Policy",
"kind": "ValidationPolicy",
"version": "v1alpha1"
}
],
Expand Down
Loading

0 comments on commit 4904d99

Please sign in to comment.