Skip to content

Commit 2eacf10

Browse files
authored
[Linter] [Imports] Standardize k8s.io/api/batch/v1 (#1057)
1 parent d77b4d0 commit 2eacf10

File tree

6 files changed

+23
-21
lines changed

6 files changed

+23
-21
lines changed

.golangci.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ linters-settings:
3838
alias: typedCore
3939
- pkg: k8s.io/api/apps/v1
4040
alias: apps
41+
- pkg: k8s.io/api/batch/v1
42+
alias: batch
4143
gci:
4244
sections:
4345
- standard

pkg/apis/apps/v1/job.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
package v1
2222

2323
import (
24-
batchv1 "k8s.io/api/batch/v1"
24+
batch "k8s.io/api/batch/v1"
2525
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
2626

2727
"github.com/arangodb/kube-arangodb/pkg/apis/apps"
@@ -44,8 +44,8 @@ type ArangoJobList struct {
4444
type ArangoJob struct {
4545
meta.TypeMeta `json:",inline"`
4646
meta.ObjectMeta `json:"metadata,omitempty"`
47-
Spec ArangoJobSpec `json:"spec,omitempty"`
48-
Status batchv1.JobStatus `json:"status,omitempty"`
47+
Spec ArangoJobSpec `json:"spec,omitempty"`
48+
Status batch.JobStatus `json:"status,omitempty"`
4949
}
5050

5151
// AsOwner creates an OwnerReference for the given job

pkg/apis/apps/v1/job_spec.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@
2020

2121
package v1
2222

23-
import batchv1 "k8s.io/api/batch/v1"
23+
import batch "k8s.io/api/batch/v1"
2424

2525
type ArangoJobSpec struct {
26-
ArangoDeploymentName string `json:"arangoDeploymentName"`
27-
JobTemplate *batchv1.JobSpec `json:"jobTemplate,omitempty"`
26+
ArangoDeploymentName string `json:"arangoDeploymentName"`
27+
JobTemplate *batch.JobSpec `json:"jobTemplate,omitempty"`
2828
}

pkg/handlers/job/handler.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"os"
2727
"reflect"
2828

29-
batchv1 "k8s.io/api/batch/v1"
29+
batch "k8s.io/api/batch/v1"
3030
core "k8s.io/api/core/v1"
3131
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3232
"k8s.io/client-go/kubernetes"
@@ -92,20 +92,20 @@ func (h *handler) Handle(item operation.Item) error {
9292
return nil
9393
}
9494

95-
func (h *handler) createFailedJobStatusWithEvent(msg string, job *appsApi.ArangoJob) batchv1.JobStatus {
95+
func (h *handler) createFailedJobStatusWithEvent(msg string, job *appsApi.ArangoJob) batch.JobStatus {
9696
h.eventRecorder.Warning(job, jobError, msg)
97-
return batchv1.JobStatus{
98-
Conditions: []batchv1.JobCondition{
97+
return batch.JobStatus{
98+
Conditions: []batch.JobCondition{
9999
{
100-
Type: batchv1.JobFailed,
100+
Type: batch.JobFailed,
101101
Status: core.ConditionUnknown,
102102
Message: msg,
103103
},
104104
},
105105
}
106106
}
107107

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

130-
func (h *handler) prepareK8sJob(job *appsApi.ArangoJob) (*batchv1.Job, error) {
131-
k8sJob := batchv1.Job{}
130+
func (h *handler) prepareK8sJob(job *appsApi.ArangoJob) (*batch.Job, error) {
131+
k8sJob := batch.Job{}
132132
k8sJob.Name = job.Name
133133
k8sJob.Namespace = job.Namespace
134134
k8sJob.Spec = *job.Spec.JobTemplate

pkg/handlers/job/handler_scheduler_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import (
2424
"testing"
2525

2626
"github.com/stretchr/testify/require"
27-
batchv1 "k8s.io/api/batch/v1"
27+
batch "k8s.io/api/batch/v1"
2828
"k8s.io/apimachinery/pkg/util/uuid"
2929

3030
"github.com/arangodb/kube-arangodb/pkg/operatorV2/operation"
@@ -93,5 +93,5 @@ func Test_Job_Create_Error_If_Deployment_Not_Exist(t *testing.T) {
9393
// Assert
9494
newJob := refreshArangoJob(t, handler, job)
9595
require.True(t, len(newJob.Status.Conditions) == 1)
96-
require.True(t, newJob.Status.Conditions[0].Type == batchv1.JobFailed)
96+
require.True(t, newJob.Status.Conditions[0].Type == batch.JobFailed)
9797
}

pkg/handlers/job/job_suite_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import (
2525
"testing"
2626

2727
"github.com/stretchr/testify/require"
28-
batchv1 "k8s.io/api/batch/v1"
28+
batch "k8s.io/api/batch/v1"
2929
core "k8s.io/api/core/v1"
3030
meta "k8s.io/apimachinery/pkg/apis/meta/v1"
3131
"k8s.io/apimachinery/pkg/util/uuid"
@@ -86,7 +86,7 @@ func createArangoJob(t *testing.T, h *handler, jobs ...*appsApi.ArangoJob) {
8686
}
8787
}
8888

89-
func createK8sJob(t *testing.T, h *handler, jobs ...*batchv1.Job) {
89+
func createK8sJob(t *testing.T, h *handler, jobs ...*batch.Job) {
9090
for _, job := range jobs {
9191
_, err := h.kubeClient.BatchV1().Jobs(job.Namespace).Create(context.Background(), job, meta.CreateOptions{})
9292
require.NoError(t, err)
@@ -113,7 +113,7 @@ func newArangoJob(name, namespace, deployment string) *appsApi.ArangoJob {
113113
},
114114
Spec: appsApi.ArangoJobSpec{
115115
ArangoDeploymentName: deployment,
116-
JobTemplate: &batchv1.JobSpec{
116+
JobTemplate: &batch.JobSpec{
117117
Template: core.PodTemplateSpec{
118118
Spec: core.PodSpec{
119119
Containers: []core.Container{
@@ -145,8 +145,8 @@ func newArangoDeployment(name, namespace string) *deploymentApi.ArangoDeployment
145145
}
146146
}
147147

148-
func newK8sJob(name, namespace string) *batchv1.Job {
149-
return &batchv1.Job{
148+
func newK8sJob(name, namespace string) *batch.Job {
149+
return &batch.Job{
150150
ObjectMeta: meta.ObjectMeta{
151151
Name: name,
152152
Namespace: namespace,

0 commit comments

Comments
 (0)