diff --git a/pkg/iris/workloads/services/mapper/cronjob.go b/pkg/iris/workloads/services/mapper/cronjob.go index ba11be9..4595b58 100644 --- a/pkg/iris/workloads/services/mapper/cronjob.go +++ b/pkg/iris/workloads/services/mapper/cronjob.go @@ -50,8 +50,9 @@ func (m *workloadMapper) CreateCronjobEcst(cluster models.Cluster, cronJob batch NoOfNodes: cluster.NoOfNodes, K8sVersion: cluster.K8sVersion, }, - ServiceName: service, - Timestamp: cronJob.CreationTimestamp.UTC().Format(time.RFC3339), + NamespaceName: cronJob.Namespace, + ServiceName: service, + Timestamp: cronJob.CreationTimestamp.UTC().Format(time.RFC3339), } return mappedDeployment } diff --git a/pkg/iris/workloads/services/mapper/mapping_test.go b/pkg/iris/workloads/services/mapper/mapping_test.go index 442c87a..7f17c09 100644 --- a/pkg/iris/workloads/services/mapper/mapping_test.go +++ b/pkg/iris/workloads/services/mapper/mapping_test.go @@ -1,8 +1,12 @@ package mapper import ( + "testing" + "time" + "github.com/leanix/leanix-k8s-connector/pkg/iris/workloads/models" "github.com/leanix/leanix-k8s-connector/pkg/kubernetes" + "github.com/leanix/leanix-k8s-connector/pkg/logger" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" @@ -12,11 +16,10 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/client-go/kubernetes/fake" "k8s.io/utils/pointer" - "testing" - "time" ) func Test_MapWorkloads_success(t *testing.T) { + logger.Init() dummyServices := []runtime.Object{ &corev1.Service{ Spec: corev1.ServiceSpec{ diff --git a/pkg/kubernetes/deployments.go b/pkg/kubernetes/deployments.go index 593a0ca..03d5876 100644 --- a/pkg/kubernetes/deployments.go +++ b/pkg/kubernetes/deployments.go @@ -3,6 +3,7 @@ package kubernetes import ( "context" + "github.com/leanix/leanix-k8s-connector/pkg/logger" v1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -10,6 +11,7 @@ import ( // Deployments gets the list of deployments in a namespace func (k *API) Deployments(namespace string) (*v1.DeploymentList, error) { deployments, err := k.Client.AppsV1().Deployments(namespace).List(context.Background(), metav1.ListOptions{}) + logger.Infof("list of workload deployments: %v", deployments) if err != nil { return nil, err } diff --git a/pkg/kubernetes/deployments_test.go b/pkg/kubernetes/deployments_test.go index 5ddbebf..854b245 100644 --- a/pkg/kubernetes/deployments_test.go +++ b/pkg/kubernetes/deployments_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "github.com/leanix/leanix-k8s-connector/pkg/logger" "github.com/stretchr/testify/assert" appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -12,6 +13,7 @@ import ( ) func TestDeployments(t *testing.T) { + logger.Init() // create a dummy nodes dummyDeployments := []runtime.Object{ &appsv1.Deployment{