Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: minimal topology details for rest of the children #288

Merged
merged 4 commits into from
Oct 5, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions envvar.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func GetSecretFromCache(c kubernetes.Interface, namespace, name, key string) (st
}
secret, err := c.CoreV1().Secrets(namespace).Get(context.Background(), name, metav1.GetOptions{})
if secret == nil {
return "", fmt.Errorf("Could not get contents of secret %v from namespace %v: %v", name, namespace, err)
return "", fmt.Errorf("could not get contents of secret %v from namespace %v: %w", name, namespace, err)
}

value, ok := secret.Data[key]
Expand All @@ -58,7 +58,7 @@ func GetSecretFromCache(c kubernetes.Interface, namespace, name, key string) (st
for k := range secret.Data {
names = append(names, k)
}
return "", fmt.Errorf("Could not find key %v in secret %v (%s)", key, name, strings.Join(names, ", "))
return "", fmt.Errorf("could not find key %v in secret %v (%s)", key, name, strings.Join(names, ", "))
}
envCache.Set(id, string(value), 5*time.Minute)
return string(value), nil
Expand All @@ -71,7 +71,7 @@ func GetConfigMapFromCache(c kubernetes.Interface, namespace, name, key string)
}
configMap, err := c.CoreV1().ConfigMaps(namespace).Get(context.Background(), name, metav1.GetOptions{})
if configMap == nil {
return "", fmt.Errorf("Could not get contents of configmap %v from namespace %v: %v", name, namespace, err)
return "", fmt.Errorf("could not get contents of configmap %v from namespace %v: %w", name, namespace, err)
}

value, ok := configMap.Data[key]
Expand All @@ -80,7 +80,7 @@ func GetConfigMapFromCache(c kubernetes.Interface, namespace, name, key string)
for k := range configMap.Data {
names = append(names, k)
}
return "", fmt.Errorf("Could not find key %v in configmap %v (%s)", key, name, strings.Join(names, ", "))
return "", fmt.Errorf("could not find key %v in configmap %v (%s)", key, name, strings.Join(names, ", "))
}
envCache.Set(id, string(value), 5*time.Minute)
return string(value), nil
Expand Down
25 changes: 25 additions & 0 deletions fixtures/dummy/components.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package dummy

