feat: kubesphere 4.0 (#6115)
* feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> * feat: kubesphere 4.0 Signed-off-by: ci-bot <ci-bot@kubesphere.io> --------- Signed-off-by: ci-bot <ci-bot@kubesphere.io> Co-authored-by: ks-ci-bot <ks-ci-bot@example.com> Co-authored-by: joyceliu <joyceliu@yunify.com>
This commit is contained in:
committed by
GitHub
parent
b5015ec7b9
commit
447a51f08b
43
vendor/github.com/open-policy-agent/opa/rego/plugins.go
generated
vendored
Normal file
43
vendor/github.com/open-policy-agent/opa/rego/plugins.go
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
// Copyright 2023 The OPA Authors. All rights reserved.
|
||||
// Use of this source code is governed by an Apache2
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
package rego
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/open-policy-agent/opa/ast"
|
||||
"github.com/open-policy-agent/opa/ir"
|
||||
)
|
||||
|
||||
var targetPlugins = map[string]TargetPlugin{}
|
||||
var pluginMtx sync.Mutex
|
||||
|
||||
type TargetPlugin interface {
|
||||
IsTarget(string) bool
|
||||
PrepareForEval(context.Context, *ir.Policy, ...PrepareOption) (TargetPluginEval, error)
|
||||
}
|
||||
|
||||
type TargetPluginEval interface {
|
||||
Eval(context.Context, *EvalContext, ast.Value) (ast.Value, error)
|
||||
}
|
||||
|
||||
func (r *Rego) targetPlugin(tgt string) TargetPlugin {
|
||||
for _, p := range targetPlugins {
|
||||
if p.IsTarget(tgt) {
|
||||
return p
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func RegisterPlugin(name string, p TargetPlugin) {
|
||||
pluginMtx.Lock()
|
||||
defer pluginMtx.Unlock()
|
||||
if _, ok := targetPlugins[name]; ok {
|
||||
panic("plugin already registered " + name)
|
||||
}
|
||||
targetPlugins[name] = p
|
||||
}
|
||||
Reference in New Issue
Block a user