Skip to content

Commit

Permalink
apply review notes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maksim Fedotov committed Sep 2, 2020
1 parent 75edcf9 commit 9d845b3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 12 deletions.
7 changes: 5 additions & 2 deletions e2e/custom_capsule_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,13 @@ import (
var _ = Describe("creating a Namespace as Tenant owner with custom --capsule-group", func() {
tnt := &v1alpha1.Tenant{
ObjectMeta: metav1.ObjectMeta{
Name: "tenant-assigned-custom-group",
Name: "tenantassignedcustomgroup",
},
Spec: v1alpha1.TenantSpec{
Owner: "alice",
Owner: v1alpha1.OwnerSpec{
Name: "alice",
Kind: "User",
},
StorageClasses: []string{},
IngressClasses: []string{},
LimitRanges: []corev1.LimitRangeSpec{},
Expand Down
2 changes: 1 addition & 1 deletion e2e/force_tenant_prefix_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ var _ = Describe("creating a Namespace with --force-tenant-name flag", func() {
args := append(defaulManagerPodArgs, []string{"--force-tenant-prefix"}...)
ModifyCapsuleManagerPodArgs(args)
ns := NewNamespace("test")
NamespaceCreationShouldFail(ns, t1, podRecreationTimeoutInterval)
NamespaceCreationShouldNotSucceed(ns, t1, podRecreationTimeoutInterval)
})
It("should be assigned to the second Tenant", func() {
ns := NewNamespace("second-test")
Expand Down
5 changes: 4 additions & 1 deletion e2e/protected_namespace_regex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ var _ = Describe("creating a Namespace with --protected-namespace-regex enabled"
Name: "tenantprotectednamespace",
},
Spec: v1alpha1.TenantSpec{
Owner: "alice",
Owner: v1alpha1.OwnerSpec{
Name: "alice",
Kind: "User",
},
StorageClasses: []string{},
IngressClasses: []string{},
LimitRanges: []corev1.LimitRangeSpec{},
Expand Down
11 changes: 5 additions & 6 deletions e2e/tenant_resources_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
. "github.com/onsi/gomega"
corev1 "k8s.io/api/core/v1"
networkingv1 "k8s.io/api/networking/v1"
v1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -109,7 +108,7 @@ var _ = Describe("creating namespaces within a Tenant with resources", func() {
PodSelector: &metav1.LabelSelector{},
},
{
IPBlock: &v1.IPBlock{
IPBlock: &networkingv1.IPBlock{
CIDR: "192.168.0.0/12",
},
},
Expand All @@ -120,7 +119,7 @@ var _ = Describe("creating namespaces within a Tenant with resources", func() {
{
To: []networkingv1.NetworkPolicyPeer{
{
IPBlock: &v1.IPBlock{
IPBlock: &networkingv1.IPBlock{
CIDR: "0.0.0.0/0",
Except: []string{
"192.168.0.0/12",
Expand All @@ -131,9 +130,9 @@ var _ = Describe("creating namespaces within a Tenant with resources", func() {
},
},
PodSelector: metav1.LabelSelector{},
PolicyTypes: []v1.PolicyType{
v1.PolicyTypeIngress,
v1.PolicyTypeEgress,
PolicyTypes: []networkingv1.PolicyType{
networkingv1.PolicyTypeIngress,
networkingv1.PolicyTypeEgress,
},
},
},
Expand Down
4 changes: 2 additions & 2 deletions pkg/webhook/tenant_name/validating.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ func (r *handler) OnCreate(ctx context.Context, req admission.Request, clt clien

matched, _ := regexp.MatchString(`^[a-z0-9]([a-z0-9]*[a-z0-9])?$`, tnt.GetName())
if !matched {
fmt.Printf("%s not mached", tnt.GetName())
return admission.Denied("Tenant name had forbidden characters")
fmt.Printf("%s not matched", tnt.GetName())
return admission.Denied("Tenant name has forbidden characters")
}
return admission.Allowed("")
}
Expand Down

0 comments on commit 9d845b3

Please sign in to comment.