Skip to content

Commit

Permalink
chore: remove omit empty from some attributes (#718)
Browse files Browse the repository at this point in the history
* chore: remove omit empty from some attributes

* chore: update test fixtures
  • Loading branch information
yashmehrotra authored May 1, 2024
1 parent 68fdf1d commit 73e2ba5
Show file tree
Hide file tree
Showing 17 changed files with 234 additions and 16 deletions.
12 changes: 6 additions & 6 deletions models/components.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,22 @@ type Component struct {
AgentID uuid.UUID `json:"agent_id,omitempty"`
ExternalId string `json:"external_id,omitempty"` //nolint
ParentId *uuid.UUID `json:"parent_id,omitempty"` //nolint
Name string `json:"name,omitempty"`
Name string `json:"name"`
Text string `json:"text,omitempty"`
TopologyType string `json:"topology_type,omitempty"`
Namespace string `json:"namespace,omitempty"`
Namespace string `json:"namespace"`
Labels types.JSONStringMap `json:"labels,omitempty" gorm:"default:null"`
Hidden bool `json:"hidden,omitempty"`
Silenced bool `json:"silenced,omitempty"`
Status types.ComponentStatus `json:"status,omitempty"`
Description string `json:"description,omitempty"`
Status types.ComponentStatus `json:"status"`
Description string `json:"description"`
Lifecycle string `json:"lifecycle,omitempty"`
LogSelectors types.LogSelectors `json:"logs,omitempty" gorm:"column:log_selectors;default:null"`
Tooltip string `json:"tooltip,omitempty"`
StatusReason string `json:"status_reason,omitempty"`
StatusReason string `json:"status_reason"`
Schedule string `json:"schedule,omitempty"`
Icon string `json:"icon,omitempty"`
Type string `json:"type,omitempty"`
Type string `json:"type"`
Owner string `json:"owner,omitempty"`
Selectors types.ResourceSelectors `json:"selectors,omitempty" gorm:"resourceSelectors;default:null" swaggerignore:"true"`
Configs types.ConfigQueries `json:"configs,omitempty" gorm:"default:null"`
Expand Down
12 changes: 6 additions & 6 deletions models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ type ConfigItem struct {
AgentID uuid.UUID `json:"agent_id,omitempty"`
ConfigClass string `json:"config_class" faker:"oneof:File,EC2Instance,KubernetesPod" `
ExternalID pq.StringArray `gorm:"type:[]text" json:"external_id,omitempty"`
Type *string `json:"type,omitempty"`
Status *string `json:"status,omitempty" gorm:"default:null"`
Type *string `json:"type"`
Status *string `json:"status" gorm:"default:null"`
Ready bool `json:"ready"`
Health *Health `json:"health"`
Name *string `json:"name,omitempty" faker:"name" `
Description *string `json:"description,omitempty"`
Config *string `json:"config,omitempty" `
Source *string `json:"source,omitempty" `
Name *string `json:"name,omitempty" faker:"name"`
Description *string `json:"description"`
Config *string `json:"config"`
Source *string `json:"source,omitempty"`
ParentID *uuid.UUID `json:"parent_id,omitempty" faker:"-"`
Path string `json:"path,omitempty" faker:"-"`
CostPerMinute float64 `gorm:"column:cost_per_minute;default:null" json:"cost_per_minute,omitempty"`
Expand Down
12 changes: 8 additions & 4 deletions models/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,14 @@ func TestConfig_AsMap(t *testing.T) {
},
removeFields: []string{"updated_at", "health", "created_at", "config_class", "last_scraped_time"},
want: map[string]any{
"name": "dummy-canary",
"agent_id": "00000000-0000-0000-0000-000000000000",
"ready": false,
"id": id.String(),
"name": "dummy-canary",
"agent_id": "00000000-0000-0000-0000-000000000000",
"ready": false,
"description": nil,
"config": nil,
"status": nil,
"type": nil,
"id": id.String(),
},
},
}
Expand Down
9 changes: 9 additions & 0 deletions tests/fixtures/expectations/topology_child_tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"external_id": "dummy/node-a",
"parent_id": "018681fe-b27e-7627-72c2-ad18e93f72f4",
"name": "node-a",
"namespace": "",
"status": "healthy",
"description": "",
"tooltip": "Node A",
"status_reason": "",
"icon": "icon-kubernetes-node",
"type": "KubernetesNode",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c.018681fe-b27e-7627-72c2-ad18e93f72f4",
Expand All @@ -24,8 +27,11 @@
"external_id": "dummy/logistics-api-574dc95b5d-mp64w",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"name": "logistics-api-574dc95b5d-mp64w",
"namespace": "",
"status": "healthy",
"description": "",
"tooltip": "Logistic API Pod",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"properties": [
Expand All @@ -52,8 +58,11 @@
"external_id": "dummy/logistics-ui-676b85b87c-tjjcp",
"parent_id": "018681ff-559f-7183-19d1-7d898b4e1413",
"name": "logistics-ui-676b85b87c-tjjcp",
"namespace": "",
"status": "healthy",
"description": "",
"tooltip": "Logistic UI Pod",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"properties": [
Expand Down
33 changes: 33 additions & 0 deletions tests/fixtures/expectations/topology_cluster_component_tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/cluster",
"name": "cluster",
"namespace": "",
"status": "healthy",
"description": "",
"tooltip": "Kubernetes Cluster",
"status_reason": "",
"icon": "icon-cluster",
"type": "KubernetesCluster",
"summary": {
Expand All @@ -27,8 +30,11 @@
"external_id": "dummy/nodes",
"parent_id": "018681fe-8156-4b91-d178-caf8b3c2818c",
"name": "Nodes",
"namespace": "",
"status": "healthy",
"description": "",
"tooltip": "Kubernetes Nodes",
"status_reason": "",
"icon": "icon-kubernetes-node",
"type": "KubernetesNodes",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c",
Expand All @@ -48,7 +54,10 @@
"id": "018681ff-227e-4d71-b38e-0693cc862213",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "node-b",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-node",
"type": "KubernetesNode",
"summary": {
Expand All @@ -66,7 +75,10 @@
"id": "018681ff-e578-a926-e366-d2dc0646eafa",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "logistics-worker-79cb67d8f5-lr66n",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"summary": {
Expand All @@ -81,7 +93,10 @@
"id": "018681fe-f5aa-37e9-83f7-47b5b0232d5e",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "node-a",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-node",
"type": "KubernetesNode",
"summary": {
Expand All @@ -94,7 +109,10 @@
"id": "018681ff-80ed-d10d-21ef-c74f152b085b",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "logistics-api-574dc95b5d-mp64w",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"summary": {
Expand All @@ -107,7 +125,10 @@
"id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "logistics-ui-676b85b87c-tjjcp",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"summary": {
Expand All @@ -126,8 +147,11 @@
"external_id": "dummy/pods",
"parent_id": "018681fe-8156-4b91-d178-caf8b3c2818c",
"name": "Pods",
"namespace": "",
"status": "healthy",
"description": "",
"tooltip": "Kubernetes Pods",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPods",
"path": "018681fe-8156-4b91-d178-caf8b3c2818c",
Expand All @@ -142,7 +166,10 @@
"id": "018681ff-80ed-d10d-21ef-c74f152b085b",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "logistics-api-574dc95b5d-mp64w",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"summary": {
Expand All @@ -155,7 +182,10 @@
"id": "018681ff-b6c1-a14d-2fd4-8c7dac94cddd",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "logistics-ui-676b85b87c-tjjcp",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"summary": {
Expand All @@ -168,7 +198,10 @@
"id": "018681ff-e578-a926-e366-d2dc0646eafa",
"agent_id": "00000000-0000-0000-0000-000000000000",
"name": "logistics-worker-79cb67d8f5-lr66n",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"icon": "icon-kubernetes-pod",
"type": "KubernetesPod",
"summary": {
Expand Down
3 changes: 3 additions & 0 deletions tests/fixtures/expectations/topology_depth_1_child_tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
"external_id": "dummy/logistics-api",
"parent_id": "018681fc-e54f-bd4f-42be-068a9a69eeb5",
"name": "logistics-api",
"namespace": "",
"labels": {
"telemetry": "enabled"
},
"status": "warning",
"description": "",
"status_reason": "",
"type": "Application",
"owner": "logistics-team",
"path": "018681fc-e54f-bd4f-42be-068a9a69eeb5",
Expand Down
12 changes: 12 additions & 0 deletions tests/fixtures/expectations/topology_depth_1_root_tree.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/logistics",
"name": "logistics",
"namespace": "",
"labels": {
"telemetry": "enabled"
},
"status": "warning",
"description": "",
"status_reason": "",
"type": "Entity",
"owner": "logistics-team",
"summary": {
Expand Down Expand Up @@ -38,8 +41,11 @@
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/cluster",
"name": "cluster",
"namespace": "",
"status": "healthy",
"description": "",
"tooltip": "Kubernetes Cluster",
"status_reason": "",
"icon": "icon-cluster",
"type": "KubernetesCluster",
"summary": {
Expand All @@ -59,7 +65,10 @@
"agent_id": "ebd4cbf7-267e-48f9-a050-eca12e535ce1",
"external_id": "dummy/payments-api",
"name": "payments-api",
"namespace": "",
"status": "healthy",
"description": "",
"status_reason": "",
"type": "Application",
"summary": {
"healthy": 1
Expand All @@ -73,10 +82,13 @@
"agent_id": "00000000-0000-0000-0000-000000000000",
"external_id": "dummy/flux",
"name": "flux",
"namespace": "",
"labels": {
"fluxcd.io/name": "flux"
},
"status": "healthy",
"description": "",
"status_reason": "",
"type": "Flux",
"summary": {
"healthy": 1
Expand Down
Loading

0 comments on commit 73e2ba5

Please sign in to comment.