1
0
Fork 0
mirror of https://github.com/kyverno/kyverno.git synced 2025-03-31 03:45:17 +00:00

Merge branch 'master' into add_testscenario

This commit is contained in:
Shuting Zhao 2020-01-10 12:00:04 -08:00
commit ac0404bd6c
3 changed files with 16 additions and 11 deletions

View file

@ -106,6 +106,8 @@ spec:
generate: generate:
kind: ConfigMap kind: ConfigMap
name: zk-kafka-address name: zk-kafka-address
# create the resource in the new namespace
namespace: "{{request.object.name}}"
data: data:
kind: ConfigMap kind: ConfigMap
data: data:

View file

@ -76,7 +76,7 @@ spec :
- key: name # compares (key operator value) - key: name # compares (key operator value)
operator: Equal operator: Equal
value: name # constant "name" == "name" value: name # constant "name" == "name"
- key: "{{serviceAccount}}" # refer to a pre-defined variable serviceAccount - key: "{{serviceAccountName}}" # refer to a pre-defined variable serviceAccountName
operator: NotEqual operator: NotEqual
value: "user1" # if service value: "user1" # if service
# Each rule can contain a single validate, mutate, or generate directive # Each rule can contain a single validate, mutate, or generate directive

View file

@ -232,17 +232,20 @@ func variableSubsitutionForAttributes(gen kyverno.Generation, ctx context.EvalIn
if newNamespace, ok := newNamespaceVar.(string); ok { if newNamespace, ok := newNamespaceVar.(string); ok {
gen.Namespace = newNamespace gen.Namespace = newNamespace
} }
// Clone
cloneName := gen.Clone.Name
cloneNamespace := gen.Clone.Namespace
newcloneNameVar := variables.SubstituteVariables(ctx, cloneName) if gen.Clone != (kyverno.CloneFrom{}) {
if newcloneName, ok := newcloneNameVar.(string); ok { // Clone
gen.Clone.Name = newcloneName cloneName := gen.Clone.Name
} cloneNamespace := gen.Clone.Namespace
newcloneNamespaceVar := variables.SubstituteVariables(ctx, cloneNamespace)
if newcloneNamespace, ok := newcloneNamespaceVar.(string); ok { newcloneNameVar := variables.SubstituteVariables(ctx, cloneName)
gen.Clone.Namespace = newcloneNamespace if newcloneName, ok := newcloneNameVar.(string); ok {
gen.Clone.Name = newcloneName
}
newcloneNamespaceVar := variables.SubstituteVariables(ctx, cloneNamespace)
if newcloneNamespace, ok := newcloneNamespaceVar.(string); ok {
gen.Clone.Namespace = newcloneNamespace
}
} }
return gen return gen
} }