Skip to content

Commit

Permalink
Add goimports support to bazel
Browse files Browse the repository at this point in the history
  • Loading branch information
rmohr committed Mar 15, 2019
1 parent 6ea634b commit ae00998
Show file tree
Hide file tree
Showing 27 changed files with 91 additions and 52 deletions.
9 changes: 9 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@bazel_gazelle//:def.bzl", "gazelle")
load("@io_bazel_rules_go//go:def.bzl", "nogo")
load("@com_github_atlassian_bazel_tools//goimports:def.bzl", "goimports")

goimports(
name = "goimports",
display_diffs = True,
local = ["kubevirt.io"],
prefix = "kubevirt.io/kubevirt",
write = True,
)

nogo(
name = "nogo_vet",
Expand Down
14 changes: 12 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ load(
# Additional bazel rules
http_archive(
name = "io_bazel_rules_go",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.18.0/rules_go-0.18.0.tar.gz"],
sha256 = "301c8b39b0808c49f98895faa6aa8c92cbd605ab5ad4b6a3a652da33a1a2ba2e",
urls = ["https://github.com/bazelbuild/rules_go/releases/download/0.18.0/rules_go-0.18.0.tar.gz"],
)

http_archive(
Expand All @@ -35,6 +35,12 @@ git_repository(
tag = "v0.5.1",
)

http_archive(
name = "com_github_atlassian_bazel_tools",
strip_prefix = "bazel-tools-02472d814d1867de2ad75801760732c9e595c9d9",
urls = ["https://github.com/atlassian/bazel-tools/archive/02472d814d1867de2ad75801760732c9e595c9d9.zip"],
)

# Libvirt dependencies
http_file(
name = "libvirt_libs",
Expand Down Expand Up @@ -96,7 +102,11 @@ go_rules_dependencies()
go_register_toolchains(
go_version = "1.11.5",
nogo = "@//:nogo_vet",
)
)

load("@com_github_atlassian_bazel_tools//goimports:deps.bzl", "goimports_dependencies")

goimports_dependencies()

load(
"@bazel_gazelle//:deps.bzl",
Expand Down
2 changes: 1 addition & 1 deletion cmd/virt-operator/virt-operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
_ "kubevirt.io/kubevirt/pkg/monitoring/client/prometheus" // import for prometheus metrics
_ "kubevirt.io/kubevirt/pkg/monitoring/reflector/prometheus" // import for prometheus metrics
_ "kubevirt.io/kubevirt/pkg/monitoring/workqueue/prometheus" // import for prometheus metrics
"kubevirt.io/kubevirt/pkg/virt-operator"
virt_operator "kubevirt.io/kubevirt/pkg/virt-operator"
)

func main() {
Expand Down
60 changes: 40 additions & 20 deletions nogo_config.json
Original file line number Diff line number Diff line change
@@ -1,102 +1,122 @@
{
"structtag": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"asmdecl": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"assign": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"atomic": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"bools": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"buildtag": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"cgocall": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"composites": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"copylocks": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"httpresponse": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"loopclosure": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"lostcancel": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"nilfunc": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"printf": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"shift": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"stdmethods": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"tests": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"unreachable": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"unsafeptr": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
},
"unusedresult": {
"exclude_files": {
"vendor/": "vendor doesn't pass vet"
"vendor/": "vendor doesn't pass vet",
"external/": "externaldoesn't pass vet"
}
}
}
2 changes: 1 addition & 1 deletion pkg/api/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
"encoding/json"
"fmt"

"k8s.io/api/autoscaling/v1"
v1 "k8s.io/api/autoscaling/v1"
k8sv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/ignition/ignition.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"io/ioutil"
"os"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
diskutils "kubevirt.io/kubevirt/pkg/ephemeral-disk-utils"
"kubevirt.io/kubevirt/pkg/log"
"kubevirt.io/kubevirt/pkg/precond"
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubecli/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
networkclient "github.com/k8snetworkplumbingwg/network-attachment-definition-client/pkg/client/clientset/versioned"

cdiclient "kubevirt.io/containerized-data-importer/pkg/client/clientset/versioned"
"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
)

type KubevirtClient interface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubecli/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
)

func (k *kubevirt) KubeVirt(namespace string) KubeVirtInterface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubecli/replicaset.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
)

