From ebd228d58ef0d3680581849f5be82b929fc22206 Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Tue, 11 Jun 2024 14:42:48 -0700 Subject: [PATCH] Move Siteinfo types Signed-off-by: Tamal Saha --- api/v1/siteinfo_types.go | 102 +++++++++++++++++++ api/v1/zz_generated.deepcopy.go | 171 ++++++++++++++++++++++++++++++++ 2 files changed, 273 insertions(+) create mode 100644 api/v1/siteinfo_types.go diff --git a/api/v1/siteinfo_types.go b/api/v1/siteinfo_types.go new file mode 100644 index 000000000..e9dfdd716 --- /dev/null +++ b/api/v1/siteinfo_types.go @@ -0,0 +1,102 @@ +/* +Copyright AppsCode Inc. and Contributors + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package v1 + +import ( + core "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/version" +) + +const ( + ResourceKindSiteInfo = "SiteInfo" + ResourceSiteInfo = "siteinfo" + ResourceSiteInfos = "siteinfos" +) + +// SiteInfo captures information of a product deployment site. + +// +k8s:openapi-gen=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// +kubebuilder:object:root=true +// +kubebuilder:resource:path=siteinfos,singular=siteinfo,scope=Cluster,categories={auditor,appscode,all} +type SiteInfo struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Product *ProductInfo `json:"product,omitempty"` + Kubernetes *KubernetesInfo `json:"kubernetes,omitempty"` +} + +type Version struct { + Version string `json:"version,omitempty"` + VersionStrategy string `json:"versionStrategy,omitempty"` + CommitHash string `json:"commitHash,omitempty"` + GitBranch string `json:"gitBranch,omitempty"` + GitTag string `json:"gitTag,omitempty"` + CommitTimestamp string `json:"commitTimestamp,omitempty"` + GoVersion string `json:"goVersion,omitempty"` + Compiler string `json:"compiler,omitempty"` + Platform string `json:"platform,omitempty"` +} + +type ProductInfo struct { + Version Version `json:"version"` + LicenseID string `json:"licenseID,omitempty"` + + ProductOwnerName string `json:"productOwnerName,omitempty"` + ProductOwnerUID string `json:"productOwnerUID,omitempty"` + + // This has been renamed to Features + ProductName string `json:"productName,omitempty"` + ProductUID string `json:"productUID,omitempty"` +} + +type KubernetesInfo struct { + // Deprecated + ClusterName string `json:"clusterName,omitempty"` + // Deprecated + ClusterUID string `json:"clusterUID,omitempty"` + Cluster *ClusterMetadata `json:"cluster,omitempty"` + Version *version.Info `json:"version,omitempty"` + ControlPlane *ControlPlaneInfo `json:"controlPlane,omitempty"` + NodeStats NodeStats `json:"nodeStats"` +} + +// https://github.com/kmodules/client-go/blob/kubernetes-1.16.3/tools/analytics/analytics.go#L66 +type ControlPlaneInfo struct { + DNSNames []string `json:"dnsNames,omitempty"` + EmailAddresses []string `json:"emailAddresses,omitempty"` + IPAddresses []string `json:"ipAddresses,omitempty"` + URIs []string `json:"uris,omitempty"` + NotBefore metav1.Time `json:"notBefore"` + NotAfter metav1.Time `json:"notAfter"` +} + +type NodeStats struct { + Count int `json:"count,omitempty"` + + // Capacity represents the total resources of a node. + // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#capacity + // +optional + Capacity core.ResourceList `json:"capacity,omitempty"` + + // Allocatable represents the resources of a node that are available for scheduling. + // Defaults to Capacity. + // +optional + Allocatable core.ResourceList `json:"allocatable,omitempty"` +} diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index fd286ac41..0788850ae 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -24,6 +24,8 @@ package v1 import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + version "k8s.io/apimachinery/pkg/version" ) // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. @@ -174,6 +176,44 @@ func (in Conditions) DeepCopy() Conditions { return *out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ControlPlaneInfo) DeepCopyInto(out *ControlPlaneInfo) { + *out = *in + if in.DNSNames != nil { + in, out := &in.DNSNames, &out.DNSNames + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.EmailAddresses != nil { + in, out := &in.EmailAddresses, &out.EmailAddresses + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.IPAddresses != nil { + in, out := &in.IPAddresses, &out.IPAddresses + *out = make([]string, len(*in)) + copy(*out, *in) + } + if in.URIs != nil { + in, out := &in.URIs, &out.URIs + *out = make([]string, len(*in)) + copy(*out, *in) + } + in.NotBefore.DeepCopyInto(&out.NotBefore) + in.NotAfter.DeepCopyInto(&out.NotAfter) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ControlPlaneInfo. +func (in *ControlPlaneInfo) DeepCopy() *ControlPlaneInfo { + if in == nil { + return nil + } + out := new(ControlPlaneInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HealthCheckSpec) DeepCopyInto(out *HealthCheckSpec) { *out = *in @@ -219,6 +259,38 @@ func (in *ImageInfo) DeepCopy() *ImageInfo { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *KubernetesInfo) DeepCopyInto(out *KubernetesInfo) { + *out = *in + if in.Cluster != nil { + in, out := &in.Cluster, &out.Cluster + *out = new(ClusterMetadata) + **out = **in + } + if in.Version != nil { + in, out := &in.Version, &out.Version + *out = new(version.Info) + **out = **in + } + if in.ControlPlane != nil { + in, out := &in.ControlPlane, &out.ControlPlane + *out = new(ControlPlaneInfo) + (*in).DeepCopyInto(*out) + } + in.NodeStats.DeepCopyInto(&out.NodeStats) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new KubernetesInfo. +func (in *KubernetesInfo) DeepCopy() *KubernetesInfo { + if in == nil { + return nil + } + out := new(KubernetesInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Lineage) DeepCopyInto(out *Lineage) { *out = *in @@ -245,6 +317,36 @@ func (in *Lineage) DeepCopy() *Lineage { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeStats) DeepCopyInto(out *NodeStats) { + *out = *in + if in.Capacity != nil { + in, out := &in.Capacity, &out.Capacity + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + if in.Allocatable != nil { + in, out := &in.Allocatable, &out.Allocatable + *out = make(corev1.ResourceList, len(*in)) + for key, val := range *in { + (*out)[key] = val.DeepCopy() + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeStats. +func (in *NodeStats) DeepCopy() *NodeStats { + if in == nil { + return nil + } + out := new(NodeStats) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ObjectID) DeepCopyInto(out *ObjectID) { *out = *in @@ -295,6 +397,23 @@ func (in *ObjectReference) DeepCopy() *ObjectReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ProductInfo) DeepCopyInto(out *ProductInfo) { + *out = *in + out.Version = in.Version + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ProductInfo. +func (in *ProductInfo) DeepCopy() *ProductInfo { + if in == nil { + return nil + } + out := new(ProductInfo) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *PullCredentials) DeepCopyInto(out *PullCredentials) { *out = *in @@ -363,6 +482,42 @@ func (in *ResourceID) DeepCopy() *ResourceID { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *SiteInfo) DeepCopyInto(out *SiteInfo) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + if in.Product != nil { + in, out := &in.Product, &out.Product + *out = new(ProductInfo) + **out = **in + } + if in.Kubernetes != nil { + in, out := &in.Kubernetes, &out.Kubernetes + *out = new(KubernetesInfo) + (*in).DeepCopyInto(*out) + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new SiteInfo. +func (in *SiteInfo) DeepCopy() *SiteInfo { + if in == nil { + return nil + } + out := new(SiteInfo) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *SiteInfo) 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 *TLSConfig) DeepCopyInto(out *TLSConfig) { *out = *in @@ -417,6 +572,22 @@ func (in *TypedObjectReference) DeepCopy() *TypedObjectReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Version) DeepCopyInto(out *Version) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Version. +func (in *Version) DeepCopy() *Version { + if in == nil { + return nil + } + out := new(Version) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *X509Subject) DeepCopyInto(out *X509Subject) { *out = *in