Skip to content

Commit

Permalink
Reformat all imports using gci linter.
Browse files Browse the repository at this point in the history
  • Loading branch information
mbobrovskyi committed Sep 29, 2024
1 parent 425ece1 commit 02e136c
Show file tree
Hide file tree
Showing 23 changed files with 73 additions and 45 deletions.
23 changes: 20 additions & 3 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ linters-settings:
disabled-checks:
- appendAssign
- exitAfterDefer
goimports:
local-prefixes: sigs.k8s.io/kueue
govet:
enable:
- nilness
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(sigs.k8s.io/kueue) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports.
# Skip generated files.
# Default: true
skip-generated: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
perfsprint:
int-conversion: false
errorf: true
Expand All @@ -34,9 +51,9 @@ linters:
- dupword
- durationcheck
- fatcontext
- gci
- ginkgolinter
- gocritic
- goimports
- govet
- loggercheck
- misspell
Expand Down
23 changes: 20 additions & 3 deletions cmd/experimental/kjobctl/.golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,28 @@ linters-settings:
disabled-checks:
- appendAssign
- exitAfterDefer
goimports:
local-prefixes: sigs.k8s.io/kueue
govet:
enable:
- nilness
gci:
# Section configuration to compare against.
# Section names are case-insensitive and may contain parameters in ().
# The default order of sections is `standard > default > custom > blank > dot > alias`,
# If `custom-order` is `true`, it follows the order of `sections` option.
# Default: ["standard", "default"]
sections:
- standard # Standard section: captures all standard packages.
- default # Default section: contains all imports that could not be matched to another section type.
- prefix(sigs.k8s.io/kueue) # Custom section: groups all imports with the specified Prefix.
- blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled.
- dot # Dot section: contains all dot imports.
# Skip generated files.
# Default: true
skip-generated: true
# Enable custom order of sections.
# If `true`, make the section order the same as the order of `sections`.
# Default: false
custom-order: true
perfsprint:
int-conversion: false
errorf: true
Expand All @@ -32,9 +49,9 @@ linters:
- copyloopvar
- dupword
- durationcheck
- gci
- ginkgolinter
- gocritic
- goimports
- govet
- loggercheck
- misspell
Expand Down
3 changes: 2 additions & 1 deletion cmd/experimental/kjobctl/pkg/cmd/util/client_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ import (
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/dynamic"
k8s "k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"

kueueversioned "sigs.k8s.io/kueue/client-go/clientset/versioned"
kjobctlversioned "sigs.k8s.io/kueue/cmd/experimental/kjobctl/client-go/clientset/versioned"

_ "k8s.io/client-go/plugin/pkg/client/auth"
)