func (k *kubevirt) ReplicaSet(namespace string) ReplicaSetInterface {
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubecli/replicaset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/ghttp"
"k8s.io/api/autoscaling/v1"
v1 "k8s.io/api/autoscaling/v1"
k8sv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
k8smetav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
2 changes: 1 addition & 1 deletion pkg/util/openapi/openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"

"github.com/emicklei/go-restful"
"github.com/emicklei/go-restful-openapi"
restfulspec "github.com/emicklei/go-restful-openapi"
"github.com/go-openapi/errors"
"github.com/go-openapi/spec"
"github.com/go-openapi/strfmt"
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-controller/services/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ import (
"kubevirt.io/kubevirt/pkg/util/hardware"
"kubevirt.io/kubevirt/pkg/util/net/dns"
"kubevirt.io/kubevirt/pkg/util/types"
"kubevirt.io/kubevirt/pkg/virt-config"
virtconfig "kubevirt.io/kubevirt/pkg/virt-config"
)

const configMapName = "kubevirt-config"
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-controller/services/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"kubevirt.io/kubevirt/pkg/hooks"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/log"
"kubevirt.io/kubevirt/pkg/virt-config"
virtconfig "kubevirt.io/kubevirt/pkg/virt-config"
)

const namespaceKubevirt = "kubevirt"
Expand Down
4 changes: 2 additions & 2 deletions pkg/virt-controller/watch/replicaset_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import (
k8sv1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/cache/testing"
framework "k8s.io/client-go/tools/cache/testing"
"k8s.io/client-go/tools/record"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/testutils"
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/virt-controller/watch/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/testing"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/cache/testing"
framework "k8s.io/client-go/tools/cache/testing"
"k8s.io/client-go/tools/record"

cdiv1 "kubevirt.io/containerized-data-importer/pkg/apis/core/v1alpha1"
cdifake "kubevirt.io/containerized-data-importer/pkg/client/clientset/versioned/fake"
"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
virtv1 "kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/testutils"
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-controller/watch/vmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"time"

k8sv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/client-go/tools/cache"
Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-operator/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ import (
"kubevirt.io/kubevirt/pkg/log"
"kubevirt.io/kubevirt/pkg/service"
kvutil "kubevirt.io/kubevirt/pkg/util"
"kubevirt.io/kubevirt/pkg/virt-operator/install-strategy"
installstrategy "kubevirt.io/kubevirt/pkg/virt-operator/install-strategy"
"kubevirt.io/kubevirt/pkg/virt-operator/util"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-operator/install-strategy/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/controller"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/log"
Expand Down
4 changes: 2 additions & 2 deletions pkg/virt-operator/kubevirt.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ import (
"k8s.io/client-go/tools/record"
"k8s.io/client-go/util/workqueue"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/controller"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/log"
"kubevirt.io/kubevirt/pkg/virt-operator/install-strategy"
installstrategy "kubevirt.io/kubevirt/pkg/virt-operator/install-strategy"
"kubevirt.io/kubevirt/pkg/virt-operator/util"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/virt-operator/kubevirt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ import (
"k8s.io/client-go/kubernetes/fake"
"k8s.io/client-go/testing"
"k8s.io/client-go/tools/cache"
"k8s.io/client-go/tools/cache/testing"
framework "k8s.io/client-go/tools/cache/testing"
"k8s.io/client-go/tools/record"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/kubecli"
"kubevirt.io/kubevirt/pkg/log"
"kubevirt.io/kubevirt/pkg/testutils"
"kubevirt.io/kubevirt/pkg/version"
"kubevirt.io/kubevirt/pkg/virt-operator/creation/components"
"kubevirt.io/kubevirt/pkg/virt-operator/creation/rbac"
"kubevirt.io/kubevirt/pkg/virt-operator/install-strategy"
installstrategy "kubevirt.io/kubevirt/pkg/virt-operator/install-strategy"
"kubevirt.io/kubevirt/pkg/virt-operator/util"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/virt-operator/util/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import (
discoveryFake "k8s.io/client-go/discovery/fake"
"k8s.io/client-go/kubernetes/fake"

"kubevirt.io/kubevirt/pkg/api/v1"
v1 "kubevirt.io/kubevirt/pkg/api/v1"
"kubevirt.io/kubevirt/pkg/kubecli"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/virtctl/imageupload/imageupload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down
Loading

0 comments on commit ae00998

Please sign in to comment.