Skip to content

Commit 2dffd64

Browse files
authored
Merge pull request #5 from devtron-labs/appdetails-improve-v2-kubelink
feat: Appdetails improve v2 kubelink
2 parents c5886d8 + 3eda1f4 commit 2dffd64

File tree

24 files changed

+2308
-1752
lines changed

24 files changed

+2308
-1752
lines changed

kubelink/bean/Bean.go

+10-121
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
package bean
1818

1919
import (
20+
"github.com/devtron-labs/common-lib/utils/k8s/commonBean"
2021
remoteConnectionBean "github.com/devtron-labs/common-lib/utils/remoteConnection/bean"
2122
client "github.com/devtron-labs/kubelink/grpc"
22-
v1 "k8s.io/api/core/v1"
2323
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
2424
"k8s.io/apimachinery/pkg/runtime/schema"
2525
"time"
@@ -36,13 +36,13 @@ type HelmAppValues struct {
3636
}
3737

3838
type AppDetail struct {
39-
ApplicationStatus *HealthStatusCode `json:"applicationStatus"`
40-
ReleaseStatus *ReleaseStatus `json:"releaseStatus"`
41-
LastDeployed time.Time `json:"lastDeployed"`
42-
ChartMetadata *ChartMetadata `json:"chartMetadata"`
43-
ResourceTreeResponse *ResourceTreeResponse `json:"resourceTreeResponse"`
44-
EnvironmentDetails *client.EnvironmentDetails `json:"environmentDetails"`
45-
ReleaseExists bool `json:"releaseExists"`
39+
ApplicationStatus *commonBean.HealthStatusCode `json:"applicationStatus"`
40+
ReleaseStatus *ReleaseStatus `json:"releaseStatus"`
41+
LastDeployed time.Time `json:"lastDeployed"`
42+
ChartMetadata *ChartMetadata `json:"chartMetadata"`
43+
ResourceTreeResponse *ResourceTreeResponse `json:"resourceTreeResponse"`
44+
EnvironmentDetails *client.EnvironmentDetails `json:"environmentDetails"`
45+
ReleaseExists bool `json:"releaseExists"`
4646
}
4747

4848
type ReleaseStatus struct {
@@ -75,16 +75,6 @@ const (
7575
// StatusPendingRollback indicates that an rollback operation is underway.
7676
StatusPendingRollback HelmReleaseStatus = "pending-rollback"
7777
)
78-
const (
79-
ContainersType = "Containers"
80-
ContainersNamesType = "ContainerNames"
81-
InitContainersNamesType = "InitContainerNames"
82-
EphemeralContainersInfoType = "EphemeralContainerInfo"
83-
EphemeralContainersStatusType = "EphemeralContainerStatuses"
84-
StatusReason = "Status Reason"
85-
Node = "Node"
86-
RestartCount = "Restart Count"
87-
)
8878

8979
type ChartMetadata struct {
9080
// The name of the chart
@@ -103,94 +93,12 @@ type ChartMetadata struct {
10393

10494
type ResourceTreeResponse struct {
10595
*ApplicationTree
106-
PodMetadata []*PodMetadata `json:"podMetadata"`
96+
PodMetadata []*commonBean.PodMetadata `json:"podMetadata"`
10797
}
10898

10999
// ApplicationTree holds nodes which belongs to the application
110100
type ApplicationTree struct {
111-
Nodes []*ResourceNode `json:"nodes,omitempty" protobuf:"bytes,1,rep,name=nodes"`
112-
}
113-
114-
// ResourceNode contains information about live resource and its children
115-
type ResourceNode struct {
116-
*ResourceRef `json:",inline" protobuf:"bytes,1,opt,name=resourceRef"`
117-
ParentRefs []*ResourceRef `json:"parentRefs,omitempty" protobuf:"bytes,2,opt,name=parentRefs"`
118-
NetworkingInfo *ResourceNetworkingInfo `json:"networkingInfo,omitempty" protobuf:"bytes,4,opt,name=networkingInfo"`
119-
ResourceVersion string `json:"resourceVersion,omitempty" protobuf:"bytes,5,opt,name=resourceVersion"`
120-
Health *HealthStatus `json:"health,omitempty" protobuf:"bytes,7,opt,name=health"`
121-
IsHibernated bool `json:"isHibernated"`
122-
CanBeHibernated bool `json:"canBeHibernated"`
123-
Info []InfoItem `json:"info,omitempty"`
124-
Port []int64 `json:"port,omitempty"`
125-
CreatedAt string `json:"createdAt,omitempty"`
126-
IsHook bool `json:"isHook,omitempty"`
127-
HookType string `json:"hookType,omitempty"`
128-
// UpdateRevision is used when a pod's owner is a StatefulSet for identifying if the pod is new or old
129-
UpdateRevision string `json:"updateRevision,omitempty"`
130-
// DeploymentPodHash is the podHash in deployment manifest and is used to compare replicaSet's podHash for identifying new vs old pod
131-
DeploymentPodHash string `json:"deploymentPodHash,omitempty"`
132-
DeploymentCollisionCount *int32 `json:"deploymentCollisionCount,omitempty"`
133-
// RolloutCurrentPodHash is the podHash in rollout manifest and is used to compare replicaSet's podHash for identifying new vs old pod
134-
RolloutCurrentPodHash string `json:"rolloutCurrentPodHash,omitempty"`
135-
}
136-
137-
// ResourceRef includes fields which unique identify resource
138-
type ResourceRef struct {
139-
Group string `json:"group,omitempty" protobuf:"bytes,1,opt,name=group"`
140-
Version string `json:"version,omitempty" protobuf:"bytes,2,opt,name=version"`
141-
Kind string `json:"kind,omitempty" protobuf:"bytes,3,opt,name=kind"`
142-
Namespace string `json:"namespace,omitempty" protobuf:"bytes,4,opt,name=namespace"`
143-
Name string `json:"name,omitempty" protobuf:"bytes,5,opt,name=name"`
144-
UID string `json:"uid,omitempty" protobuf:"bytes,6,opt,name=uid"`
145-
Manifest unstructured.Unstructured `json:"-"`
146-
}
147-
148-
func (r *ResourceRef) GetGvk() schema.GroupVersionKind {
149-
if r == nil {
150-
return schema.GroupVersionKind{}
151-
}
152-
return schema.GroupVersionKind{
153-
Group: r.Group,
154-
Version: r.Version,
155-
Kind: r.Kind,
156-
}
157-
}
158-
159-
// ResourceNetworkingInfo holds networking resource related information
160-
type ResourceNetworkingInfo struct {
161-
Labels map[string]string `json:"labels,omitempty" protobuf:"bytes,3,opt,name=labels"`
162-
}
163-
164-
type HealthStatus struct {
165-
Status HealthStatusCode `json:"status,omitempty" protobuf:"bytes,1,opt,name=status"`
166-
Message string `json:"message,omitempty" protobuf:"bytes,2,opt,name=message"`
167-
}
168-
169-
type HealthStatusCode = string
170-
171-
const (
172-
HealthStatusUnknown HealthStatusCode = "Unknown"
173-
HealthStatusProgressing HealthStatusCode = "Progressing"
174-
HealthStatusHealthy HealthStatusCode = "Healthy"
175-
HealthStatusSuspended HealthStatusCode = "Suspended"
176-
HealthStatusDegraded HealthStatusCode = "Degraded"
177-
HealthStatusMissing HealthStatusCode = "Missing"
178-
HealthStatusHibernated HealthStatusCode = "Hibernated"
179-
HealthStatusPartiallyHibernated HealthStatusCode = "Partially Hibernated"
180-
)
181-
182-
type PodMetadata struct {
183-
Name string `json:"name"`
184-
UID string `json:"uid"`
185-
Containers []string `json:"containers"`
186-
InitContainers []string `json:"initContainers"`
187-
IsNew bool `json:"isNew"`
188-
EphemeralContainers []*EphemeralContainerData `json:"ephemeralContainers"`
189-
}
190-
191-
type EphemeralContainerData struct {
192-
Name string `json:"name"`
193-
IsExternal bool `json:"isExternal"`
101+
Nodes []*commonBean.ResourceNode `json:"nodes,omitempty" protobuf:"bytes,1,rep,name=nodes"`
194102
}
195103

196104
type HelmReleaseDetailRequest struct {
@@ -231,25 +139,6 @@ type DesiredOrLiveManifest struct {
231139
LiveManifestFetchErrorCode int32 `json:"liveManifestFetchErrorCode"`
232140
}
233141

234-
// use value field as generic type
235-
// InfoItem contains arbitrary, human readable information about an application
236-
type InfoItem struct {
237-
// Name is a human readable title for this piece of information.
238-
Name string `json:"name,omitempty"`
239-
// Value is human readable content.
240-
Value interface{} `json:"value,omitempty"`
241-
}
242-
243-
type EphemeralContainerInfo struct {
244-
Name string
245-
Command []string
246-
}
247-
248-
type EphemeralContainerStatusesInfo struct {
249-
Name string
250-
State v1.ContainerState
251-
}
252-
253142
type ClusterInfo struct {
254143
ClusterId int `json:"clusterId"`
255144
ClusterName string `json:"clusterName"`

kubelink/converter/ClusterBeanConverter.go

+4-3
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package converter
1818

1919
import (
2020
k8sUtils "github.com/devtron-labs/common-lib/utils/k8s"
21+
"github.com/devtron-labs/common-lib/utils/k8s/commonBean"
2122
"github.com/devtron-labs/kubelink/bean"
2223
client "github.com/devtron-labs/kubelink/grpc"
2324
repository "github.com/devtron-labs/kubelink/pkg/cluster"
@@ -84,9 +85,9 @@ func (impl *ClusterBeanConverterImpl) GetClusterInfo(c *repository.Cluster) *bea
8485
InsecureSkipTLSVerify: c.InsecureSkipTlsVerify,
8586
}
8687
if c.InsecureSkipTlsVerify == false {
87-
clusterInfo.KeyData = config[k8sUtils.TlsKey]
88-
clusterInfo.CertData = config[k8sUtils.CertData]
89-
clusterInfo.CAData = config[k8sUtils.CertificateAuthorityData]
88+
clusterInfo.KeyData = config[commonBean.TlsKey]
89+
clusterInfo.CertData = config[commonBean.CertData]
90+
clusterInfo.CAData = config[commonBean.CertificateAuthorityData]
9091
}
9192
}
9293
return clusterInfo

kubelink/go.mod

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ toolchain go1.22.6
66

77
require (
88
github.com/caarlos0/env v3.5.0+incompatible
9-
github.com/davecgh/go-spew v1.1.1
10-
github.com/devtron-labs/common-lib v0.16.1-0.20240923063129-ff2dc035435e
9+
github.com/devtron-labs/common-lib v0.18.1-0.20241001061923-eda545dc839e
1110
github.com/evanphx/json-patch v5.7.0+incompatible
1211
github.com/go-pg/pg v6.15.1+incompatible
1312
github.com/golang/protobuf v1.5.4
@@ -52,6 +51,7 @@ require (
5251
github.com/containerd/log v0.1.0 // indirect
5352
github.com/containerd/platforms v0.2.1 // indirect
5453
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
54+
github.com/davecgh/go-spew v1.1.1 // indirect
5555
github.com/distribution/reference v0.6.0 // indirect
5656
github.com/docker/cli v27.1.0+incompatible // indirect
5757
github.com/docker/distribution v2.8.3+incompatible // indirect
@@ -177,6 +177,7 @@ require (
177177
)
178178

179179
replace (
180+
github.com/devtron-labs/common-lib => github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241007082211-c5886d8a9988
180181
go.opentelemetry.io/otel/metric => go.opentelemetry.io/otel/metric v1.18.0
181182
// https://github.com/kubernetes/kubernetes/issues/79384#issuecomment-505627280
182183
k8s.io/api => k8s.io/api v0.29.0

kubelink/go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxG
7979
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
8080
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
8181
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
82-
github.com/devtron-labs/common-lib v0.16.1-0.20240923063129-ff2dc035435e h1:siyAoJz9Nq26JrTzmSGd02EOmPV86tUgzgBW1Y5bSVU=
83-
github.com/devtron-labs/common-lib v0.16.1-0.20240923063129-ff2dc035435e/go.mod h1:I+B+0ZeOV1Qv8dE/uNAFXOhw7lxfD6FqK6KzTBLBY7E=
82+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241007082211-c5886d8a9988 h1:nb8tGcgpt2Eu7ceuWhwAKf+07s/0RZ1ASYsGhZ7swSQ=
83+
github.com/devtron-labs/devtron-services/common-lib v0.0.0-20241007082211-c5886d8a9988/go.mod h1:KpKnF4OSpQNDJmb4wVZq3Za88ePBw4xec2GOAGRm5UQ=
8484
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
8585
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
8686
github.com/distribution/distribution/v3 v3.0.0-beta.1 h1:X+ELTxPuZ1Xe5MsD3kp2wfGUhc8I+MPfRis8dZ818Ic=

0 commit comments

Comments
 (0)