From ef75d0496a949f394f7139bbfdef6bed2f20baaf Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Mon, 5 Jul 2021 13:51:08 +0200 Subject: [PATCH] feat(api): Tenant state --- api/v1alpha1/zz_generated.deepcopy.go | 2 +- api/v1beta1/tenant_status.go | 20 ++++++++++++++++++++ api/v1beta1/tenant_types.go | 7 +------ api/v1beta1/zz_generated.deepcopy.go | 2 +- 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 api/v1beta1/tenant_status.go diff --git a/api/v1alpha1/zz_generated.deepcopy.go b/api/v1alpha1/zz_generated.deepcopy.go index fad8b8f3..e258ce42 100644 --- a/api/v1alpha1/zz_generated.deepcopy.go +++ b/api/v1alpha1/zz_generated.deepcopy.go @@ -10,7 +10,7 @@ package v1alpha1 import ( corev1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" - v1 "k8s.io/api/rbac/v1" + "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/runtime" ) diff --git a/api/v1beta1/tenant_status.go b/api/v1beta1/tenant_status.go new file mode 100644 index 00000000..f75a0e15 --- /dev/null +++ b/api/v1beta1/tenant_status.go @@ -0,0 +1,20 @@ +// Copyright 2020-2021 Clastix Labs +// SPDX-License-Identifier: Apache-2.0 + +package v1beta1 + +// +kubebuilder:validation:Enum=cordoned;active +type tenantState string + +const ( + TenantStateActive tenantState = "active" + TenantStateCordoned tenantState = "cordoned" +) + +// TenantStatus defines the observed state of Tenant +type TenantStatus struct { + //+kubebuilder:default=active + State tenantState `json:"state"` + Size uint `json:"size"` + Namespaces []string `json:"namespaces,omitempty"` +} diff --git a/api/v1beta1/tenant_types.go b/api/v1beta1/tenant_types.go index 78863d0e..55fd50e5 100644 --- a/api/v1beta1/tenant_types.go +++ b/api/v1beta1/tenant_types.go @@ -32,16 +32,11 @@ type TenantSpec struct { EnableNodePorts bool `json:"enableNodePorts,omitempty"` } -// TenantStatus defines the observed state of Tenant -type TenantStatus struct { - Size uint `json:"size"` - Namespaces []string `json:"namespaces,omitempty"` -} - //+kubebuilder:object:root=true //+kubebuilder:subresource:status //+kubebuilder:storageversion // +kubebuilder:resource:scope=Cluster,shortName=tnt +// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.state",description="The actual state of the Tenant" // +kubebuilder:printcolumn:name="Namespace quota",type="integer",JSONPath=".spec.namespaceQuota",description="The max amount of Namespaces can be created" // +kubebuilder:printcolumn:name="Namespace count",type="integer",JSONPath=".status.size",description="The total amount of Namespaces in use" // +kubebuilder:printcolumn:name="Owner name",type="string",JSONPath=".spec.owner.name",description="The assigned Tenant owner" diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go index 59ea7e0e..7147ed3c 100644 --- a/api/v1beta1/zz_generated.deepcopy.go +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -10,7 +10,7 @@ package v1beta1 import ( corev1 "k8s.io/api/core/v1" networkingv1 "k8s.io/api/networking/v1" - v1 "k8s.io/api/rbac/v1" + "k8s.io/api/rbac/v1" "k8s.io/apimachinery/pkg/runtime" )