mirror of
https://github.com/projectcapsule/capsule.git
synced 2026-08-25 16:07:24 +00:00
fix: using embedded struct for selector
This commit is contained in:
@@ -7,16 +7,17 @@ package e2e
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
capsulev1beta2 "github.com/clastix/capsule/api/v1beta2"
|
||||
"github.com/clastix/capsule/pkg/api"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
v1 "k8s.io/api/scheduling/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
capsulev1beta2 "github.com/clastix/capsule/api/v1beta2"
|
||||
"github.com/clastix/capsule/pkg/api"
|
||||
)
|
||||
|
||||
var _ = Describe("enforcing a Priority Class", func() {
|
||||
@@ -36,7 +37,7 @@ var _ = Describe("enforcing a Priority Class", func() {
|
||||
Exact: []string{"gold"},
|
||||
Regex: "pc\\-\\w+",
|
||||
},
|
||||
Selector: metav1.LabelSelector{
|
||||
LabelSelector: metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"env": "customers",
|
||||
},
|
||||
|
||||
@@ -7,14 +7,16 @@ package e2e
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/clastix/capsule/pkg/api"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
nodev1 "k8s.io/api/node/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/clastix/capsule/pkg/api"
|
||||
|
||||
capsulev1beta2 "github.com/clastix/capsule/api/v1beta2"
|
||||
)
|
||||
@@ -36,7 +38,7 @@ var _ = Describe("enforcing a Runtime Class", func() {
|
||||
Exact: []string{"legacy"},
|
||||
Regex: "^hardened-.*$",
|
||||
},
|
||||
Selector: metav1.LabelSelector{
|
||||
LabelSelector: metav1.LabelSelector{
|
||||
MatchLabels: map[string]string{
|
||||
"env": "customers",
|
||||
},
|
||||
|
||||
@@ -16,13 +16,12 @@ import (
|
||||
// +kubebuilder:object:generate=true
|
||||
|
||||
type SelectorAllowedListSpec struct {
|
||||
AllowedListSpec `json:",inline"`
|
||||
|
||||
Selector metav1.LabelSelector `json:",inline"`
|
||||
AllowedListSpec `json:",inline"`
|
||||
metav1.LabelSelector `json:",inline"`
|
||||
}
|
||||
|
||||
func (in *SelectorAllowedListSpec) SelectorMatch(obj client.Object) bool {
|
||||
selector, err := metav1.LabelSelectorAsSelector(&in.Selector)
|
||||
selector, err := metav1.LabelSelectorAsSelector(&in.LabelSelector)
|
||||
if err != nil {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ func (in *ResourceQuotaSpec) DeepCopy() *ResourceQuotaSpec {
|
||||
func (in *SelectorAllowedListSpec) DeepCopyInto(out *SelectorAllowedListSpec) {
|
||||
*out = *in
|
||||
in.AllowedListSpec.DeepCopyInto(&out.AllowedListSpec)
|
||||
in.Selector.DeepCopyInto(&out.Selector)
|
||||
in.LabelSelector.DeepCopyInto(&out.LabelSelector)
|
||||
}
|
||||
|
||||
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SelectorAllowedListSpec.
|
||||
|
||||
@@ -77,7 +77,7 @@ func appendClassError(spec api.SelectorAllowedListSpec) (append string) {
|
||||
append += fmt.Sprintf(", or matching the regex %s", spec.Regex)
|
||||
}
|
||||
|
||||
if len(spec.Selector.MatchLabels) > 0 || len(spec.Selector.MatchExpressions) > 0 {
|
||||
if len(spec.MatchLabels) > 0 || len(spec.MatchExpressions) > 0 {
|
||||
append += fmt.Sprintf(", or matching the label selector defined in the Tenant")
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ func appendError(spec api.SelectorAllowedListSpec) (append string) {
|
||||
append += fmt.Sprintf(", or matching the regex %s", spec.Regex)
|
||||
}
|
||||
|
||||
if len(spec.Selector.MatchLabels) > 0 || len(spec.Selector.MatchExpressions) > 0 {
|
||||
if len(spec.MatchLabels) > 0 || len(spec.MatchExpressions) > 0 {
|
||||
append += ", or matching the label selector defined in the Tenant"
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ func AllowedValuesErrorMessage(allowed api.SelectorAllowedListSpec, err string)
|
||||
extra = append(extra, fmt.Sprintf(" use one matching the following regex (%s)", allowed.Regex))
|
||||
}
|
||||
|
||||
if len(allowed.Selector.MatchLabels) > 0 || len(allowed.Selector.MatchExpressions) > 0 {
|
||||
if len(allowed.MatchLabels) > 0 || len(allowed.MatchExpressions) > 0 {
|
||||
extra = append(extra, ", or matching the label selector defined in the Tenant")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user