Skip to content

Commit

Permalink
Merge remote-tracking branch 'kubelink/appdetails-improve-v2' into ap…
Browse files Browse the repository at this point in the history
…pdetails-improve-v2-kubelink
  • Loading branch information
ayu-devtron committed Oct 7, 2024
2 parents e6ec309 + 41c89b8 commit 793116a
Show file tree
Hide file tree
Showing 24 changed files with 2,306 additions and 1,752 deletions.
131 changes: 10 additions & 121 deletions kubelink/bean/Bean.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package bean

import (
"github.com/devtron-labs/common-lib/utils/k8s/commonBean"
remoteConnectionBean "github.com/devtron-labs/common-lib/utils/remoteConnection/bean"
client "github.com/devtron-labs/kubelink/grpc"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"time"
Expand All @@ -36,13 +36,13 @@ type HelmAppValues struct {
}

type AppDetail struct {
ApplicationStatus *HealthStatusCode `json:"applicationStatus"`
ReleaseStatus *ReleaseStatus `json:"releaseStatus"`
LastDeployed time.Time `json:"lastDeployed"`
ChartMetadata *ChartMetadata `json:"chartMetadata"`
ResourceTreeResponse *ResourceTreeResponse `json:"resourceTreeResponse"`
EnvironmentDetails *client.EnvironmentDetails `json:"environmentDetails"`
ReleaseExists bool `json:"releaseExists"`
ApplicationStatus *commonBean.HealthStatusCode `json:"applicationStatus"`
ReleaseStatus *ReleaseStatus `json:"releaseStatus"`
LastDeployed time.Time `json:"lastDeployed"`
ChartMetadata *ChartMetadata `json:"chartMetadata"`
ResourceTreeResponse *ResourceTreeResponse `json:"resourceTreeResponse"`
EnvironmentDetails *client.EnvironmentDetails `json:"environmentDetails"`
ReleaseExists bool `json:"releaseExists"`
}

type ReleaseStatus struct {
Expand Down Expand Up @@ -75,16 +75,6 @@ const (
// StatusPendingRollback indicates that an rollback operation is underway.
StatusPendingRollback HelmReleaseStatus = "pending-rollback"
)
const (
ContainersType = "Containers"
ContainersNamesType = "ContainerNames"
InitContainersNamesType = "InitContainerNames"
EphemeralContainersInfoType = "EphemeralContainerInfo"
EphemeralContainersStatusType = "EphemeralContainerStatuses"
StatusReason = "Status Reason"
Node = "Node"
RestartCount = "Restart Count"
)

type ChartMetadata struct {
// The name of the chart
Expand All @@ -103,94 +93,12 @@ type ChartMetadata struct {

type ResourceTreeResponse struct {
*ApplicationTree
PodMetadata []*PodMetadata `json:"podMetadata"`
PodMetadata []*commonBean.PodMetadata `json:"podMetadata"`
}

// ApplicationTree holds nodes which belongs to the application
type ApplicationTree struct {
Nodes []*ResourceNode `json:"nodes,omitempty" protobuf:"bytes,1,rep,name=nodes"`
}

// ResourceNode contains information about live resource and its children
type ResourceNode struct {
*ResourceRef `json:",inline" protobuf:"bytes,1,opt,name=resourceRef"`
ParentRefs []*ResourceRef `json:"parentRefs,omitempty" protobuf:"bytes,2,opt,name=parentRefs"`
NetworkingInfo *ResourceNetworkingInfo `json:"networkingInfo,omitempty" protobuf:"bytes,4,opt,name=networkingInfo"`
ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,5,opt,name=resourceVersion"`
Health *HealthStatus `json:"health,omitempty" protobuf:"bytes,7,opt,name=health"`
IsHibernated bool `json:"isHibernated"`
CanBeHibernated bool `json:"canBeHibernated"`
Info []InfoItem `json:"info,omitempty"`
Port []int64 `json:"port,omitempty"`
CreatedAt string `json:"createdAt,omitempty"`
IsHook bool `json:"isHook,omitempty"`
HookType string `json:"hookType,omitempty"`
// UpdateRevision is used when a pod's owner is a StatefulSet for identifying if the pod is new or old
UpdateRevision string `json:"updateRevision,omitempty"`
// DeploymentPodHash is the podHash in deployment manifest and is used to compare replicaSet's podHash for identifying new vs old pod
DeploymentPodHash string `json:"deploymentPodHash,omitempty"`
DeploymentCollisionCount *int32 `json:"deploymentCollisionCount,omitempty"`
// RolloutCurrentPodHash is the podHash in rollout manifest and is used to compare replicaSet's podHash for identifying new vs old pod
RolloutCurrentPodHash string `json:"rolloutCurrentPodHash,omitempty"`
}

// ResourceRef includes fields which unique identify resource
type ResourceRef struct {
Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
Version string `json:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
Kind string `json:"kind,omitempty" protobuf:"bytes,3,opt,name=kind"`
Namespace string `json:"namespace,omitempty" protobuf:"bytes,4,opt,name=namespace"`
Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"`
UID string `json:"uid,omitempty" protobuf:"bytes,6,opt,name=uid"`
Manifest unstructured.Unstructured `json:"-"`
}

func (r *ResourceRef) GetGvk() schema.GroupVersionKind {
if r == nil {
return schema.GroupVersionKind{}
}
return schema.GroupVersionKind{
Group: r.Group,
Version: r.Version,
Kind: r.Kind,
}
}

// ResourceNetworkingInfo holds networking resource related information
type ResourceNetworkingInfo struct {
Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,3,opt,name=labels"`
}

type HealthStatus struct {
Status HealthStatusCode `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
}

type HealthStatusCode = string

const (
HealthStatusUnknown HealthStatusCode = "Unknown"
HealthStatusProgressing HealthStatusCode = "Progressing"
HealthStatusHealthy HealthStatusCode = "Healthy"
HealthStatusSuspended HealthStatusCode = "Suspended"
HealthStatusDegraded HealthStatusCode = "Degraded"
HealthStatusMissing HealthStatusCode = "Missing"
HealthStatusHibernated HealthStatusCode = "Hibernated"
HealthStatusPartiallyHibernated HealthStatusCode = "Partially Hibernated"
)

type PodMetadata struct {
Name string `json:"name"`
UID string `json:"uid"`
Containers []string `json:"containers"`
InitContainers []string `json:"initContainers"`
IsNew bool `json:"isNew"`
EphemeralContainers []*EphemeralContainerData `json:"ephemeralContainers"`
}

type EphemeralContainerData struct {
Name string `json:"name"`
IsExternal bool `json:"isExternal"`
Nodes []*commonBean.ResourceNode `json:"nodes,omitempty" protobuf:"bytes,1,rep,name=nodes"`
}

type HelmReleaseDetailRequest struct {
Expand Down Expand Up @@ -231,25 +139,6 @@ type DesiredOrLiveManifest struct {
LiveManifestFetchErrorCode int32 `json:"liveManifestFetchErrorCode"`
}

// use value field as generic type
// InfoItem contains arbitrary, human readable information about an application
type InfoItem struct {
// Name is a human readable title for this piece of information.
Name string `json:"name,omitempty"`
// Value is human readable content.
Value interface{} `json:"value,omitempty"`
}

type EphemeralContainerInfo struct {
Name string
Command []string
}

type EphemeralContainerStatusesInfo struct {
Name string
State v1.ContainerState
}

type ClusterInfo struct {
ClusterId int `json:"clusterId"`
ClusterName string `json:"clusterName"`
Expand Down
7 changes: 4 additions & 3 deletions kubelink/converter/ClusterBeanConverter.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package converter

import (
k8sUtils "github.com/devtron-labs/common-lib/utils/k8s"
"github.com/devtron-labs/common-lib/utils/k8s/commonBean"
"github.com/devtron-labs/kubelink/bean"
client "github.com/devtron-labs/kubelink/grpc"
repository "github.com/devtron-labs/kubelink/pkg/cluster"
Expand Down Expand Up @@ -84,9 +85,9 @@ func (impl *ClusterBeanConverterImpl) GetClusterInfo(c *repository.Cluster) *bea
InsecureSkipTLSVerify: c.InsecureSkipTlsVerify,
}
if c.InsecureSkipTlsVerify == false {
clusterInfo.KeyData = config[k8sUtils.TlsKey]
clusterInfo.CertData = config[k8sUtils.CertData]
clusterInfo.CAData = config[k8sUtils.CertificateAuthorityData]
clusterInfo.KeyData = config[commonBean.TlsKey]
clusterInfo.CertData = config[commonBean.CertData]
clusterInfo.CAData = config[commonBean.CertificateAuthorityData]
}
}
return clusterInfo
Expand Down
4 changes: 2 additions & 2 deletions kubelink/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ toolchain go1.22.6

require (
github.com/caarlos0/env v3.5.0+incompatible
github.com/davecgh/go-spew v1.1.1
github.com/devtron-labs/common-lib v0.16.1-0.20240923063129-ff2dc035435e
github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e
github.com/evanphx/json-patch v5.7.0+incompatible
github.com/go-pg/pg v6.15.1+incompatible
github.com/golang/protobuf v1.5.4
Expand Down Expand Up @@ -52,6 +51,7 @@ require (
github.com/containerd/log v0.1.0 // indirect
github.com/containerd/platforms v0.2.1 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/distribution/reference v0.6.0 // indirect
github.com/docker/cli v27.1.0+incompatible // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
Expand Down
4 changes: 2 additions & 2 deletions kubelink/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxG
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/devtron-labs/common-lib v0.16.1-0.20240923063129-ff2dc035435e h1:siyAoJz9Nq26JrTzmSGd02EOmPV86tUgzgBW1Y5bSVU=
github.com/devtron-labs/common-lib v0.16.1-0.20240923063129-ff2dc035435e/go.mod h1:I+B+0ZeOV1Qv8dE/uNAFXOhw7lxfD6FqK6KzTBLBY7E=
github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e h1:UkRCn1BERRBTILtYOZAFl8vCQW3CifHk0Kfexw6WWmg=
github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/distribution/distribution/v3 v3.0.0-beta.1 h1:X+ELTxPuZ1Xe5MsD3kp2wfGUhc8I+MPfRis8dZ818Ic=
Expand Down
Loading

0 comments on commit 793116a

Please sign in to comment.