mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-30 06:54:01 +00:00
add functions to policy accessors for getting match information and params
This commit is contained in:
parent
1f40d5c095
commit
6d5133f3ec
@ -17,6 +17,7 @@ limitations under the License.
|
||||
package generic
|
||||
|
||||
import (
|
||||
"k8s.io/api/admissionregistration/v1beta1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
)
|
||||
@ -25,6 +26,7 @@ type PolicyAccessor interface {
|
||||
GetName() string
|
||||
GetNamespace() string
|
||||
GetParamKind() *schema.GroupVersionKind
|
||||
GetMatchConstraints() *v1beta1.MatchResources
|
||||
}
|
||||
|
||||
type BindingAccessor interface {
|
||||
@ -35,4 +37,7 @@ type BindingAccessor interface {
|
||||
// which is cluster-scoped, so namespace is usually left blank.
|
||||
// But we leave the door open to add a namespaced vesion in the future
|
||||
GetPolicyName() types.NamespacedName
|
||||
GetParamRef() *v1beta1.ParamRef
|
||||
|
||||
GetMatchResources() *v1beta1.MatchResources
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/require"
|
||||
"k8s.io/api/admissionregistration/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
@ -204,6 +205,10 @@ func (fp *FakePolicy) GetParamKind() *schema.GroupVersionKind {
|
||||
return fp.ParamKind
|
||||
}
|
||||
|
||||
func (fb *FakePolicy) GetMatchConstraints() *v1beta1.MatchResources {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fb *FakeBinding) GetName() string {
|
||||
return fb.Name
|
||||
}
|
||||
@ -218,6 +223,14 @@ func (fb *FakeBinding) GetPolicyName() types.NamespacedName {
|
||||
}
|
||||
}
|
||||
|
||||
func (fb *FakeBinding) GetMatchResources() *v1beta1.MatchResources {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fb *FakeBinding) GetParamRef() *v1beta1.ParamRef {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (fp *FakePolicy) DeepCopyObject() runtime.Object {
|
||||
// totally fudged deepcopy
|
||||
newFP := &FakePolicy{}
|
||||
|
@ -75,6 +75,10 @@ func (v *validatingAdmissionPolicyAccessor) GetParamKind() *schema.GroupVersionK
|
||||
}
|
||||
}
|
||||
|
||||
func (v *validatingAdmissionPolicyAccessor) GetMatchConstraints() *v1beta1.MatchResources {
|
||||
return v.Spec.MatchConstraints
|
||||
}
|
||||
|
||||
type validatingAdmissionPolicyBindingAccessor struct {
|
||||
*v1beta1.ValidatingAdmissionPolicyBinding
|
||||
}
|
||||
@ -93,3 +97,11 @@ func (v *validatingAdmissionPolicyBindingAccessor) GetPolicyName() types.Namespa
|
||||
Name: v.Spec.PolicyName,
|
||||
}
|
||||
}
|
||||
|
||||
func (v *validatingAdmissionPolicyBindingAccessor) GetMatchResources() *v1beta1.MatchResources {
|
||||
return v.Spec.MatchResources
|
||||
}
|
||||
|
||||
func (v *validatingAdmissionPolicyBindingAccessor) GetParamRef() *v1beta1.ParamRef {
|
||||
return v.Spec.ParamRef
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user