Skip to content
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

Add goimports #415

Closed
wants to merge 3 commits into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,21 @@ jobs:
run: |
make verify-fmt

verify-imports:
name: Verify imports
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.21.x
uses: actions/setup-go@v4
with:
go-version: 1.21.x
id: go
- name: Check out code
uses: actions/checkout@v3
- name: Run make verify-imports
run: |
make verify-imports

test-scripts:
name: Test Scripts
strategy:
Expand Down
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,13 @@ $(ACT):
.PHONY: act
act: $(ACT) ## Download act locally if necessary.

OPENSHIFT_GOIMPORTS ?= $(PROJECT_PATH)/bin/openshift-goimports
OPENSHIFT_GOIMPORTS_VERSION ?= c70783e636f2213cac683f6865d88c5edace3157
.PHONY: openshift-goimports
openshift-goimports: $(OPENSHIFT_GOIMPORTS) ## Download openshift-goimports locally if necessary
$(OPENSHIFT_GOIMPORTS):
$(call go-install-tool,$(OPENSHIFT_GOIMPORTS),github.com/openshift-eng/openshift-goimports@$(OPENSHIFT_GOIMPORTS_VERSION))

##@ Development
define patch-config
envsubst \
Expand Down Expand Up @@ -274,12 +281,18 @@ dependencies-manifests: ## Update kuadrant dependencies manifests.
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

.PHONY: fmt
fmt: ## Run go fmt against code.
go fmt ./...

.PHONY: vet
vet: ## Run go vet against code.
go vet ./...

.PHONY: imports
imports: openshift-goimports ## Run openshift goimports against code.
$(OPENSHIFT_GOIMPORTS) -m github.com/kuadrant/kuadrant-operator -i github.com/kuadrant

.PHONY: clean-cov
clean-cov: ## Remove coverage reports
rm -rf coverage
Expand Down
4 changes: 3 additions & 1 deletion api/v1beta1/kuadrant_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,12 @@ package v1beta1
import (
"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"
limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"

"github.com/kuadrant/kuadrant-operator/pkg/common"
)

Expand Down
3 changes: 2 additions & 1 deletion api/v1beta1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions api/v1beta2/authpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import (

"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"

"github.com/kuadrant/kuadrant-operator/pkg/common"
)

Expand Down
1 change: 1 addition & 0 deletions api/v1beta2/authpolicy_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"

"github.com/kuadrant/kuadrant-operator/pkg/common"
)

Expand Down
4 changes: 3 additions & 1 deletion api/v1beta2/ratelimitpolicy_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import (

"github.com/go-logr/logr"
"github.com/google/go-cmp/cmp"
"github.com/kuadrant/kuadrant-operator/pkg/common"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

"github.com/kuadrant/kuadrant-operator/pkg/common"
)

// EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
Expand Down
4 changes: 2 additions & 2 deletions api/v1beta2/route_selectors.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package v1beta2

import (
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

orderedmap "github.com/elliotchance/orderedmap/v2"

gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

"github.com/kuadrant/kuadrant-operator/pkg/common"
)

Expand Down
3 changes: 2 additions & 1 deletion api/v1beta2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions controllers/authpolicy_authconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import (
"strings"

"github.com/go-logr/logr"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"

api "github.com/kuadrant/kuadrant-operator/api/v1beta2"
"github.com/kuadrant/kuadrant-operator/pkg/common"
)
Expand Down
3 changes: 2 additions & 1 deletion controllers/authpolicy_authconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import (
"reflect"
"testing"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"
"k8s.io/utils/ptr"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"
)

