Skip to content

Commit

Permalink
Merge pull request #285 from leanix/bugfix/missing-namespace-cronjob
Browse files Browse the repository at this point in the history
Add namespacename to cronjob
  • Loading branch information
timmeyerLeanIX authored Jun 9, 2023
2 parents 6c84e7a + 2747121 commit f0d9cbb
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
5 changes: 3 additions & 2 deletions pkg/iris/workloads/services/mapper/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/iris/workloads/services/mapper/mapping_test.go
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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{
Expand Down
2 changes: 2 additions & 0 deletions pkg/kubernetes/deployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ 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"
)

// 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
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/kubernetes/deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -12,6 +13,7 @@ import (
)

func TestDeployments(t *testing.T) {
logger.Init()
// create a dummy nodes
dummyDeployments := []runtime.Object{
&appsv1.Deployment{
Expand Down

0 comments on commit f0d9cbb

Please sign in to comment.