Skip to content

Commit

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

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

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

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

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

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

0 comments on commit 2855cc9

Please sign in to comment.