From bb1cdcf739a85ce9ab8a2d6a7f8f80ae8764b584 Mon Sep 17 00:00:00 2001 From: Kevin Ingelman Date: Tue, 30 Apr 2024 14:18:54 -0700 Subject: [PATCH] Restore Server v1beta1 Go API definition The `v1beta1` Go API definition for Servers was removed in #11920, in favor of the `v1beta2` definition that was being added. For backwards compatability, the `v1beta1` definition should have been left in place. Signed-off-by: Kevin Ingelman --- controller/gen/apis/server/v1beta1/doc.go | 3 ++ .../gen/apis/server/v1beta1/register.go | 49 +++++++++++++++++++ controller/gen/apis/server/v1beta1/types.go | 45 +++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 controller/gen/apis/server/v1beta1/doc.go create mode 100644 controller/gen/apis/server/v1beta1/register.go create mode 100644 controller/gen/apis/server/v1beta1/types.go diff --git a/controller/gen/apis/server/v1beta1/doc.go b/controller/gen/apis/server/v1beta1/doc.go new file mode 100644 index 0000000000000..ffd023fe6d80c --- /dev/null +++ b/controller/gen/apis/server/v1beta1/doc.go @@ -0,0 +1,3 @@ +// +k8s:deepcopy-gen=package + +package v1beta1 diff --git a/controller/gen/apis/server/v1beta1/register.go b/controller/gen/apis/server/v1beta1/register.go new file mode 100644 index 0000000000000..175a7ce81229e --- /dev/null +++ b/controller/gen/apis/server/v1beta1/register.go @@ -0,0 +1,49 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime" + "k8s.io/apimachinery/pkg/runtime/schema" + + "github.com/linkerd/linkerd2/controller/gen/apis/server" +) + +var ( + // SchemeGroupVersion is the identifier for the API which includes the name + // of the group and the version of the API. + SchemeGroupVersion = schema.GroupVersion{ + Group: server.GroupName, + Version: "v1beta1", + } + + // SchemeBuilder collects functions that add things to a scheme. It's to + // allow code to compile without explicitly referencing generated types. + // You should declare one in each package that will have generated deep + // copy or conversion functions. + SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes) + + // AddToScheme applies all the stored functions to the scheme. A non-nil error + // indicates that one function failed and the attempt was abandoned. + AddToScheme = SchemeBuilder.AddToScheme +) + +// Kind takes an unqualified kind and returns back a Group qualified GroupKind +func Kind(kind string) schema.GroupKind { + return SchemeGroupVersion.WithKind(kind).GroupKind() +} + +// Resource takes an unqualified resource and returns a Group qualified +// GroupResource +func Resource(resource string) schema.GroupResource { + return SchemeGroupVersion.WithResource(resource).GroupResource() +} + +// Adds the list of known types to Scheme. +func addKnownTypes(scheme *runtime.Scheme) error { + scheme.AddKnownTypes(SchemeGroupVersion, + &Server{}, + &ServerList{}, + ) + metav1.AddToGroupVersion(scheme, SchemeGroupVersion) + return nil +} diff --git a/controller/gen/apis/server/v1beta1/types.go b/controller/gen/apis/server/v1beta1/types.go new file mode 100644 index 0000000000000..5b5211deb6da8 --- /dev/null +++ b/controller/gen/apis/server/v1beta1/types.go @@ -0,0 +1,45 @@ +package v1beta1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/intstr" +) + +// +genclient +// +genclient:noStatus +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +groupName=policy.linkerd.io + +type Server struct { + // TypeMeta is the metadata for the resource, like kind and apiversion + metav1.TypeMeta `json:",inline"` + + // ObjectMeta contains the metadata for the particular object, including + // things like... + // - name + // - namespace + // - self link + // - labels + // - ... etc ... + metav1.ObjectMeta `json:"metadata,omitempty"` + + // Spec is the custom resource spec + Spec ServerSpec `json:"spec"` +} + +// ServerSpec specifies a Server resource. +type ServerSpec struct { + PodSelector *metav1.LabelSelector `json:"podSelector"` + Port intstr.IntOrString `json:"port,omitempty"` + ProxyProtocol string `json:"proxyProtocol,omitempty"` +} + +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// ServerList is a list of Server resources. +type ServerList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata"` + + Items []Server `json:"items"` +}