diff --git a/api/v1alpha1/conversion_hub.go b/api/v1alpha1/conversion_hub.go index bff22ae8..2dfc9483 100644 --- a/api/v1alpha1/conversion_hub.go +++ b/api/v1alpha1/conversion_hub.go @@ -200,17 +200,17 @@ func (t *Tenant) ConvertTo(dstRaw conversion.Hub) error { } } if len(t.Spec.NetworkPolicies) > 0 { - dst.Spec.NetworkPolicies = &capsulev1beta1.NetworkPolicySpec{ + dst.Spec.NetworkPolicies = capsulev1beta1.NetworkPolicySpec{ Items: t.Spec.NetworkPolicies, } } if len(t.Spec.LimitRanges) > 0 { - dst.Spec.LimitRanges = &capsulev1beta1.LimitRangesSpec{ + dst.Spec.LimitRanges = capsulev1beta1.LimitRangesSpec{ Items: t.Spec.LimitRanges, } } if len(t.Spec.ResourceQuota) > 0 { - dst.Spec.ResourceQuota = &capsulev1beta1.ResourceQuotaSpec{ + dst.Spec.ResourceQuota = capsulev1beta1.ResourceQuotaSpec{ Scope: func() capsulev1beta1.ResourceQuotaScope { if v, ok := t.GetAnnotations()[resourceQuotaScopeAnnotation]; ok { switch v { @@ -500,13 +500,13 @@ func (t *Tenant) ConvertFrom(srcRaw conversion.Hub) error { Regex: src.Spec.ContainerRegistries.Regex, } } - if src.Spec.NetworkPolicies != nil { + if len(src.Spec.NetworkPolicies.Items) > 0 { t.Spec.NetworkPolicies = src.Spec.NetworkPolicies.Items } - if src.Spec.LimitRanges != nil { + if len(src.Spec.LimitRanges.Items) > 0 { t.Spec.LimitRanges = src.Spec.LimitRanges.Items } - if src.Spec.ResourceQuota != nil { + if len(src.Spec.ResourceQuota.Items) > 0 { t.Annotations[resourceQuotaScopeAnnotation] = string(src.Spec.ResourceQuota.Scope) t.Spec.ResourceQuota = src.Spec.ResourceQuota.Items } diff --git a/api/v1alpha1/conversion_hub_test.go b/api/v1alpha1/conversion_hub_test.go index a9c8cac3..7936516d 100644 --- a/api/v1alpha1/conversion_hub_test.go +++ b/api/v1alpha1/conversion_hub_test.go @@ -240,13 +240,13 @@ func generateTenantsSpecs() (Tenant, capsulev1beta1.Tenant) { }, ContainerRegistries: v1beta1AllowedListSpec, NodeSelector: nodeSelector, - NetworkPolicies: &capsulev1beta1.NetworkPolicySpec{ + NetworkPolicies: capsulev1beta1.NetworkPolicySpec{ Items: networkPolicies, }, - LimitRanges: &capsulev1beta1.LimitRangesSpec{ + LimitRanges: capsulev1beta1.LimitRangesSpec{ Items: limitRanges, }, - ResourceQuota: &capsulev1beta1.ResourceQuotaSpec{ + ResourceQuota: capsulev1beta1.ResourceQuotaSpec{ Scope: capsulev1beta1.ResourceQuotaScopeNamespace, Items: resourceQuotas, }, diff --git a/e2e/owner_webhooks_test.go b/e2e/owner_webhooks_test.go index 55086b06..07f702e4 100644 --- a/e2e/owner_webhooks_test.go +++ b/e2e/owner_webhooks_test.go @@ -38,7 +38,7 @@ var _ = Describe("when Tenant owner interacts with the webhooks", func() { "glusterfs", }, }, - LimitRanges: &capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ + LimitRanges: capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ { Limits: []corev1.LimitRangeItem{ { @@ -56,7 +56,7 @@ var _ = Describe("when Tenant owner interacts with the webhooks", func() { }, }, }, - NetworkPolicies: &capsulev1beta1.NetworkPolicySpec{Items: []networkingv1.NetworkPolicySpec{ + NetworkPolicies: capsulev1beta1.NetworkPolicySpec{Items: []networkingv1.NetworkPolicySpec{ { Egress: []networkingv1.NetworkPolicyEgressRule{ { @@ -77,7 +77,7 @@ var _ = Describe("when Tenant owner interacts with the webhooks", func() { }, }, }, - ResourceQuota: &capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ + ResourceQuota: capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ { Hard: map[corev1.ResourceName]resource.Quantity{ corev1.ResourcePods: resource.MustParse("10"), diff --git a/e2e/resource_quota_exceeded_test.go b/e2e/resource_quota_exceeded_test.go index 51baed4b..bd6bc1c9 100644 --- a/e2e/resource_quota_exceeded_test.go +++ b/e2e/resource_quota_exceeded_test.go @@ -33,7 +33,7 @@ var _ = Describe("exceeding a Tenant resource quota", func() { Kind: "User", }, }, - LimitRanges: &capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ + LimitRanges: capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ { Limits: []corev1.LimitRangeItem{ { @@ -79,7 +79,7 @@ var _ = Describe("exceeding a Tenant resource quota", func() { }, }, }, - ResourceQuota: &capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ + ResourceQuota: capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ { Hard: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceLimitsCPU: resource.MustParse("8"), diff --git a/e2e/tenant_resources_changes_test.go b/e2e/tenant_resources_changes_test.go index f691d6f4..f797d625 100644 --- a/e2e/tenant_resources_changes_test.go +++ b/e2e/tenant_resources_changes_test.go @@ -33,7 +33,7 @@ var _ = Describe("changing Tenant managed Kubernetes resources", func() { Kind: "User", }, }, - LimitRanges: &capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ + LimitRanges: capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ { Limits: []corev1.LimitRangeItem{ { @@ -79,7 +79,7 @@ var _ = Describe("changing Tenant managed Kubernetes resources", func() { }, }, }, - NetworkPolicies: &capsulev1beta1.NetworkPolicySpec{Items: []networkingv1.NetworkPolicySpec{ + NetworkPolicies: capsulev1beta1.NetworkPolicySpec{Items: []networkingv1.NetworkPolicySpec{ { Ingress: []networkingv1.NetworkPolicyIngressRule{ { @@ -127,7 +127,7 @@ var _ = Describe("changing Tenant managed Kubernetes resources", func() { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - ResourceQuota: &capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ + ResourceQuota: capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ { Hard: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceLimitsCPU: resource.MustParse("8"), diff --git a/e2e/tenant_resources_test.go b/e2e/tenant_resources_test.go index d1fbbcc0..59b7012e 100644 --- a/e2e/tenant_resources_test.go +++ b/e2e/tenant_resources_test.go @@ -33,7 +33,7 @@ var _ = Describe("creating namespaces within a Tenant with resources", func() { Kind: "User", }, }, - LimitRanges: &capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ + LimitRanges: capsulev1beta1.LimitRangesSpec{Items: []corev1.LimitRangeSpec{ { Limits: []corev1.LimitRangeItem{ { @@ -79,7 +79,7 @@ var _ = Describe("creating namespaces within a Tenant with resources", func() { }, }, }, - NetworkPolicies: &capsulev1beta1.NetworkPolicySpec{Items: []networkingv1.NetworkPolicySpec{ + NetworkPolicies: capsulev1beta1.NetworkPolicySpec{Items: []networkingv1.NetworkPolicySpec{ { Ingress: []networkingv1.NetworkPolicyIngressRule{ { @@ -127,7 +127,7 @@ var _ = Describe("creating namespaces within a Tenant with resources", func() { NodeSelector: map[string]string{ "kubernetes.io/os": "linux", }, - ResourceQuota: &capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ + ResourceQuota: capsulev1beta1.ResourceQuotaSpec{Items: []corev1.ResourceQuotaSpec{ { Hard: map[corev1.ResourceName]resource.Quantity{ corev1.ResourceLimitsCPU: resource.MustParse("8"),