Skip to content

Commit

Permalink
Move Siteinfo types
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Jun 11, 2024
1 parent 3c1fd4e commit ebd228d
Show file tree
Hide file tree
Showing 2 changed files with 273 additions and 0 deletions.
102 changes: 102 additions & 0 deletions api/v1/siteinfo_types.go
Original file line number Diff line number Diff line change
@@ -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"`
}
171 changes: 171 additions & 0 deletions api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ebd228d

Please sign in to comment.