Skip to content

Commit

Permalink
Merge pull request #82 from kubescape/apigroup
Browse files Browse the repository at this point in the history
keep group/version together in apiVersion label
  • Loading branch information
matthyx committed Nov 30, 2023
2 parents bbc3f6e + 27b926e commit ba83f84
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
5 changes: 1 addition & 4 deletions instanceidhandler/v1/instanceidhandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"fmt"

"github.com/kubescape/k8s-interface/instanceidhandler"
"github.com/kubescape/k8s-interface/k8sinterface"
"github.com/kubescape/k8s-interface/names"
)

Expand Down Expand Up @@ -120,10 +119,8 @@ func (id *InstanceID) GetHashed() string {
}

func (id *InstanceID) GetLabels() map[string]string {
group, version := k8sinterface.SplitApiVersion(id.GetAPIVersion())
return map[string]string{
ApiGroupMetadataKey: group,
ApiVersionMetadataKey: version,
ApiVersionMetadataKey: id.GetAPIVersion(),
NamespaceMetadataKey: id.GetNamespace(),
KindMetadataKey: id.GetKind(),
NameMetadataKey: id.GetName(),
Expand Down
7 changes: 2 additions & 5 deletions instanceidhandler/v1/instanceidhandler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ func TestInstanceID(t *testing.T) {
t.Errorf("can't create instance ID from service")
}
expectedLabels := map[string]string{
ApiGroupMetadataKey: "apps",
ApiVersionMetadataKey: "v1",
ApiVersionMetadataKey: "apps/v1",
NamespaceMetadataKey: "default",
KindMetadataKey: "ReplicaSet",
NameMetadataKey: "nginx-84f5585d68",
Expand All @@ -121,8 +120,7 @@ func TestInstanceID(t *testing.T) {
}

expectedLabels = map[string]string{
ApiGroupMetadataKey: "batch",
ApiVersionMetadataKey: "v1",
ApiVersionMetadataKey: "batch/v1",
NamespaceMetadataKey: "default",
KindMetadataKey: "Job",
NameMetadataKey: "nginx-job",
Expand All @@ -134,7 +132,6 @@ func TestInstanceID(t *testing.T) {
}

expectedLabels = map[string]string{
ApiGroupMetadataKey: "",
ApiVersionMetadataKey: "v1",
NamespaceMetadataKey: "default",
KindMetadataKey: "Pod",
Expand Down

0 comments on commit ba83f84

Please sign in to comment.