import (
"fmt"

"github.com/flanksource/duty/models"
"github.com/flanksource/duty/types"
"github.com/google/uuid"
Expand Down Expand Up @@ -72,76 +74,99 @@ var ClusterComponent = models.Component{
Type: "KubernetesCluster",
Status: types.ComponentStatusHealthy,
CreatedAt: DummyCreatedAt,
Tooltip: "Kubernetes Cluster",
Icon: "icon-cluster",
}

var NodesComponent = models.Component{
ID: uuid.MustParse("018681fe-b27e-7627-72c2-ad18e93f72f4"),
Name: "Nodes",
Icon: "icon-kubernetes-node",
Tooltip: "Kubernetes Nodes",
ExternalId: "dummy/nodes",
Type: "KubernetesNodes",
Status: types.ComponentStatusHealthy,
ParentId: &ClusterComponent.ID,
CreatedAt: DummyCreatedAt,
Path: ClusterComponent.ID.String(),
}

var NodeA = models.Component{
ID: uuid.MustParse("018681fe-f5aa-37e9-83f7-47b5b0232d5e"),
Name: "node-a",
Icon: "icon-kubernetes-node",
Tooltip: "Node A",
ExternalId: "dummy/node-a",
Type: "KubernetesNode",
Status: types.ComponentStatusHealthy,
ParentId: &NodesComponent.ID,
CreatedAt: DummyCreatedAt,
Path: fmt.Sprintf("%s.%s", ClusterComponent.ID.String(), NodesComponent.ID.String()),
}

var NodeB = models.Component{
ID: uuid.MustParse("018681ff-227e-4d71-b38e-0693cc862213"),
Name: "node-b",
Icon: "icon-kubernetes-node",
Tooltip: "Node B",
ExternalId: "dummy/node-b",
Type: "KubernetesNode",
Status: types.ComponentStatusHealthy,
ParentId: &NodesComponent.ID,
CreatedAt: DummyCreatedAt,
Path: fmt.Sprintf("%s.%s", ClusterComponent.ID.String(), NodesComponent.ID.String()),
}

var PodsComponent = models.Component{
ID: uuid.MustParse("018681ff-559f-7183-19d1-7d898b4e1413"),
Name: "Pods",
Icon: "icon-kubernetes-pod",
Tooltip: "Kubernetes Pods",
ExternalId: "dummy/pods",
Type: "KubernetesPods",
Status: types.ComponentStatusHealthy,
ParentId: &ClusterComponent.ID,
CreatedAt: DummyCreatedAt,
Path: ClusterComponent.ID.String(),
}

var LogisticsAPIPod = models.Component{
ID: uuid.MustParse("018681ff-80ed-d10d-21ef-c74f152b085b"),
Name: "logistics-api-574dc95b5d-mp64w",
Icon: "icon-kubernetes-pod",
Tooltip: "Logistic API Pod",
ExternalId: "dummy/logistics-api-574dc95b5d-mp64w",
Type: "KubernetesPod",
Status: types.ComponentStatusHealthy,
ParentId: &PodsComponent.ID,
CreatedAt: DummyCreatedAt,
Path: fmt.Sprintf("%s.%s", ClusterComponent.ID.String(), PodsComponent.ID.String()),
}

var LogisticsUIPod = models.Component{
ID: uuid.MustParse("018681ff-b6c1-a14d-2fd4-8c7dac94cddd"),
Name: "logistics-ui-676b85b87c-tjjcp",
Icon: "icon-kubernetes-pod",
Tooltip: "Logistic UI Pod",
Type: "KubernetesPod",
ExternalId: "dummy/logistics-ui-676b85b87c-tjjcp",
Status: types.ComponentStatusHealthy,
ParentId: &PodsComponent.ID,
CreatedAt: DummyCreatedAt,
Path: fmt.Sprintf("%s.%s", ClusterComponent.ID.String(), PodsComponent.ID.String()),
}

var LogisticsWorkerPod = models.Component{
ID: uuid.MustParse("018681ff-e578-a926-e366-d2dc0646eafa"),
Name: "logistics-worker-79cb67d8f5-lr66n",
Icon: "icon-kubernetes-pod",
Tooltip: "Logistic Worker Pod",
ExternalId: "dummy/logistics-worker-79cb67d8f5-lr66n",
Type: "KubernetesPod",
Status: types.ComponentStatusHealthy,
ParentId: &PodsComponent.ID,
CreatedAt: DummyCreatedAt,
Path: fmt.Sprintf("%s.%s", ClusterComponent.ID.String(), PodsComponent.ID.String()),
}

var PaymentsAPI = models.Component{
Expand Down
68 changes: 46 additions & 22 deletions fixtures/expectations/topology_child_tree.json
Original file line number Diff line number Diff line change
@@ -1,19 +1,8 @@
{
"components": [
{
"id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e",
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/node-a",
"parent_id": "018681fe-b27e-7627-72c2-ad18e93f72f4",
"name": "node-a",
"status": "healthy",
"type": "KubernetesNode",
"summary": {
"healthy": 2
},
"is_leaf": false,
"created_at": "2023-01-01T05:29:00+05:30",
"updated_at": "2023-01-01T05:29:00+05:30",
"children": ["018681ff-80ed-d10d-21ef-c74f152b085b", "018681ff-b6c1-a14d-2fd4-8c7dac94cddd"],
"components": [
{
"id": "018681ff-80ed-d10d-21ef-c74f152b085b",
Expand All @@ -29,9 +18,10 @@
"is_leaf": false,
"created_at": "2023-01-01T05:29:00+05:30",
"updated_at": "2023-01-01T05:29:00+05:30",
"parents": [
"018681fe-f5aa-37e9-83f7-47b5b0232d5e"
]
"icon": "icon-kubernetes-pod",
"tooltip": "Logistic API Pod",
"parents": ["018681fe-f5aa-37e9-83f7-47b5b0232d5e"],
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413"
},
{
"id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd",
Expand All @@ -47,15 +37,49 @@
"is_leaf": false,
"created_at": "2023-01-01T05:29:00+05:30",
"updated_at": "2023-01-01T05:29:00+05:30",
"parents": [
"018681fe-f5aa-37e9-83f7-47b5b0232d5e"
]
"icon": "icon-kubernetes-pod",
"tooltip": "Logistic UI Pod",
"parents": ["018681fe-f5aa-37e9-83f7-47b5b0232d5e"],
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681ff-559f-7183-19d1-7d898b4e1413"
},
{
"agent_id": "00000000-0000-0000-0000-000000000000",
"id": "018681ff-80ed-d10d-21ef-c74f152b085b",
"is_leaf": false,
"name": "logistics-api-574dc95b5d-mp64w",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"parents": ["018681fe-f5aa-37e9-83f7-47b5b0232d5e"],
"status": "healthy",
"summary": {
"healthy": 1
},
"type": "KubernetesPod"
},
{
"agent_id": "00000000-0000-0000-0000-000000000000",
"id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd",
"is_leaf": false,
"name": "logistics-ui-676b85b87c-tjjcp",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"parents": ["018681fe-f5aa-37e9-83f7-47b5b0232d5e"],
"status": "healthy",
"summary": {
"healthy": 1
},
"type": "KubernetesPod"
}
],
"children": [
"018681ff-80ed-d10d-21ef-c74f152b085b",
"018681ff-b6c1-a14d-2fd4-8c7dac94cddd"
]
"external_id": "dummy/node-a",
"icon": "icon-kubernetes-node",
"id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e",
"is_leaf": false,
"name": "node-a",
"parent_id": "018681fe-b27e-7627-72c2-ad18e93f72f4",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681fe-b27e-7627-72c2-ad18e93f72f4",
"status": "healthy",
"summary": { "healthy": 4 },
"tooltip": "Node A",
"type": "KubernetesNode"
}
],
"healthStatuses": [
Expand Down
Loading
Loading