Skip to content

Enforce consistent import ordering #29791

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
5 changes: 5 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ linters:
disable-all: true
enable:
- nosprintfhostport
- goimports
presets: []
fast: true
run:
timeout: 5m

linters-settings:
goimports-reviser:
local-prefixes: github.com/openshift/origin
15 changes: 8 additions & 7 deletions cmd/openshift-tests/openshift-tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ import (
"time"

"github.com/openshift/library-go/pkg/serviceability"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
utilflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/kubectl/pkg/util/templates"

"github.com/openshift/origin/pkg/cmd"
collectdiskcertificates "github.com/openshift/origin/pkg/cmd/openshift-tests/collect-disk-certificates"
"github.com/openshift/origin/pkg/cmd/openshift-tests/dev"
Expand All @@ -28,13 +36,6 @@ import (
versioncmd "github.com/openshift/origin/pkg/cmd/openshift-tests/version"
testginkgo "github.com/openshift/origin/pkg/test/ginkgo"
exutil "github.com/openshift/origin/test/extended/util"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
utilflag "k8s.io/component-base/cli/flag"
"k8s.io/component-base/logs"
"k8s.io/kubectl/pkg/util/templates"
)

func main() {
Expand Down
9 changes: 4 additions & 5 deletions cmd/update-tls-artifacts/update-tls-artifacts.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@ import (
"fmt"
"os"

"github.com/openshift/origin/pkg/cmd/update-tls-artifacts/generate-owners"

"github.com/openshift/library-go/pkg/serviceability"
exutil "github.com/openshift/origin/test/extended/util"
"github.com/spf13/pflag"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/kubectl/pkg/util/templates"

generate_owners "github.com/openshift/origin/pkg/cmd/update-tls-artifacts/generate-owners"
exutil "github.com/openshift/origin/test/extended/util"
)

func main() {
Expand Down
13 changes: 6 additions & 7 deletions examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import (
"path/filepath"
"testing"

app "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/apitesting"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/yaml"
"k8s.io/klog/v2"

appsv1 "github.com/openshift/api/apps/v1"
buildv1 "github.com/openshift/api/build/v1"
imagev1 "github.com/openshift/api/image/v1"
routev1 "github.com/openshift/api/route/v1"
templatev1 "github.com/openshift/api/template/v1"
app "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/apitesting"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/yaml"
klog "k8s.io/klog/v2"
)

func walkJSONFiles(inDir string, fn func(name, path string, data []byte)) error {
Expand Down
5 changes: 2 additions & 3 deletions hack/jsonformat/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package main

import (
"encoding/json"
"io/ioutil"
"log"
"os"
)

import "io/ioutil"
import "os"

func main() {
if len(os.Args) != 2 {
log.Fatal("Usage: jsonformat.go <filename>")
Expand Down
3 changes: 1 addition & 2 deletions hack/listtests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import (
"bytes"
"flag"
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"regexp"
"sort"
"strings"

"log"
)

var reLine = regexp.MustCompile("^\\s*(\\w+)\\s+(\\w+)\\s+(.+)$")
Expand Down
3 changes: 2 additions & 1 deletion pkg/alerts/types.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package alerts

import (
"github.com/openshift/origin/pkg/monitor/monitorapi"
"github.com/prometheus/common/model"

"github.com/openshift/origin/pkg/monitor/monitorapi"
)

type MetricCondition struct {
Expand Down
17 changes: 17 additions & 0 deletions pkg/certs/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,31 @@ import (
)

type ConfigMapRefByNamespaceName []certgraphapi.InClusterConfigMapLocation

type SecretRefByNamespaceName []certgraphapi.InClusterSecretLocation

type SecretInfoByNamespaceName map[certgraphapi.InClusterSecretLocation]certgraphapi.PKIRegistryCertKeyPairInfo

type ConfigMapInfoByNamespaceName map[certgraphapi.InClusterConfigMapLocation]certgraphapi.PKIRegistryCertificateAuthorityInfo

type OnDiskLocationByPath []certgraphapi.OnDiskLocation

type CertKeyPairInfoByOnDiskLocation map[certgraphapi.OnDiskLocation]certgraphapi.PKIRegistryCertKeyPairInfo

type CABundleInfoByOnDiskLocation map[certgraphapi.OnDiskLocation]certgraphapi.PKIRegistryCertificateAuthorityInfo

type CertKeyPairByLocation []certgraphapi.PKIRegistryCertKeyPair

type CertificateAuthorityBundleByLocation []certgraphapi.PKIRegistryCABundle

func (n SecretRefByNamespaceName) Len() int {
return len(n)
}

func (n SecretRefByNamespaceName) Swap(i, j int) {
n[i], n[j] = n[j], n[i]
}

func (n SecretRefByNamespaceName) Less(i, j int) bool {
diff := strings.Compare(n[i].Namespace, n[j].Namespace)
switch {
Expand All @@ -39,9 +48,11 @@ func (n SecretRefByNamespaceName) Less(i, j int) bool {
func (n ConfigMapRefByNamespaceName) Len() int {
return len(n)
}

func (n ConfigMapRefByNamespaceName) Swap(i, j int) {
n[i], n[j] = n[j], n[i]
}

func (n ConfigMapRefByNamespaceName) Less(i, j int) bool {
diff := strings.Compare(n[i].Namespace, n[j].Namespace)
switch {
Expand All @@ -57,9 +68,11 @@ func (n ConfigMapRefByNamespaceName) Less(i, j int) bool {
func (n OnDiskLocationByPath) Len() int {
return len(n)
}

func (n OnDiskLocationByPath) Swap(i, j int) {
n[i], n[j] = n[j], n[i]
}

func (n OnDiskLocationByPath) Less(i, j int) bool {
return strings.Compare(n[i].Path, n[j].Path) < 0
}
Expand Down Expand Up @@ -87,19 +100,23 @@ func BuildCABundlePath(curr certgraphapi.PKIRegistryCABundle) string {
func (n CertKeyPairByLocation) Len() int {
return len(n)
}

func (n CertKeyPairByLocation) Swap(i, j int) {
n[i], n[j] = n[j], n[i]
}

func (n CertKeyPairByLocation) Less(i, j int) bool {
return strings.Compare(BuildCertKeyPath(n[i]), BuildCertKeyPath(n[j])) < 0
}

func (n CertificateAuthorityBundleByLocation) Len() int {
return len(n)
}

func (n CertificateAuthorityBundleByLocation) Swap(i, j int) {
n[i], n[j] = n[j], n[i]
}

func (n CertificateAuthorityBundleByLocation) Less(i, j int) bool {
return strings.Compare(BuildCABundlePath(n[i]), BuildCABundlePath(n[j])) < 0
}
11 changes: 5 additions & 6 deletions pkg/clioptions/clusterdiscovery/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,18 @@ import (
"net/url"
"strings"

"k8s.io/apimachinery/pkg/runtime/schema"

configv1 "github.com/openshift/api/config/v1"
operatorv1 "github.com/openshift/api/operator/v1"
configclient "github.com/openshift/client-go/config/clientset/versioned"
operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/util/sets"
clientset "k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"
utilnet "k8s.io/utils/net"

configv1 "github.com/openshift/api/config/v1"
operatorv1 "github.com/openshift/api/operator/v1"
configclient "github.com/openshift/client-go/config/clientset/versioned"
operatorclient "github.com/openshift/client-go/operator/clientset/versioned"
"github.com/openshift/origin/test/extended/util/azure"
)

Expand Down
3 changes: 2 additions & 1 deletion pkg/clioptions/clusterdiscovery/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"path/filepath"
"strings"

"github.com/openshift/origin/test/extended/storage/csi"
"k8s.io/apimachinery/pkg/util/sets"
"k8s.io/kubernetes/test/e2e/framework/testfiles"
"k8s.io/kubernetes/test/e2e/storage/external"
"sigs.k8s.io/yaml"

"github.com/openshift/origin/test/extended/storage/csi"
)

const (
Expand Down
28 changes: 7 additions & 21 deletions pkg/clioptions/clusterdiscovery/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,35 +5,21 @@ import (
"fmt"
"os"

"github.com/onsi/ginkgo/v2"
ginkgo "github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"
"github.com/sirupsen/logrus"

"github.com/openshift/origin/test/extended/util/image"
_ "k8s.io/kubernetes/test/e2e"
e2e "k8s.io/kubernetes/test/e2e/framework"
_ "k8s.io/kubernetes/test/e2e/lifecycle"

exutil "github.com/openshift/origin/test/extended/util"
// Initialize baremetal as a provider
_ "github.com/openshift/origin/test/extended/util/alibabacloud"
_ "github.com/openshift/origin/test/extended/util/baremetal"

// Initialize ovirt as a provider
_ "github.com/openshift/origin/test/extended/util/ovirt"

// Initialize kubevirt as a provider
_ "github.com/openshift/origin/test/extended/util/external"
"github.com/openshift/origin/test/extended/util/image"
_ "github.com/openshift/origin/test/extended/util/kubevirt"

// Initialize alibabacloud as a provider
_ "github.com/openshift/origin/test/extended/util/alibabacloud"

// Initialize nutanix as a provider
_ "github.com/openshift/origin/test/extended/util/nutanix"

// Initialize nutanix as a provider
_ "github.com/openshift/origin/test/extended/util/external"

// these are loading important global flags that we need to get and set
_ "k8s.io/kubernetes/test/e2e"
_ "k8s.io/kubernetes/test/e2e/lifecycle"
_ "github.com/openshift/origin/test/extended/util/ovirt"
)

func InitializeTestFramework(context *e2e.TestContextType, config *ClusterConfiguration, dryRun bool) error {
Expand Down
1 change: 0 additions & 1 deletion pkg/clioptions/clusterdiscovery/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
configv1 "github.com/openshift/api/config/v1"
operatorv1 "github.com/openshift/api/operator/v1"
"github.com/stretchr/testify/require"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
Expand Down
6 changes: 3 additions & 3 deletions pkg/clioptions/clusterinfo/wait_for_stable_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import (
"strings"
"time"

configv1 "github.com/openshift/api/config/v1"
configclient "github.com/openshift/client-go/config/clientset/versioned"
"github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

configv1 "github.com/openshift/api/config/v1"
configclient "github.com/openshift/client-go/config/clientset/versioned"
"github.com/openshift/library-go/pkg/config/clusteroperator/v1helpers"
"github.com/openshift/origin/pkg/test/ginkgo/junitapi"
exutil "github.com/openshift/origin/test/extended/util"
)
Expand Down
3 changes: 1 addition & 2 deletions pkg/clioptions/clusterinfo/write_job_run_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ import (
"context"
"strings"

"github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"

"k8s.io/client-go/rest"
e2e "k8s.io/kubernetes/test/e2e/framework"

"github.com/openshift/origin/pkg/monitor/monitorapi"
"github.com/openshift/origin/pkg/monitortestlibrary/platformidentification"
)

func WasMasterNodeUpdated(events monitorapi.Intervals) string {
Expand Down
3 changes: 2 additions & 1 deletion pkg/clioptions/imagesetup/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import (
"fmt"
"os"

"github.com/openshift/origin/test/extended/util/image"
k8simage "k8s.io/kubernetes/test/utils/image"

"github.com/openshift/origin/test/extended/util/image"
)

// OpenShift tests consume images from the cluster, from a number of vetted community locations,
Expand Down
6 changes: 2 additions & 4 deletions pkg/clioptions/suiteselection/suite_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ import (
"strings"

clientconfigv1 "github.com/openshift/client-go/config/clientset/versioned"
"github.com/spf13/pflag"
apierrors "k8s.io/apimachinery/pkg/api/errors"

"k8s.io/cli-runtime/pkg/genericclioptions"
"k8s.io/client-go/discovery"

testginkgo "github.com/openshift/origin/pkg/test/ginkgo"

"github.com/spf13/pflag"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

type DiscoveryClientGetter interface {
Expand Down
3 changes: 2 additions & 1 deletion pkg/clioptions/upgradeoptions/upgrade_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"fmt"
"strings"

"github.com/openshift/origin/test/e2e/upgrade"
"k8s.io/kubernetes/test/e2e/upgrades"

"github.com/openshift/origin/test/e2e/upgrade"
)

type UpgradeOptions struct {
Expand Down
3 changes: 1 addition & 2 deletions pkg/clusterversion/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package clusterversion
import (
"strings"

"golang.org/x/mod/semver"

configv1 "github.com/openshift/api/config/v1"
"golang.org/x/mod/semver"
)

// IsUpgradedFromMinorVersion returns true if the cluster has been upgraded from or through the given version.
Expand Down
Loading