type ClientGetter interface {
Expand Down
3 changes: 1 addition & 2 deletions cmd/experimental/kjobctl/pkg/cmd/util/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ limitations under the License.
package util

import (
"k8s.io/klog/v2"

"github.com/spf13/cobra"
"k8s.io/klog/v2"
)

func AddFieldSelectorFlagVar(cmd *cobra.Command, p *string) {
Expand Down
9 changes: 4 additions & 5 deletions cmd/kueue/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@ import (
"net/http"
"os"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
"k8s.io/client-go/util/flowcontrol"

zaplog "go.uber.org/zap"
"go.uber.org/zap/zapcore"
corev1 "k8s.io/api/core/v1"
Expand All @@ -39,6 +34,7 @@ import (
"k8s.io/client-go/discovery"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/client-go/util/flowcontrol"
"k8s.io/utils/ptr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/healthz"
Expand Down Expand Up @@ -67,6 +63,9 @@ import (
"sigs.k8s.io/kueue/pkg/visibility"
"sigs.k8s.io/kueue/pkg/webhooks"

// Import all Kubernetes client auth plugins (e.g. Azure, GCP, OIDC, etc.)
// to ensure that exec-entrypoint and run can make use of them.
_ "k8s.io/client-go/plugin/pkg/client/auth"
// Ensure linking of the job controllers.
_ "sigs.k8s.io/kueue/pkg/controller/jobs"
)
Expand Down
6 changes: 2 additions & 4 deletions cmd/kueuectl/app/list/list_pods_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ import (
kftraining "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1"
rayv1 "github.com/ray-project/kuberay/ray-operator/apis/ray/v1"
rayutils "github.com/ray-project/kuberay/ray-operator/controllers/ray/utils"

kueuecmdtesting "sigs.k8s.io/kueue/cmd/kueuectl/app/testing"

batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -45,8 +42,9 @@ import (
"k8s.io/cli-runtime/pkg/resource"
restfake "k8s.io/client-go/rest/fake"
"k8s.io/utils/strings/slices"

jobsetapi "sigs.k8s.io/jobset/api/jobset/v1alpha2"

kueuecmdtesting "sigs.k8s.io/kueue/cmd/kueuectl/app/testing"
)

type podTestCase struct {
Expand Down
1 change: 0 additions & 1 deletion cmd/kueuectl/app/stop/stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package stop

import (
"github.com/spf13/cobra"

"k8s.io/cli-runtime/pkg/genericiooptions"
"k8s.io/kubectl/pkg/util/templates"

Expand Down
3 changes: 2 additions & 1 deletion cmd/kueuectl/app/util/client_getter.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ import (
"k8s.io/cli-runtime/pkg/resource"
"k8s.io/client-go/dynamic"
k8s "k8s.io/client-go/kubernetes"
_ "k8s.io/client-go/plugin/pkg/client/auth"

"sigs.k8s.io/kueue/client-go/clientset/versioned"

_ "k8s.io/client-go/plugin/pkg/client/auth"
)

type ClientGetter interface {
Expand Down
3 changes: 2 additions & 1 deletion pkg/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/webhook"

configapi "sigs.k8s.io/kueue/apis/config/v1beta1"
_ "sigs.k8s.io/kueue/pkg/controller/jobs"
"sigs.k8s.io/kueue/pkg/controller/jobs/job"

_ "sigs.k8s.io/kueue/pkg/controller/jobs"
)

func TestLoad(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ import (
kueuealpha "sigs.k8s.io/kueue/apis/kueue/v1alpha1"
kueue "sigs.k8s.io/kueue/apis/kueue/v1beta1"
"sigs.k8s.io/kueue/pkg/controller/jobframework"
_ "sigs.k8s.io/kueue/pkg/controller/jobs"
"sigs.k8s.io/kueue/pkg/util/slices"
utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
testingjob "sigs.k8s.io/kueue/pkg/util/testingjobs/job"

_ "sigs.k8s.io/kueue/pkg/controller/jobs"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion pkg/controller/jobframework/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,13 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

configapi "sigs.k8s.io/kueue/apis/config/v1beta1"
_ "sigs.k8s.io/kueue/pkg/controller/jobs"
"sigs.k8s.io/kueue/pkg/util/kubeversion"
utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
testingjob "sigs.k8s.io/kueue/pkg/util/testingjobs/job"
testingmpijob "sigs.k8s.io/kueue/pkg/util/testingjobs/mpijob"

_ "sigs.k8s.io/kueue/pkg/controller/jobs"

. "sigs.k8s.io/kueue/pkg/controller/jobframework"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/client/interceptor"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"

"sigs.k8s.io/controller-runtime/pkg/client"

kueuealpha "sigs.k8s.io/kueue/apis/kueue/v1alpha1"
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/jobs/pod/pod_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ import (
"sigs.k8s.io/kueue/pkg/constants"
controllerconsts "sigs.k8s.io/kueue/pkg/controller/constants"
"sigs.k8s.io/kueue/pkg/controller/jobframework"
_ "sigs.k8s.io/kueue/pkg/controller/jobs/job"
_ "sigs.k8s.io/kueue/pkg/controller/jobs/raycluster"
"sigs.k8s.io/kueue/pkg/podset"
utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
testingpod "sigs.k8s.io/kueue/pkg/util/testingjobs/pod"

_ "sigs.k8s.io/kueue/pkg/controller/jobs/job"
_ "sigs.k8s.io/kueue/pkg/controller/jobs/raycluster"
)

func TestPodsReady(t *testing.T) {
Expand Down
5 changes: 3 additions & 2 deletions pkg/controller/jobs/pod/pod_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ import (
configapi "sigs.k8s.io/kueue/apis/config/v1beta1"
"sigs.k8s.io/kueue/pkg/constants"
"sigs.k8s.io/kueue/pkg/controller/jobframework"
utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
testingpod "sigs.k8s.io/kueue/pkg/util/testingjobs/pod"

_ "sigs.k8s.io/kueue/pkg/controller/jobs/kubeflow/jobs"
_ "sigs.k8s.io/kueue/pkg/controller/jobs/mpijob"
_ "sigs.k8s.io/kueue/pkg/controller/jobs/raycluster"
utiltesting "sigs.k8s.io/kueue/pkg/util/testing"
testingpod "sigs.k8s.io/kueue/pkg/util/testingjobs/pod"
)

func TestDefault(t *testing.T) {
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/jobs/raycluster/raycluster_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/jobs/rayjob/rayjob_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/klog/v2"
"k8s.io/utils/ptr"

ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"sigs.k8s.io/controller-runtime/pkg/webhook/admission"
Expand Down
1 change: 0 additions & 1 deletion pkg/util/kubeversion/kubeversion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"k8s.io/apimachinery/pkg/runtime"
versionutil "k8s.io/apimachinery/pkg/util/version"
"k8s.io/apimachinery/pkg/version"

fakediscovery "k8s.io/client-go/discovery/fake"
fakeclientset "k8s.io/client-go/kubernetes/fake"
kubetesting "k8s.io/client-go/testing"
Expand Down
13 changes: 7 additions & 6 deletions pkg/visibility/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,20 @@ import (
"os"
"strings"

openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
utilversion "k8s.io/apiserver/pkg/util/version"
"k8s.io/client-go/pkg/version"
ctrl "sigs.k8s.io/controller-runtime"

generatedopenapi "sigs.k8s.io/kueue/apis/visibility/openapi"
visibilityv1alpha1 "sigs.k8s.io/kueue/apis/visibility/v1alpha1"
visibilityv1beta1 "sigs.k8s.io/kueue/apis/visibility/v1beta1"
"sigs.k8s.io/kueue/pkg/queue"
"sigs.k8s.io/kueue/pkg/visibility/api"

openapinamer "k8s.io/apiserver/pkg/endpoints/openapi"
genericapiserver "k8s.io/apiserver/pkg/server"
genericoptions "k8s.io/apiserver/pkg/server/options"
utilversion "k8s.io/apiserver/pkg/util/version"
"k8s.io/client-go/pkg/version"
_ "k8s.io/component-base/metrics/prometheus/restclient" // for client-go metrics registration
ctrl "sigs.k8s.io/controller-runtime"
)

var (
Expand Down
4 changes: 1 addition & 3 deletions test/e2e/multikueue/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,17 @@ import (
"os/exec"

"github.com/google/go-cmp/cmp/cmpopts"
kfmpi "github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1"
kftraining "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1"
"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

batchv1 "k8s.io/api/batch/v1"
corev1 "k8s.io/api/core/v1"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
versionutil "k8s.io/apimachinery/pkg/util/version"
"k8s.io/utils/ptr"

kfmpi "github.com/kubeflow/mpi-operator/pkg/apis/kubeflow/v2beta1"
"sigs.k8s.io/controller-runtime/pkg/client"
jobset "sigs.k8s.io/jobset/api/jobset/v1alpha2"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"sigs.k8s.io/kueue/pkg/controller/jobframework"
workloadpaddlejob "sigs.k8s.io/kueue/pkg/controller/jobs/kubeflow/jobs/paddlejob"
"sigs.k8s.io/kueue/pkg/controller/jobs/kubeflow/kubeflowjob"

"sigs.k8s.io/kueue/pkg/util/testing"
testingpaddlejob "sigs.k8s.io/kueue/pkg/util/testingjobs/paddlejob"
kftesting "sigs.k8s.io/kueue/test/integration/controller/jobs/kubeflow"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,12 @@ import (
"sigs.k8s.io/kueue/pkg/controller/constants"
"sigs.k8s.io/kueue/pkg/controller/jobframework"
workloadraycluster "sigs.k8s.io/kueue/pkg/controller/jobs/raycluster"
_ "sigs.k8s.io/kueue/pkg/controller/jobs/rayjob" // to enable the framework
"sigs.k8s.io/kueue/pkg/util/testing"
testingraycluster "sigs.k8s.io/kueue/pkg/util/testingjobs/raycluster"
testingrayjob "sigs.k8s.io/kueue/pkg/util/testingjobs/rayjob"
"sigs.k8s.io/kueue/test/util"

_ "sigs.k8s.io/kueue/pkg/controller/jobs/rayjob" // to enable the framework
)

const (
Expand Down
2 changes: 0 additions & 2 deletions test/integration/multikueue/multikueue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ import (
"sigs.k8s.io/kueue/pkg/controller/admissionchecks/multikueue"
workloadjob "sigs.k8s.io/kueue/pkg/controller/jobs/job"
workloadjobset "sigs.k8s.io/kueue/pkg/controller/jobs/jobset"

workloadpaddlejob "sigs.k8s.io/kueue/pkg/controller/jobs/kubeflow/jobs/paddlejob"
workloadpytorchjob "sigs.k8s.io/kueue/pkg/controller/jobs/kubeflow/jobs/pytorchjob"
workloadtfjob "sigs.k8s.io/kueue/pkg/controller/jobs/kubeflow/jobs/tfjob"
Expand All @@ -55,7 +54,6 @@ import (
testingjob "sigs.k8s.io/kueue/pkg/util/testingjobs/job"
testingjobset "sigs.k8s.io/kueue/pkg/util/testingjobs/jobset"
testingmpijob "sigs.k8s.io/kueue/pkg/util/testingjobs/mpijob"

testingpaddlejob "sigs.k8s.io/kueue/pkg/util/testingjobs/paddlejob"
testingpytorchjob "sigs.k8s.io/kueue/pkg/util/testingjobs/pytorchjob"
testingtfjob "sigs.k8s.io/kueue/pkg/util/testingjobs/tfjob"
Expand Down

0 comments on commit 02e136c

Please sign in to comment.