func TestAuthorinoConditionsFromHTTPRouteRule(t *testing.T) {
Expand Down
2 changes: 2 additions & 0 deletions controllers/authpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"

"github.com/go-logr/logr"

apierrors "k8s.io/apimachinery/pkg/api/errors"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -13,6 +14,7 @@ import (
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"

api "github.com/kuadrant/kuadrant-operator/api/v1beta2"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/reconcilers"
Expand Down
7 changes: 5 additions & 2 deletions controllers/authpolicy_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@ import (
"strings"
"time"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"
api "github.com/kuadrant/kuadrant-operator/api/v1beta2"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
secv1beta1resources "istio.io/client-go/pkg/apis/security/v1beta1"

apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand All @@ -25,6 +24,10 @@ import (
logf "sigs.k8s.io/controller-runtime/pkg/log"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"

api "github.com/kuadrant/kuadrant-operator/api/v1beta2"
)

const (
Expand Down
8 changes: 4 additions & 4 deletions controllers/authpolicy_istio_authorizationpolicy.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ import (
"reflect"

"github.com/go-logr/logr"
istiosecurity "istio.io/api/security/v1beta1"
istio "istio.io/client-go/pkg/apis/security/v1beta1"

apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/utils/env"
"sigs.k8s.io/controller-runtime/pkg/client"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
gatewayapiv1alpha2 "sigs.k8s.io/gateway-api/apis/v1alpha2"

istiosecurity "istio.io/api/security/v1beta1"
istio "istio.io/client-go/pkg/apis/security/v1beta1"

api "github.com/kuadrant/kuadrant-operator/api/v1beta2"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/reconcilers"
"k8s.io/utils/env"
)

var KuadrantExtAuthProviderName = env.GetString("AUTH_PROVIDER", "kuadrant-authorization")
Expand Down
1 change: 1 addition & 0 deletions controllers/authpolicy_istio_authorizationpolicy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"testing"

istiosecurity "istio.io/api/security/v1beta1"

"k8s.io/utils/ptr"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
)
Expand Down
2 changes: 2 additions & 0 deletions controllers/authpolicy_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import (
"slices"

"github.com/go-logr/logr"

apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

authorinoapi "github.com/kuadrant/authorino/api/v1beta2"

api "github.com/kuadrant/kuadrant-operator/api/v1beta2"
"github.com/kuadrant/kuadrant-operator/pkg/common"
)
Expand Down
1 change: 1 addition & 0 deletions controllers/gateway_eventmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/go-logr/logr"

"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down
1 change: 1 addition & 0 deletions controllers/gateway_kuadrant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"strings"

"github.com/go-logr/logr"

apierrors "k8s.io/apimachinery/pkg/api/errors"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
Expand Down
1 change: 1 addition & 0 deletions controllers/gateway_kuadrant_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

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

"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand Down
7 changes: 4 additions & 3 deletions controllers/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ import (
"path/filepath"
"time"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"

"github.com/google/uuid"
. "github.com/onsi/gomega"

corev1 "k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
Expand All @@ -30,6 +28,9 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"
logf "sigs.k8s.io/controller-runtime/pkg/log"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
)

func ApplyKuadrantCR(namespace string) {
Expand Down
1 change: 1 addition & 0 deletions controllers/httproute_eventmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"

"github.com/go-logr/logr"

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

Expand Down
1 change: 1 addition & 0 deletions controllers/httprouteparentrefs_eventmapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

"github.com/go-logr/logr"

"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"
Expand Down
19 changes: 10 additions & 9 deletions controllers/kuadrant_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,31 +20,32 @@ import (
"context"
"encoding/json"

"github.com/kuadrant/kuadrant-operator/pkg/kuadranttools"
corev1 "k8s.io/api/core/v1"
"k8s.io/utils/env"

"github.com/go-logr/logr"
authorinov1beta1 "github.com/kuadrant/authorino-operator/api/v1beta1"
maistrav1 "github.com/kuadrant/kuadrant-operator/api/external/maistra/v1"
maistrav2 "github.com/kuadrant/kuadrant-operator/api/external/maistra/v2"
limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"
"golang.org/x/sync/errgroup"
iopv1alpha1 "istio.io/istio/operator/pkg/apis/istio/v1alpha1"
istiov1alpha1 "maistra.io/istio-operator/api/v1alpha1"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
apimeta "k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
istiov1alpha1 "maistra.io/istio-operator/api/v1alpha1"
"k8s.io/utils/env"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1"

authorinov1beta1 "github.com/kuadrant/authorino-operator/api/v1beta1"
limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"

maistrav1 "github.com/kuadrant/kuadrant-operator/api/external/maistra/v1"
maistrav2 "github.com/kuadrant/kuadrant-operator/api/external/maistra/v2"
kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
"github.com/kuadrant/kuadrant-operator/pkg/istio"
"github.com/kuadrant/kuadrant-operator/pkg/kuadranttools"
"github.com/kuadrant/kuadrant-operator/pkg/log"
"github.com/kuadrant/kuadrant-operator/pkg/reconcilers"
)
Expand Down
4 changes: 3 additions & 1 deletion controllers/kuadrant_status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"slices"

"github.com/go-logr/logr"

corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -15,9 +16,10 @@ import (
"sigs.k8s.io/controller-runtime/pkg/reconcile"

authorinov1beta1 "github.com/kuadrant/authorino-operator/api/v1beta1"
limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"

kuadrantv1beta1 "github.com/kuadrant/kuadrant-operator/api/v1beta1"
"github.com/kuadrant/kuadrant-operator/pkg/common"
limitadorv1alpha1 "github.com/kuadrant/limitador-operator/api/v1alpha1"
)

const (
Expand Down
Loading
Loading