Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ linters-settings:
alias: typedCore
- pkg: k8s.io/api/apps/v1
alias: apps
- pkg: k8s.io/api/batch/v1
alias: batch
gci:
sections:
- standard
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/apps/v1/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
package v1

import (
batchv1 "k8s.io/api/batch/v1"
batch "k8s.io/api/batch/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"

"github.com/arangodb/kube-arangodb/pkg/apis/apps"
Expand All @@ -44,8 +44,8 @@ type ArangoJobList struct {
type ArangoJob struct {
meta.TypeMeta `json:",inline"`
meta.ObjectMeta `json:"metadata,omitempty"`
Spec ArangoJobSpec `json:"spec,omitempty"`
Status batchv1.JobStatus `json:"status,omitempty"`
Spec ArangoJobSpec `json:"spec,omitempty"`
Status batch.JobStatus `json:"status,omitempty"`
}

// AsOwner creates an OwnerReference for the given job
Expand Down
6 changes: 3 additions & 3 deletions pkg/apis/apps/v1/job_spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

package v1

import batchv1 "k8s.io/api/batch/v1"
import batch "k8s.io/api/batch/v1"

type ArangoJobSpec struct {
ArangoDeploymentName string `json:"arangoDeploymentName"`
JobTemplate *batchv1.JobSpec `json:"jobTemplate,omitempty"`
ArangoDeploymentName string `json:"arangoDeploymentName"`
JobTemplate *batch.JobSpec `json:"jobTemplate,omitempty"`
}
16 changes: 8 additions & 8 deletions pkg/handlers/job/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"os"
"reflect"

batchv1 "k8s.io/api/batch/v1"
batch "k8s.io/api/batch/v1"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -92,20 +92,20 @@ func (h *handler) Handle(item operation.Item) error {
return nil
}

func (h *handler) createFailedJobStatusWithEvent(msg string, job *appsApi.ArangoJob) batchv1.JobStatus {
func (h *handler) createFailedJobStatusWithEvent(msg string, job *appsApi.ArangoJob) batch.JobStatus {
h.eventRecorder.Warning(job, jobError, msg)
return batchv1.JobStatus{
Conditions: []batchv1.JobCondition{
return batch.JobStatus{
Conditions: []batch.JobCondition{
{
Type: batchv1.JobFailed,
Type: batch.JobFailed,
Status: core.ConditionUnknown,
Message: msg,
},
},
}
}

func (h *handler) processArangoJob(job *appsApi.ArangoJob) batchv1.JobStatus {
func (h *handler) processArangoJob(job *appsApi.ArangoJob) batch.JobStatus {
existingJob, err := h.kubeClient.BatchV1().Jobs(job.Namespace).Get(context.Background(), job.Name, meta.GetOptions{})
if err != nil {
if k8sutil.IsNotFound(err) {
Expand All @@ -127,8 +127,8 @@ func (h *handler) processArangoJob(job *appsApi.ArangoJob) batchv1.JobStatus {
return existingJob.Status
}

func (h *handler) prepareK8sJob(job *appsApi.ArangoJob) (*batchv1.Job, error) {
k8sJob := batchv1.Job{}
func (h *handler) prepareK8sJob(job *appsApi.ArangoJob) (*batch.Job, error) {
k8sJob := batch.Job{}
k8sJob.Name = job.Name
k8sJob.Namespace = job.Namespace
k8sJob.Spec = *job.Spec.JobTemplate
Expand Down
4 changes: 2 additions & 2 deletions pkg/handlers/job/handler_scheduler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
batchv1 "k8s.io/api/batch/v1"
batch "k8s.io/api/batch/v1"
"k8s.io/apimachinery/pkg/util/uuid"

"github.com/arangodb/kube-arangodb/pkg/operatorV2/operation"
Expand Down Expand Up @@ -93,5 +93,5 @@ func Test_Job_Create_Error_If_Deployment_Not_Exist(t *testing.T) {
// Assert
newJob := refreshArangoJob(t, handler, job)
require.True(t, len(newJob.Status.Conditions) == 1)
require.True(t, newJob.Status.Conditions[0].Type == batchv1.JobFailed)
require.True(t, newJob.Status.Conditions[0].Type == batch.JobFailed)
}
10 changes: 5 additions & 5 deletions pkg/handlers/job/job_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"testing"

"github.com/stretchr/testify/require"
batchv1 "k8s.io/api/batch/v1"
batch "k8s.io/api/batch/v1"
core "k8s.io/api/core/v1"
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/uuid"
Expand Down Expand Up @@ -86,7 +86,7 @@ func createArangoJob(t *testing.T, h *handler, jobs ...*appsApi.ArangoJob) {
}
}

func createK8sJob(t *testing.T, h *handler, jobs ...*batchv1.Job) {
func createK8sJob(t *testing.T, h *handler, jobs ...*batch.Job) {
for _, job := range jobs {
_, err := h.kubeClient.BatchV1().Jobs(job.Namespace).Create(context.Background(), job, meta.CreateOptions{})
require.NoError(t, err)
Expand All @@ -113,7 +113,7 @@ func newArangoJob(name, namespace, deployment string) *appsApi.ArangoJob {
},
Spec: appsApi.ArangoJobSpec{
ArangoDeploymentName: deployment,
JobTemplate: &batchv1.JobSpec{
JobTemplate: &batch.JobSpec{
Template: core.PodTemplateSpec{
Spec: core.PodSpec{
Containers: []core.Container{
Expand Down Expand Up @@ -145,8 +145,8 @@ func newArangoDeployment(name, namespace string) *deploymentApi.ArangoDeployment
}
}

func newK8sJob(name, namespace string) *batchv1.Job {
return &batchv1.Job{
func newK8sJob(name, namespace string) *batch.Job {
return &batch.Job{
ObjectMeta: meta.ObjectMeta{
Name: name,
Namespace: namespace,
Expand Down