From 4e7ec4bb577587b1f781d10be555e811dbbcf794 Mon Sep 17 00:00:00 2001 From: Adrian Orive Date: Tue, 19 Nov 2019 10:27:33 +0100 Subject: [PATCH] Group and order imports Kubebuilder files are grouped by std/non-k8s/k8s while scaffolded files are grouped by std/external/internal Signed-off-by: Adrian Orive --- cmd/go_version_test.go | 4 +++- cmd/vendor_update.go | 1 + .../cronjob-tutorial/testdata/emptycontroller.go | 2 +- .../src/cronjob-tutorial/testdata/emptymain.go | 2 +- .../testdata/project/api/v1/cronjob_webhook.go | 2 -- .../src/cronjob-tutorial/testdata/project/main.go | 1 + .../testdata/gopath/project-v1/cmd/manager/main.go | 8 ++++---- .../pkg/controller/cronjob/cronjob_controller.go | 5 ++--- .../cronjob/cronjob_controller_suite_test.go | 4 ++-- .../cronjob/mutating/create_update_webhook.go | 4 ++-- .../mutating/cronjob_create_update_handler.go | 4 ++-- .../cronjob/validating/create_webhook.go | 4 ++-- .../cronjob/validating/cronjob_create_handler.go | 5 ++--- .../cronjob/validating/cronjob_update_handler.go | 4 ++-- .../cronjob/validating/update_webhook.go | 4 ++-- .../testdata/project/api/v1/cronjob_webhook.go | 2 -- .../multiversion-tutorial/testdata/project/main.go | 1 + pkg/scaffold/project/project_test.go | 1 + pkg/scaffold/scaffold.go | 14 +++++++++++++- pkg/scaffold/v1/controller/controller.go | 6 ++---- pkg/scaffold/v1/controller/controllersuitetest.go | 1 - pkg/scaffold/v1/controller/controllertest.go | 1 - pkg/scaffold/v1/crd/typestest.go | 1 - pkg/scaffold/v1/crd/version_suitetest.go | 1 - pkg/scaffold/v1/manager/cmd.go | 1 - pkg/scaffold/v1/manager/manager_test.go | 1 + .../v1/webhook/add_admissionbuilder_handler.go | 1 - pkg/scaffold/v1/webhook/admissionbuilder.go | 2 +- pkg/scaffold/v1/webhook/admissionhandler.go | 4 +--- pkg/scaffold/v1/webhook/server.go | 1 - pkg/scaffold/v1/webhook/webhook_test.go | 1 + pkg/scaffold/v2/controller.go | 2 -- pkg/scaffold/v2/controller_suitetest.go | 3 --- pkg/scaffold/v2/main.go | 2 -- pkg/scaffold/v2/prometheus/kustomize.go | 1 + pkg/scaffold/v2/prometheus/monitor.go | 1 + pkg/scaffold/v2/webhook/webhook.go | 4 +++- plugins/addon/helpers.go | 1 + test/e2e/v1/e2e_suite.go | 3 ++- test/e2e/v2/e2e_suite.go | 4 ++-- testdata/gopath/src/project/cmd/manager/main.go | 8 ++++---- .../controller/firstmate/firstmate_controller.go | 4 ++-- .../firstmate/firstmate_controller_suite_test.go | 4 ++-- .../firstmate/firstmate_controller_test.go | 4 ++-- .../pkg/controller/frigate/frigate_controller.go | 4 ++-- .../frigate/frigate_controller_suite_test.go | 4 ++-- .../controller/frigate/frigate_controller_test.go | 4 ++-- .../healthcheckpolicy_controller.go | 4 ++-- .../healthcheckpolicy_controller_suite_test.go | 4 ++-- .../healthcheckpolicy_controller_test.go | 4 ++-- .../pkg/controller/kraken/kraken_controller.go | 4 ++-- .../kraken/kraken_controller_suite_test.go | 4 ++-- .../controller/kraken/kraken_controller_test.go | 4 ++-- .../namespace/namespace_controller_suite_test.go | 4 ++-- .../firstmate/mutating/create_update_webhook.go | 4 ++-- .../firstmate/mutating/delete_webhook.go | 4 ++-- .../mutating/firstmate_create_update_handler.go | 4 ++-- .../firstmate/mutating/firstmate_delete_handler.go | 4 ++-- .../frigate/validating/frigate_update_handler.go | 4 ++-- .../frigate/validating/update_webhook.go | 4 ++-- .../kraken/validating/create_webhook.go | 4 ++-- .../kraken/validating/kraken_create_handler.go | 4 ++-- .../project-v2/controllers/namespace_controller.go | 3 +-- testdata/project-v2/controllers/suite_test.go | 5 +++-- testdata/project-v2/main.go | 4 +++- 65 files changed, 111 insertions(+), 107 deletions(-) diff --git a/cmd/go_version_test.go b/cmd/go_version_test.go index 05e045df9e5..f9d2ac5efe5 100644 --- a/cmd/go_version_test.go +++ b/cmd/go_version_test.go @@ -16,7 +16,9 @@ limitations under the License. package main -import "testing" +import ( + "testing" +) func TestCheckGoVersion(t *testing.T) { diff --git a/cmd/vendor_update.go b/cmd/vendor_update.go index 33a7b3cc5dd..e2835cd8d82 100644 --- a/cmd/vendor_update.go +++ b/cmd/vendor_update.go @@ -20,6 +20,7 @@ import ( "log" "github.com/spf13/cobra" + "sigs.k8s.io/kubebuilder/pkg/model" "sigs.k8s.io/kubebuilder/pkg/scaffold" "sigs.k8s.io/kubebuilder/pkg/scaffold/input" diff --git a/docs/book/src/cronjob-tutorial/testdata/emptycontroller.go b/docs/book/src/cronjob-tutorial/testdata/emptycontroller.go index 9829fdb669c..fd0581cd18b 100644 --- a/docs/book/src/cronjob-tutorial/testdata/emptycontroller.go +++ b/docs/book/src/cronjob-tutorial/testdata/emptycontroller.go @@ -23,9 +23,9 @@ package controllers import ( "context" - "k8s.io/apimachinery/pkg/runtime" "github.com/go-logr/logr" + "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/docs/book/src/cronjob-tutorial/testdata/emptymain.go b/docs/book/src/cronjob-tutorial/testdata/emptymain.go index 94e48f3c74d..725f388fa21 100644 --- a/docs/book/src/cronjob-tutorial/testdata/emptymain.go +++ b/docs/book/src/cronjob-tutorial/testdata/emptymain.go @@ -29,11 +29,11 @@ import ( "flag" "fmt" "os" - "sigs.k8s.io/controller-runtime/pkg/cache" "k8s.io/apimachinery/pkg/runtime" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ctrl "sigs.k8s.io/controller-runtime" + "sigs.k8s.io/controller-runtime/pkg/cache" "sigs.k8s.io/controller-runtime/pkg/log/zap" // +kubebuilder:scaffold:imports ) diff --git a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go index b4d8707e995..343cb6658a3 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/api/v1/cronjob_webhook.go @@ -18,13 +18,11 @@ package v1 import ( "github.com/robfig/cron" - apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" validationutils "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/webhook" diff --git a/docs/book/src/cronjob-tutorial/testdata/project/main.go b/docs/book/src/cronjob-tutorial/testdata/project/main.go index 1e7641f4106..247eb125f25 100644 --- a/docs/book/src/cronjob-tutorial/testdata/project/main.go +++ b/docs/book/src/cronjob-tutorial/testdata/project/main.go @@ -25,6 +25,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log/zap" + batchv1 "tutorial.kubebuilder.io/project/api/v1" "tutorial.kubebuilder.io/project/controllers" // +kubebuilder:scaffold:imports diff --git a/docs/book/src/migration/testdata/gopath/project-v1/cmd/manager/main.go b/docs/book/src/migration/testdata/gopath/project-v1/cmd/manager/main.go index 7bfd7b39406..99e3b7bc0c6 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/cmd/manager/main.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/cmd/manager/main.go @@ -20,15 +20,15 @@ import ( "flag" "os" - "project/pkg/apis" - "project/pkg/controller" - "project/pkg/webhook" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" + + "project/pkg/apis" + "project/pkg/controller" + "project/pkg/webhook" ) func main() { diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller.go index ef31e3384b1..dd44ccba067 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller.go @@ -23,9 +23,6 @@ import ( "time" "github.com/robfig/cron" - - batchv1 "project/pkg/apis/batch/v1" - kbatch "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -37,6 +34,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" + + batchv1 "project/pkg/apis/batch/v1" ) var log = logf.Log.WithName("controller") diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller_suite_test.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller_suite_test.go index 6597bd8f454..2e8ca224bc5 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller_suite_test.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/controller/cronjob/cronjob_controller_suite_test.go @@ -23,14 +23,14 @@ import ( "sync" "testing" - "project/pkg/apis" - "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "project/pkg/apis" ) var cfg *rest.Config diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/create_update_webhook.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/create_update_webhook.go index 9a49e7f4250..2133310770c 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/create_update_webhook.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/create_update_webhook.go @@ -17,10 +17,10 @@ limitations under the License. package mutating import ( - batchv1 "project/pkg/apis/batch/v1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + + batchv1 "project/pkg/apis/batch/v1" ) func init() { diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/cronjob_create_update_handler.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/cronjob_create_update_handler.go index 1edb02a0b9a..1beee8d6685 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/cronjob_create_update_handler.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/mutating/cronjob_create_update_handler.go @@ -20,11 +20,11 @@ import ( "context" "net/http" - batchv1 "project/pkg/apis/batch/v1" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + + batchv1 "project/pkg/apis/batch/v1" ) func init() { diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/create_webhook.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/create_webhook.go index 3c1d40dbad8..271de22b47e 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/create_webhook.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/create_webhook.go @@ -17,10 +17,10 @@ limitations under the License. package validating import ( - batchv1 "project/pkg/apis/batch/v1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + + batchv1 "project/pkg/apis/batch/v1" ) func init() { diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_create_handler.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_create_handler.go index 9ccf51e4ebe..6301f666188 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_create_handler.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_create_handler.go @@ -21,9 +21,6 @@ import ( "net/http" "github.com/robfig/cron" - - batchv1 "project/pkg/apis/batch/v1" - apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime/schema" validationutils "k8s.io/apimachinery/pkg/util/validation" @@ -31,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + + batchv1 "project/pkg/apis/batch/v1" ) func init() { diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_update_handler.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_update_handler.go index 5a41c54aee6..4392844cd19 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_update_handler.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/cronjob_update_handler.go @@ -20,11 +20,11 @@ import ( "context" "net/http" - batchv1 "project/pkg/apis/batch/v1" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + + batchv1 "project/pkg/apis/batch/v1" ) func init() { diff --git a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/update_webhook.go b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/update_webhook.go index 33de3211759..44ef0693966 100644 --- a/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/update_webhook.go +++ b/docs/book/src/migration/testdata/gopath/project-v1/pkg/webhook/default_server/cronjob/validating/update_webhook.go @@ -17,10 +17,10 @@ limitations under the License. package validating import ( - batchv1 "project/pkg/apis/batch/v1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + + batchv1 "project/pkg/apis/batch/v1" ) func init() { diff --git a/docs/book/src/multiversion-tutorial/testdata/project/api/v1/cronjob_webhook.go b/docs/book/src/multiversion-tutorial/testdata/project/api/v1/cronjob_webhook.go index 56f9718b81d..20c8974638c 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/api/v1/cronjob_webhook.go +++ b/docs/book/src/multiversion-tutorial/testdata/project/api/v1/cronjob_webhook.go @@ -18,13 +18,11 @@ package v1 import ( "github.com/robfig/cron" - apierrors "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" validationutils "k8s.io/apimachinery/pkg/util/validation" "k8s.io/apimachinery/pkg/util/validation/field" - ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/webhook" diff --git a/docs/book/src/multiversion-tutorial/testdata/project/main.go b/docs/book/src/multiversion-tutorial/testdata/project/main.go index a1dc728412a..2febd6d498e 100644 --- a/docs/book/src/multiversion-tutorial/testdata/project/main.go +++ b/docs/book/src/multiversion-tutorial/testdata/project/main.go @@ -26,6 +26,7 @@ import ( _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log/zap" + batchv1 "tutorial.kubebuilder.io/project/api/v1" batchv2 "tutorial.kubebuilder.io/project/api/v2" "tutorial.kubebuilder.io/project/controllers" diff --git a/pkg/scaffold/project/project_test.go b/pkg/scaffold/project/project_test.go index ba44f9ebae7..5bd93bcbb55 100644 --- a/pkg/scaffold/project/project_test.go +++ b/pkg/scaffold/project/project_test.go @@ -11,6 +11,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "sigs.k8s.io/kubebuilder/pkg/model" "sigs.k8s.io/kubebuilder/pkg/scaffold" "sigs.k8s.io/kubebuilder/pkg/scaffold/input" diff --git a/pkg/scaffold/scaffold.go b/pkg/scaffold/scaffold.go index 59c8f996d15..ba174c8e2ff 100644 --- a/pkg/scaffold/scaffold.go +++ b/pkg/scaffold/scaffold.go @@ -28,12 +28,20 @@ import ( "text/template" "golang.org/x/tools/imports" + "sigs.k8s.io/kubebuilder/pkg/model" "sigs.k8s.io/kubebuilder/pkg/scaffold/input" "sigs.k8s.io/kubebuilder/pkg/scaffold/project" "sigs.k8s.io/yaml" ) +var options = imports.Options{ + Comments: true, + TabIndent: true, + TabWidth: 8, + FormatOnly: true, +} + // Scaffold writes Templates to scaffold new files type Scaffold struct { // BoilerplatePath is the path to the boilerplate file @@ -181,6 +189,10 @@ func (s *Scaffold) Execute(u *model.Universe, options input.Options, files ...in if err := s.defaultOptions(&options); err != nil { return err } + + // Set the repo as the local prefix so that it knows how to group imports + imports.LocalPrefix = s.Project.Repo + for _, f := range files { m, err := s.buildFileModel(f) if err != nil { @@ -289,7 +301,7 @@ func (s *Scaffold) doTemplate(i input.Input, e input.File) ([]byte, error) { // gofmt the imports if filepath.Ext(i.Path) == ".go" { - b, err = imports.Process(i.Path, b, nil) + b, err = imports.Process(i.Path, b, &options) if err != nil { fmt.Printf("%s\n", out.Bytes()) return nil, err diff --git a/pkg/scaffold/v1/controller/controller.go b/pkg/scaffold/v1/controller/controller.go index f993e7b0a39..bb4ce630d17 100644 --- a/pkg/scaffold/v1/controller/controller.go +++ b/pkg/scaffold/v1/controller/controller.go @@ -24,6 +24,7 @@ import ( "strings" "github.com/gobuffalo/flect" + "sigs.k8s.io/kubebuilder/pkg/scaffold/input" "sigs.k8s.io/kubebuilder/pkg/scaffold/resource" ) @@ -103,14 +104,11 @@ package {{ lower .Resource.Kind }} import ( {{ if .Resource.CreateExampleReconcileBody }} "context" - "log" "reflect" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" @@ -126,9 +124,9 @@ import ( var log = logf.Log.WithName("{{ lower .Resource.Kind }}-controller") {{ else }} "context" - appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" + "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller" "sigs.k8s.io/controller-runtime/pkg/handler" diff --git a/pkg/scaffold/v1/controller/controllersuitetest.go b/pkg/scaffold/v1/controller/controllersuitetest.go index 9ba6b285ece..c7881bbd4aa 100644 --- a/pkg/scaffold/v1/controller/controllersuitetest.go +++ b/pkg/scaffold/v1/controller/controllersuitetest.go @@ -52,7 +52,6 @@ import ( "path/filepath" "sync" "testing" - "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" diff --git a/pkg/scaffold/v1/controller/controllertest.go b/pkg/scaffold/v1/controller/controllertest.go index 773b613fb59..2742a1a40c5 100644 --- a/pkg/scaffold/v1/controller/controllertest.go +++ b/pkg/scaffold/v1/controller/controllertest.go @@ -73,7 +73,6 @@ package {{ lower .Resource.Kind }} import ( "testing" "time" - "github.com/onsi/gomega" "golang.org/x/net/context" {{ if .Resource.CreateExampleReconcileBody -}} diff --git a/pkg/scaffold/v1/crd/typestest.go b/pkg/scaffold/v1/crd/typestest.go index de5d6b8f44a..35a56f4c4b6 100644 --- a/pkg/scaffold/v1/crd/typestest.go +++ b/pkg/scaffold/v1/crd/typestest.go @@ -57,7 +57,6 @@ package {{ .Resource.Version }} import ( "testing" - "github.com/onsi/gomega" "golang.org/x/net/context" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" diff --git a/pkg/scaffold/v1/crd/version_suitetest.go b/pkg/scaffold/v1/crd/version_suitetest.go index 8c30b87de99..4639e4dc836 100644 --- a/pkg/scaffold/v1/crd/version_suitetest.go +++ b/pkg/scaffold/v1/crd/version_suitetest.go @@ -58,7 +58,6 @@ import ( "os" "path/filepath" "testing" - "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" diff --git a/pkg/scaffold/v1/manager/cmd.go b/pkg/scaffold/v1/manager/cmd.go index 18a363602fd..dbd339215b4 100644 --- a/pkg/scaffold/v1/manager/cmd.go +++ b/pkg/scaffold/v1/manager/cmd.go @@ -45,7 +45,6 @@ package main import ( "flag" "os" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" diff --git a/pkg/scaffold/v1/manager/manager_test.go b/pkg/scaffold/v1/manager/manager_test.go index 75142b04255..8deee4ebd11 100644 --- a/pkg/scaffold/v1/manager/manager_test.go +++ b/pkg/scaffold/v1/manager/manager_test.go @@ -6,6 +6,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "sigs.k8s.io/kubebuilder/pkg/model" "sigs.k8s.io/kubebuilder/pkg/scaffold/input" "sigs.k8s.io/kubebuilder/pkg/scaffold/scaffoldtest" diff --git a/pkg/scaffold/v1/webhook/add_admissionbuilder_handler.go b/pkg/scaffold/v1/webhook/add_admissionbuilder_handler.go index 68e5d9b9d08..9bb9dbf3e44 100644 --- a/pkg/scaffold/v1/webhook/add_admissionbuilder_handler.go +++ b/pkg/scaffold/v1/webhook/add_admissionbuilder_handler.go @@ -55,7 +55,6 @@ package {{ .Server }}server import ( "fmt" - "{{ .Repo }}/pkg/webhook/{{ .Server }}_server/{{ lower .Resource.Kind }}/{{ .Type }}" ) diff --git a/pkg/scaffold/v1/webhook/admissionbuilder.go b/pkg/scaffold/v1/webhook/admissionbuilder.go index 6fcccbf7680..be91f14ffdc 100644 --- a/pkg/scaffold/v1/webhook/admissionbuilder.go +++ b/pkg/scaffold/v1/webhook/admissionbuilder.go @@ -77,9 +77,9 @@ const admissionWebhookBuilderTemplate = `{{ .Boilerplate }} package {{ .Type }} import ( - {{ .Resource.Group}}{{ .Resource.Version }} "{{ .ResourcePackage }}/{{ .Resource.Group}}/{{ .Resource.Version }}" admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + {{ .Resource.Group}}{{ .Resource.Version }} "{{ .ResourcePackage }}/{{ .Resource.Group}}/{{ .Resource.Version }}" ) func init() { diff --git a/pkg/scaffold/v1/webhook/admissionhandler.go b/pkg/scaffold/v1/webhook/admissionhandler.go index 75472c52639..783f437f7de 100644 --- a/pkg/scaffold/v1/webhook/admissionhandler.go +++ b/pkg/scaffold/v1/webhook/admissionhandler.go @@ -78,12 +78,10 @@ package {{ .Type }} import ( "context" "net/http" - - {{ .Resource.Group}}{{ .Resource.Version }} "{{ .ResourcePackage }}/{{ .Resource.Group}}/{{ .Resource.Version }}" - "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + {{ .Resource.Group}}{{ .Resource.Version }} "{{ .ResourcePackage }}/{{ .Resource.Group}}/{{ .Resource.Version }}" ) func init() { diff --git a/pkg/scaffold/v1/webhook/server.go b/pkg/scaffold/v1/webhook/server.go index c378e5d9b1b..31b4f322cae 100644 --- a/pkg/scaffold/v1/webhook/server.go +++ b/pkg/scaffold/v1/webhook/server.go @@ -48,7 +48,6 @@ package {{ .Server }}server import ( "fmt" "os" - "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/manager" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" diff --git a/pkg/scaffold/v1/webhook/webhook_test.go b/pkg/scaffold/v1/webhook/webhook_test.go index 5432e3722d9..dbe1505840d 100644 --- a/pkg/scaffold/v1/webhook/webhook_test.go +++ b/pkg/scaffold/v1/webhook/webhook_test.go @@ -7,6 +7,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "sigs.k8s.io/kubebuilder/pkg/model" "sigs.k8s.io/kubebuilder/pkg/scaffold/input" "sigs.k8s.io/kubebuilder/pkg/scaffold/resource" diff --git a/pkg/scaffold/v2/controller.go b/pkg/scaffold/v2/controller.go index ed7cf5a0e7d..aba74adaa51 100644 --- a/pkg/scaffold/v2/controller.go +++ b/pkg/scaffold/v2/controller.go @@ -70,12 +70,10 @@ package controllers import ( "context" - "github.com/go-logr/logr" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - {{ .Resource.GroupImportSafe }}{{ .Resource.Version }} "{{ .ResourcePackage }}/{{ .Resource.Version }}" ) diff --git a/pkg/scaffold/v2/controller_suitetest.go b/pkg/scaffold/v2/controller_suitetest.go index 06362faf719..699c6365fbe 100644 --- a/pkg/scaffold/v2/controller_suitetest.go +++ b/pkg/scaffold/v2/controller_suitetest.go @@ -57,17 +57,14 @@ package controllers import ( "path/filepath" "testing" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" - // +kubebuilder:scaffold:imports ) diff --git a/pkg/scaffold/v2/main.go b/pkg/scaffold/v2/main.go index d82400b2591..433d5d53993 100644 --- a/pkg/scaffold/v2/main.go +++ b/pkg/scaffold/v2/main.go @@ -131,13 +131,11 @@ package main import ( "flag" "os" - "k8s.io/apimachinery/pkg/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log/zap" - %s ) diff --git a/pkg/scaffold/v2/prometheus/kustomize.go b/pkg/scaffold/v2/prometheus/kustomize.go index 7e8eb2a6880..49ff8bb2037 100644 --- a/pkg/scaffold/v2/prometheus/kustomize.go +++ b/pkg/scaffold/v2/prometheus/kustomize.go @@ -18,6 +18,7 @@ package prometheus import ( "path/filepath" + "sigs.k8s.io/kubebuilder/pkg/scaffold/input" ) diff --git a/pkg/scaffold/v2/prometheus/monitor.go b/pkg/scaffold/v2/prometheus/monitor.go index f223c467cfb..3dd86fbe7b3 100644 --- a/pkg/scaffold/v2/prometheus/monitor.go +++ b/pkg/scaffold/v2/prometheus/monitor.go @@ -2,6 +2,7 @@ package prometheus import ( "path/filepath" + "sigs.k8s.io/kubebuilder/pkg/scaffold/input" ) diff --git a/pkg/scaffold/v2/webhook/webhook.go b/pkg/scaffold/v2/webhook/webhook.go index 454ce321787..9f900dee850 100644 --- a/pkg/scaffold/v2/webhook/webhook.go +++ b/pkg/scaffold/v2/webhook/webhook.go @@ -89,10 +89,12 @@ const ( package {{ .Resource.Version }} import ( - "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" + {{- if or .Validating .Defaulting }} + "k8s.io/apimachinery/pkg/runtime" "sigs.k8s.io/controller-runtime/pkg/webhook" + {{- end }} ) // log is for logging in this package. diff --git a/plugins/addon/helpers.go b/plugins/addon/helpers.go index bd769b651b1..1514c26de6f 100644 --- a/plugins/addon/helpers.go +++ b/plugins/addon/helpers.go @@ -7,6 +7,7 @@ import ( "text/template" "github.com/gobuffalo/flect" + "sigs.k8s.io/kubebuilder/pkg/model" ) diff --git a/test/e2e/v1/e2e_suite.go b/test/e2e/v1/e2e_suite.go index 47c78c788af..fc2e39aee4b 100644 --- a/test/e2e/v1/e2e_suite.go +++ b/test/e2e/v1/e2e_suite.go @@ -20,12 +20,13 @@ import ( "fmt" "os/exec" "path/filepath" - "sigs.k8s.io/kubebuilder/test/e2e/utils" "strings" "time" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "sigs.k8s.io/kubebuilder/test/e2e/utils" ) var _ = Describe("kubebuilder", func() { diff --git a/test/e2e/v2/e2e_suite.go b/test/e2e/v2/e2e_suite.go index 08f10be2d9a..0f714fef387 100644 --- a/test/e2e/v2/e2e_suite.go +++ b/test/e2e/v2/e2e_suite.go @@ -24,10 +24,10 @@ import ( "strings" "time" - "sigs.k8s.io/kubebuilder/test/e2e/utils" - . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + + "sigs.k8s.io/kubebuilder/test/e2e/utils" ) var _ = Describe("kubebuilder", func() { diff --git a/testdata/gopath/src/project/cmd/manager/main.go b/testdata/gopath/src/project/cmd/manager/main.go index d0e92e6d2ac..a7a610b25db 100644 --- a/testdata/gopath/src/project/cmd/manager/main.go +++ b/testdata/gopath/src/project/cmd/manager/main.go @@ -20,15 +20,15 @@ import ( "flag" "os" - "project/pkg/apis" - "project/pkg/controller" - "project/pkg/webhook" - _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" "sigs.k8s.io/controller-runtime/pkg/client/config" "sigs.k8s.io/controller-runtime/pkg/manager" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/runtime/signals" + + "project/pkg/apis" + "project/pkg/controller" + "project/pkg/webhook" ) func main() { diff --git a/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller.go b/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller.go index 5fd0680b724..d07933d5ace 100644 --- a/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller.go +++ b/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller.go @@ -20,8 +20,6 @@ import ( "context" "reflect" - crewv1 "project/pkg/apis/crew/v1" - appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" @@ -36,6 +34,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/reconcile" logf "sigs.k8s.io/controller-runtime/pkg/runtime/log" "sigs.k8s.io/controller-runtime/pkg/source" + + crewv1 "project/pkg/apis/crew/v1" ) var log = logf.Log.WithName("firstmate-controller") diff --git a/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_suite_test.go b/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_suite_test.go index 79c98267000..6b5f661a5e9 100644 --- a/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_suite_test.go +++ b/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_suite_test.go @@ -23,14 +23,14 @@ import ( "sync" "testing" - "project/pkg/apis" - "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "project/pkg/apis" ) var cfg *rest.Config diff --git a/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_test.go b/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_test.go index 5062c4a99d7..6e7d191ce3a 100644 --- a/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_test.go +++ b/testdata/gopath/src/project/pkg/controller/firstmate/firstmate_controller_test.go @@ -20,8 +20,6 @@ import ( "testing" "time" - crewv1 "project/pkg/apis/crew/v1" - "github.com/onsi/gomega" "golang.org/x/net/context" appsv1 "k8s.io/api/apps/v1" @@ -31,6 +29,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + crewv1 "project/pkg/apis/crew/v1" ) var c client.Client diff --git a/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller.go b/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller.go index b426088c618..c5b3ebfe350 100644 --- a/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller.go +++ b/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller.go @@ -19,8 +19,6 @@ package frigate import ( "context" - shipv1beta1 "project/pkg/apis/ship/v1beta1" - appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -30,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + shipv1beta1 "project/pkg/apis/ship/v1beta1" ) /** diff --git a/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_suite_test.go b/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_suite_test.go index 952994a6a16..3598e5b2fd1 100644 --- a/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_suite_test.go +++ b/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_suite_test.go @@ -23,14 +23,14 @@ import ( "sync" "testing" - "project/pkg/apis" - "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "project/pkg/apis" ) var cfg *rest.Config diff --git a/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_test.go b/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_test.go index d4dbb5fd559..5beae0fc4a1 100644 --- a/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_test.go +++ b/testdata/gopath/src/project/pkg/controller/frigate/frigate_controller_test.go @@ -20,8 +20,6 @@ import ( "testing" "time" - shipv1beta1 "project/pkg/apis/ship/v1beta1" - "github.com/onsi/gomega" "golang.org/x/net/context" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -30,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + shipv1beta1 "project/pkg/apis/ship/v1beta1" ) var c client.Client diff --git a/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller.go b/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller.go index de363d1ebb2..a6e660636e3 100644 --- a/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller.go +++ b/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller.go @@ -19,8 +19,6 @@ package healthcheckpolicy import ( "context" - policyv1beta1 "project/pkg/apis/policy/v1beta1" - appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -30,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + policyv1beta1 "project/pkg/apis/policy/v1beta1" ) /** diff --git a/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_suite_test.go b/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_suite_test.go index be08cf8e128..70e428c06e7 100644 --- a/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_suite_test.go +++ b/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_suite_test.go @@ -23,14 +23,14 @@ import ( "sync" "testing" - "project/pkg/apis" - "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "project/pkg/apis" ) var cfg *rest.Config diff --git a/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_test.go b/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_test.go index b3ffa011a8e..c475be2ea04 100644 --- a/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_test.go +++ b/testdata/gopath/src/project/pkg/controller/healthcheckpolicy/healthcheckpolicy_controller_test.go @@ -20,8 +20,6 @@ import ( "testing" "time" - policyv1beta1 "project/pkg/apis/policy/v1beta1" - "github.com/onsi/gomega" "golang.org/x/net/context" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -30,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + policyv1beta1 "project/pkg/apis/policy/v1beta1" ) var c client.Client diff --git a/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller.go b/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller.go index 63eeff11f8c..a228f0fffe5 100644 --- a/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller.go +++ b/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller.go @@ -19,8 +19,6 @@ package kraken import ( "context" - creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" - appsv1 "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/runtime" @@ -30,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" "sigs.k8s.io/controller-runtime/pkg/source" + + creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" ) /** diff --git a/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_suite_test.go b/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_suite_test.go index 9e5dc575102..3061742bba5 100644 --- a/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_suite_test.go +++ b/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_suite_test.go @@ -23,14 +23,14 @@ import ( "sync" "testing" - "project/pkg/apis" - "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "project/pkg/apis" ) var cfg *rest.Config diff --git a/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_test.go b/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_test.go index 22cda8bca42..5453238f3ea 100644 --- a/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_test.go +++ b/testdata/gopath/src/project/pkg/controller/kraken/kraken_controller_test.go @@ -20,8 +20,6 @@ import ( "testing" "time" - creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" - "github.com/onsi/gomega" "golang.org/x/net/context" apierrors "k8s.io/apimachinery/pkg/api/errors" @@ -30,6 +28,8 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" ) var c client.Client diff --git a/testdata/gopath/src/project/pkg/controller/namespace/namespace_controller_suite_test.go b/testdata/gopath/src/project/pkg/controller/namespace/namespace_controller_suite_test.go index a6c62fb49e2..e4443287f49 100644 --- a/testdata/gopath/src/project/pkg/controller/namespace/namespace_controller_suite_test.go +++ b/testdata/gopath/src/project/pkg/controller/namespace/namespace_controller_suite_test.go @@ -23,14 +23,14 @@ import ( "sync" "testing" - "project/pkg/apis" - "github.com/onsi/gomega" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/envtest" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" + + "project/pkg/apis" ) var cfg *rest.Config diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/create_update_webhook.go b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/create_update_webhook.go index e8b2f63aefe..b226ca78e3f 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/create_update_webhook.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/create_update_webhook.go @@ -17,10 +17,10 @@ limitations under the License. package mutating import ( - crewv1 "project/pkg/apis/crew/v1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + + crewv1 "project/pkg/apis/crew/v1" ) func init() { diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/delete_webhook.go b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/delete_webhook.go index 50809fac553..e6b4bb3bb2f 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/delete_webhook.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/delete_webhook.go @@ -17,10 +17,10 @@ limitations under the License. package mutating import ( - crewv1 "project/pkg/apis/crew/v1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + + crewv1 "project/pkg/apis/crew/v1" ) func init() { diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_create_update_handler.go b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_create_update_handler.go index 0908c5aba43..bb9275df4e3 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_create_update_handler.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_create_update_handler.go @@ -20,11 +20,11 @@ import ( "context" "net/http" - crewv1 "project/pkg/apis/crew/v1" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + + crewv1 "project/pkg/apis/crew/v1" ) func init() { diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_delete_handler.go b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_delete_handler.go index aaf44367cdf..7147f369e59 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_delete_handler.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/firstmate/mutating/firstmate_delete_handler.go @@ -20,11 +20,11 @@ import ( "context" "net/http" - crewv1 "project/pkg/apis/crew/v1" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + + crewv1 "project/pkg/apis/crew/v1" ) func init() { diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/frigate_update_handler.go b/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/frigate_update_handler.go index cc0c19f18dd..62352ac15b3 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/frigate_update_handler.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/frigate_update_handler.go @@ -20,11 +20,11 @@ import ( "context" "net/http" - shipv1beta1 "project/pkg/apis/ship/v1beta1" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + + shipv1beta1 "project/pkg/apis/ship/v1beta1" ) func init() { diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/update_webhook.go b/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/update_webhook.go index a4eddcaf36c..e0187628ed1 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/update_webhook.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/frigate/validating/update_webhook.go @@ -17,10 +17,10 @@ limitations under the License. package validating import ( - shipv1beta1 "project/pkg/apis/ship/v1beta1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + + shipv1beta1 "project/pkg/apis/ship/v1beta1" ) func init() { diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/create_webhook.go b/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/create_webhook.go index 012217006b4..e895ad1c767 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/create_webhook.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/create_webhook.go @@ -17,10 +17,10 @@ limitations under the License. package validating import ( - creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" - admissionregistrationv1beta1 "k8s.io/api/admissionregistration/v1beta1" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/builder" + + creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" ) func init() { diff --git a/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/kraken_create_handler.go b/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/kraken_create_handler.go index ca196aeffc5..743bddbf68d 100644 --- a/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/kraken_create_handler.go +++ b/testdata/gopath/src/project/pkg/webhook/default_server/kraken/validating/kraken_create_handler.go @@ -20,11 +20,11 @@ import ( "context" "net/http" - creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" - "sigs.k8s.io/controller-runtime/pkg/runtime/inject" "sigs.k8s.io/controller-runtime/pkg/webhook/admission" "sigs.k8s.io/controller-runtime/pkg/webhook/admission/types" + + creaturesv2alpha1 "project/pkg/apis/creatures/v2alpha1" ) func init() { diff --git a/testdata/project-v2/controllers/namespace_controller.go b/testdata/project-v2/controllers/namespace_controller.go index fc181bfae66..34f98b654ed 100644 --- a/testdata/project-v2/controllers/namespace_controller.go +++ b/testdata/project-v2/controllers/namespace_controller.go @@ -20,11 +20,10 @@ import ( "context" "github.com/go-logr/logr" + corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/client" - - corev1 "k8s.io/api/core/v1" ) // NamespaceReconciler reconciles a Namespace object diff --git a/testdata/project-v2/controllers/suite_test.go b/testdata/project-v2/controllers/suite_test.go index ff4fd7dc0ab..6fbb5053d54 100644 --- a/testdata/project-v2/controllers/suite_test.go +++ b/testdata/project-v2/controllers/suite_test.go @@ -22,14 +22,15 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - - corev1 "k8s.io/api/core/v1" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/envtest" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/log/zap" + + corev1 "k8s.io/api/core/v1" + crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1" // +kubebuilder:scaffold:imports ) diff --git a/testdata/project-v2/main.go b/testdata/project-v2/main.go index d91ab63d35e..e14290343fb 100644 --- a/testdata/project-v2/main.go +++ b/testdata/project-v2/main.go @@ -20,12 +20,14 @@ import ( "flag" "os" - corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/runtime" clientgoscheme "k8s.io/client-go/kubernetes/scheme" _ "k8s.io/client-go/plugin/pkg/client/auth/gcp" ctrl "sigs.k8s.io/controller-runtime" "sigs.k8s.io/controller-runtime/pkg/log/zap" + + corev1 "k8s.io/api/core/v1" + crewv1 "sigs.k8s.io/kubebuilder/testdata/project-v2/api/v1" "sigs.k8s.io/kubebuilder/testdata/project-v2/controllers" // +kubebuilder:scaffold:imports