mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-24 08:36:46 +00:00
fix: providing the http provider in the compiler (#12379)
Signed-off-by: Frank Jogeleit <frank.jogeleit@web.de>
This commit is contained in:
parent
0d43a2d997
commit
1a7c581220
3 changed files with 11 additions and 1 deletions
|
@ -109,3 +109,11 @@ func buildRequestData(data map[string]any) (io.Reader, error) {
|
|||
|
||||
return buffer, nil
|
||||
}
|
||||
|
||||
func NewHTTP() HTTP {
|
||||
return HTTP{
|
||||
HttpInterface: &HttpProvider{
|
||||
client: http.DefaultClient,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,7 +53,7 @@ func (c *compiler) compileForJSON(policy *policiesv1alpha1.ValidatingPolicy, exc
|
|||
}
|
||||
|
||||
options = append(options, declOptions...)
|
||||
options = append(options, context.Lib())
|
||||
options = append(options, context.Lib(), http.Lib())
|
||||
env, err := base.Extend(options...)
|
||||
if err != nil {
|
||||
return nil, append(allErrs, field.InternalError(nil, err))
|
||||
|
|
|
@ -10,6 +10,7 @@ import (
|
|||
"github.com/google/cel-go/common/types/ref"
|
||||
policiesv1alpha1 "github.com/kyverno/kyverno/api/policies.kyverno.io/v1alpha1"
|
||||
contextlib "github.com/kyverno/kyverno/pkg/cel/libs/context"
|
||||
"github.com/kyverno/kyverno/pkg/cel/libs/http"
|
||||
"github.com/kyverno/kyverno/pkg/cel/utils"
|
||||
"go.uber.org/multierr"
|
||||
admissionv1 "k8s.io/api/admission/v1"
|
||||
|
@ -162,6 +163,7 @@ func (p *compiledPolicy) evaluateWithData(
|
|||
vars := lazy.NewMapValue(VariablesType)
|
||||
dataNew := map[string]any{
|
||||
ContextKey: contextlib.Context{ContextInterface: data.Context},
|
||||
HttpKey: http.NewHTTP(),
|
||||
NamespaceObjectKey: data.Namespace,
|
||||
ObjectKey: data.Object,
|
||||
OldObjectKey: data.OldObject,
|
||||
|
|
Loading…
Add table
Reference in a new issue