From 8fb4b7d4a1ee2e27efecd27e4dc0aefb0d0d9c2b Mon Sep 17 00:00:00 2001 From: Dario Tranchitella Date: Sun, 27 Jun 2021 23:19:19 +0200 Subject: [PATCH] feat: scaffolding v1beta1 Tenant version --- api/v1beta1/groupversion_info.go | 23 ++++ api/v1beta1/tenant_types.go | 56 ++++++++++ api/v1beta1/zz_generated.deepcopy.go | 101 ++++++++++++++++++ .../crd/bases/capsule.clastix.io_tenants.yaml | 28 +++++ config/samples/capsule_v1beta1_tenant.yaml | 7 ++ main.go | 2 + 6 files changed, 217 insertions(+) create mode 100644 api/v1beta1/groupversion_info.go create mode 100644 api/v1beta1/tenant_types.go create mode 100644 api/v1beta1/zz_generated.deepcopy.go create mode 100644 config/samples/capsule_v1beta1_tenant.yaml diff --git a/api/v1beta1/groupversion_info.go b/api/v1beta1/groupversion_info.go new file mode 100644 index 00000000..331f1d5a --- /dev/null +++ b/api/v1beta1/groupversion_info.go @@ -0,0 +1,23 @@ +// Copyright 2020-2021 Clastix Labs +// SPDX-License-Identifier: Apache-2.0 + +// Package v1beta1 contains API Schema definitions for the capsule v1beta1 API group +//+kubebuilder:object:generate=true +//+groupName=capsule.clastix.io +package v1beta1 + +import ( + "k8s.io/apimachinery/pkg/runtime/schema" + "sigs.k8s.io/controller-runtime/pkg/scheme" +) + +var ( + // GroupVersion is group version used to register these objects + GroupVersion = schema.GroupVersion{Group: "capsule.clastix.io", Version: "v1beta1"} + + // SchemeBuilder is used to add go types to the GroupVersionKind scheme + SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion} + + // AddToScheme adds the types in this group-version to the given scheme. + AddToScheme = SchemeBuilder.AddToScheme +) diff --git a/api/v1beta1/tenant_types.go b/api/v1beta1/tenant_types.go new file mode 100644 index 00000000..96e9ba56 --- /dev/null +++ b/api/v1beta1/tenant_types.go @@ -0,0 +1,56 @@ +// Copyright 2020-2021 Clastix Labs +// SPDX-License-Identifier: Apache-2.0 + +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN! +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. + +// TenantSpec defines the desired state of Tenant +type TenantSpec struct { + // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster + // Important: Run "make" to regenerate code after modifying this file + + // Foo is an example field of Tenant. Edit tenant_types.go to remove/update + Foo string `json:"foo,omitempty"` +} + +// TenantStatus defines the observed state of Tenant +type TenantStatus struct { + // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster + // Important: Run "make" to regenerate code after modifying this file +} + +//+kubebuilder:object:root=true +//+kubebuilder:subresource:status +//+kubebuilder:storageversion + +// Tenant is the Schema for the tenants API +type Tenant struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + + Spec TenantSpec `json:"spec,omitempty"` + Status TenantStatus `json:"status,omitempty"` +} + +func (in *Tenant) Hub() { + return +} + +//+kubebuilder:object:root=true + +// TenantList contains a list of Tenant +type TenantList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []Tenant `json:"items"` +} + +func init() { + SchemeBuilder.Register(&Tenant{}, &TenantList{}) +} diff --git a/api/v1beta1/zz_generated.deepcopy.go b/api/v1beta1/zz_generated.deepcopy.go new file mode 100644 index 00000000..caf34f9e --- /dev/null +++ b/api/v1beta1/zz_generated.deepcopy.go @@ -0,0 +1,101 @@ +// +build !ignore_autogenerated + +// Copyright 2020-2021 Clastix Labs +// SPDX-License-Identifier: Apache-2.0 + +// Code generated by controller-gen. DO NOT EDIT. + +package v1beta1 + +import ( + runtime "k8s.io/apimachinery/pkg/runtime" +) + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Tenant) DeepCopyInto(out *Tenant) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + out.Status = in.Status +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Tenant. +func (in *Tenant) DeepCopy() *Tenant { + if in == nil { + return nil + } + out := new(Tenant) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *Tenant) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TenantList) DeepCopyInto(out *TenantList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]Tenant, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TenantList. +func (in *TenantList) DeepCopy() *TenantList { + if in == nil { + return nil + } + out := new(TenantList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *TenantList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TenantSpec) DeepCopyInto(out *TenantSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TenantSpec. +func (in *TenantSpec) DeepCopy() *TenantSpec { + if in == nil { + return nil + } + out := new(TenantSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *TenantStatus) DeepCopyInto(out *TenantStatus) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TenantStatus. +func (in *TenantStatus) DeepCopy() *TenantStatus { + if in == nil { + return nil + } + out := new(TenantStatus) + in.DeepCopyInto(out) + return out +} diff --git a/config/crd/bases/capsule.clastix.io_tenants.yaml b/config/crd/bases/capsule.clastix.io_tenants.yaml index ffd7ca24..a9fa3d9e 100644 --- a/config/crd/bases/capsule.clastix.io_tenants.yaml +++ b/config/crd/bases/capsule.clastix.io_tenants.yaml @@ -563,6 +563,34 @@ spec: type: object type: object served: true + storage: false + subresources: + status: {} + - name: v1beta1 + schema: + openAPIV3Schema: + description: Tenant is the Schema for the tenants API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: TenantSpec defines the desired state of Tenant + properties: + foo: + description: Foo is an example field of Tenant. Edit tenant_types.go to remove/update + type: string + type: object + status: + description: TenantStatus defines the observed state of Tenant + type: object + type: object + served: true storage: true subresources: status: {} diff --git a/config/samples/capsule_v1beta1_tenant.yaml b/config/samples/capsule_v1beta1_tenant.yaml new file mode 100644 index 00000000..eda5825c --- /dev/null +++ b/config/samples/capsule_v1beta1_tenant.yaml @@ -0,0 +1,7 @@ +apiVersion: capsule.clastix.io/v1beta1 +kind: Tenant +metadata: + name: tenant-sample +spec: + # Add fields here + foo: bar diff --git a/main.go b/main.go index cf157285..02c540de 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/log/zap" capsulev1alpha1 "github.com/clastix/capsule/api/v1alpha1" + capsulev1beta1 "github.com/clastix/capsule/api/v1beta1" "github.com/clastix/capsule/controllers" config "github.com/clastix/capsule/controllers/config" "github.com/clastix/capsule/controllers/rbac" @@ -50,6 +51,7 @@ func init() { utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(capsulev1alpha1.AddToScheme(scheme)) + utilruntime.Must(capsulev1beta1.AddToScheme(scheme)) // +kubebuilder:scaffold:scheme }