Skip to content

Commit

Permalink
Enable image substitution in the background mode
Browse files Browse the repository at this point in the history
Signed-off-by: Shuting Zhao <shutting06@gmail.com>
  • Loading branch information
realshuting committed Apr 28, 2021
1 parent 0776b43 commit 85dde7e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions pkg/policy/apply.go
Expand Up @@ -50,6 +50,10 @@ func applyPolicy(policy kyverno.ClusterPolicy, resource unstructured.Unstructure
logger.Error(err, "failed to add namespace to ctx")
}

if err := ctx.AddImageInfo(&resource); err != nil {
logger.Error(err, "unable to add image info to variables context")
}

engineResponseMutation, err = mutation(policy, resource, logger, resCache, ctx, namespaceLabels)
if err != nil {
logger.Error(err, "failed to process mutation rule")
Expand Down
2 changes: 1 addition & 1 deletion pkg/policy/background.go
Expand Up @@ -24,7 +24,7 @@ func ContainsVariablesOtherThanObject(policy kyverno.ClusterPolicy) error {
return fmt.Errorf("invalid variable used at path: spec/rules[%d]/exclude/%s", idx, path)
}

filterVars := []string{"request.object", "request.namespace"}
filterVars := []string{"request.object", "request.namespace", "images"}
ctx := context.NewContext(filterVars...)

for _, contextEntry := range rule.Context {
Expand Down

0 comments on commit 85dde7e

Please sign in to comment.