Skip to content

Commit

Permalink
feat(ingress): updated test case
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitphatak committed Sep 5, 2023
1 parent 841f544 commit a75883a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion internal/store/ingress.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,13 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
Value: 1,
})
} else {
apiGroup := ""
if path.Backend.Resource.APIGroup != nil {
apiGroup = *path.Backend.Resource.APIGroup
}
ms = append(ms, &metric.Metric{
LabelKeys: []string{"host", "path", "api_group", "kind", "name"},
LabelValues: []string{rule.Host, path.Path, *path.Backend.Resource.APIGroup, path.Backend.Resource.Kind, path.Backend.Resource.Name},
LabelValues: []string{rule.Host, path.Path, apiGroup, path.Backend.Resource.Kind, path.Backend.Resource.Name},
Value: 1,
})
}
Expand Down
2 changes: 1 addition & 1 deletion internal/store/ingress_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestIngressStore(t *testing.T) {
kube_ingress_info{namespace="ns4",ingress="ingress4",ingressclass="_default"} 1
kube_ingress_created{namespace="ns4",ingress="ingress4"} 1.501569018e+09
kube_ingress_path{namespace="ns4",ingress="ingress4",host="somehost",path="/somepath",service_name="someservice",service_port="1234"} 1
kube_ingress_path{namespace="ns4",ingress="ingress4",host="somehost",path="/somepath2",service_name="",service_port=""} 1
kube_ingress_path{namespace="ns4",ingress="ingress4",host="somehost",path="/somepath2",api_group="",kind="somekind",name="somename"} 1
`,
MetricNames: []string{"kube_ingress_info", "kube_ingress_metadata_resource_version", "kube_ingress_created", "kube_ingress_labels", "kube_ingress_path", "kube_ingress_tls"},
},
Expand Down

0 comments on commit a75883a

Please sign in to comment.