From f5a1f50b0eb3e11afd9da1ca6b2a33eb19d9c3f6 Mon Sep 17 00:00:00 2001 From: pashakostohrys Date: Mon, 23 Sep 2024 14:22:11 +0300 Subject: [PATCH] fix linter --- acr_controller/application/client.go | 3 ++- acr_controller/controller/broadcaster.go | 6 ++++-- acr_controller/controller/controller.go | 16 +++++----------- acr_controller/server.go | 20 +++++++++++--------- acr_controller/service/acr_service.go | 9 ++++----- acr_controller/service/acr_service_test.go | 10 ++++------ server/application/application.go | 5 ++++- 7 files changed, 34 insertions(+), 35 deletions(-) diff --git a/acr_controller/application/client.go b/acr_controller/application/client.go index 80a3bbb8caa71..ed09e3e0f5f17 100644 --- a/acr_controller/application/client.go +++ b/acr_controller/application/client.go @@ -10,8 +10,9 @@ import ( "strings" "time" - appclient "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" "google.golang.org/grpc" + + appclient "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" ) //go:generate go run github.com/vektra/mockery/v2@v2.43.2 --name=ApplicationClient diff --git a/acr_controller/controller/broadcaster.go b/acr_controller/controller/broadcaster.go index 6b20e7d84d1a6..f91ff7fec082b 100644 --- a/acr_controller/controller/broadcaster.go +++ b/acr_controller/controller/broadcaster.go @@ -1,10 +1,12 @@ package application_change_revision_controller import ( - appv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" + "sync" + + "sync" + log "github.com/sirupsen/logrus" "k8s.io/apimachinery/pkg/watch" - "sync" ) type subscriber struct { diff --git a/acr_controller/controller/controller.go b/acr_controller/controller/controller.go index 4d65002aec92a..06746b350fff9 100644 --- a/acr_controller/controller/controller.go +++ b/acr_controller/controller/controller.go @@ -2,23 +2,19 @@ package application_change_revision_controller import ( "context" + "time" + appclient "github.com/argoproj/argo-cd/v2/acr_controller/application" "github.com/argoproj/argo-cd/v2/acr_controller/service" appclientset "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned" - "time" appv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" applisters "github.com/argoproj/argo-cd/v2/pkg/client/listers/application/v1alpha1" servercache "github.com/argoproj/argo-cd/v2/server/cache" "github.com/argoproj/argo-cd/v2/util/settings" - log "github.com/sirupsen/logrus" - "k8s.io/apimachinery/pkg/watch" - "k8s.io/client-go/tools/cache" ) -var ( - watchAPIBufferSize = 1000 -) +var watchAPIBufferSize = 1000 type ACRController interface { Run(ctx context.Context) @@ -52,9 +48,7 @@ func NewApplicationChangeRevisionController(appInformer cache.SharedIndexInforme } func (c *applicationChangeRevisionController) Run(ctx context.Context) { - var ( - logCtx log.FieldLogger = log.StandardLogger() - ) + var logCtx log.FieldLogger = log.StandardLogger() calculateIfPermitted := func(ctx context.Context, a appv1.Application, eventType watch.EventType, ts string) error { if eventType == watch.Bookmark || eventType == watch.Deleted { @@ -64,7 +58,7 @@ func (c *applicationChangeRevisionController) Run(ctx context.Context) { return c.acrService.ChangeRevision(ctx, &a) } - //TODO: move to abstraction + // TODO: move to abstraction eventsChannel := make(chan *appv1.ApplicationWatchEvent, watchAPIBufferSize) unsubscribe := c.appBroadcaster.Subscribe(eventsChannel) defer unsubscribe() diff --git a/acr_controller/server.go b/acr_controller/server.go index 7182577487b00..b79302216e506 100644 --- a/acr_controller/server.go +++ b/acr_controller/server.go @@ -4,14 +4,22 @@ import ( "context" "crypto/tls" "fmt" - appclient "github.com/argoproj/argo-cd/v2/acr_controller/application" - acr_controller "github.com/argoproj/argo-cd/v2/acr_controller/controller" - "github.com/argoproj/argo-cd/v2/event_reporter/reporter" "net" "net/http" "strings" "time" + appclient "github.com/argoproj/argo-cd/v2/acr_controller/application" + acr_controller "github.com/argoproj/argo-cd/v2/acr_controller/controller" + "github.com/argoproj/argo-cd/v2/event_reporter/reporter" + + "github.com/redis/go-redis/v9" + log "github.com/sirupsen/logrus" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/tools/cache" + appclientset "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned" appinformer "github.com/argoproj/argo-cd/v2/pkg/client/informers/externalversions" applisters "github.com/argoproj/argo-cd/v2/pkg/client/listers/application/v1alpha1" @@ -20,12 +28,6 @@ import ( errorsutil "github.com/argoproj/argo-cd/v2/util/errors" "github.com/argoproj/argo-cd/v2/util/healthz" settings_util "github.com/argoproj/argo-cd/v2/util/settings" - "github.com/redis/go-redis/v9" - log "github.com/sirupsen/logrus" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/wait" - "k8s.io/client-go/kubernetes" - "k8s.io/client-go/tools/cache" ) const ( diff --git a/acr_controller/service/acr_service.go b/acr_controller/service/acr_service.go index 4a41ab5eefe41..45ac771ded9ad 100644 --- a/acr_controller/service/acr_service.go +++ b/acr_controller/service/acr_service.go @@ -3,15 +3,14 @@ package service import ( "context" "encoding/json" - argoclient "github.com/argoproj/argo-cd/v2/acr_controller/application" - appclient "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - application "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - appclientset "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned" + "sync" + + "sync" + log "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/pointer" - "sync" ) type ACRService interface { diff --git a/acr_controller/service/acr_service_test.go b/acr_controller/service/acr_service_test.go index c2f950a8bfe14..12e19b5994b1f 100644 --- a/acr_controller/service/acr_service_test.go +++ b/acr_controller/service/acr_service_test.go @@ -2,18 +2,16 @@ package service import ( "context" - "github.com/argoproj/argo-cd/v2/acr_controller/application/mocks" - appclient "github.com/argoproj/argo-cd/v2/pkg/apiclient/application" - appsv1 "github.com/argoproj/argo-cd/v2/pkg/apis/application/v1alpha1" - apps "github.com/argoproj/argo-cd/v2/pkg/client/clientset/versioned/fake" - "github.com/argoproj/argo-cd/v2/test" + "testing" + + "testing" + "github.com/stretchr/testify/assert" "github.com/stretchr/testify/mock" "github.com/stretchr/testify/require" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/pointer" "sigs.k8s.io/yaml" - "testing" ) const fakeApp = ` diff --git a/server/application/application.go b/server/application/application.go index ea39cd6b31b50..8d69a8d87549e 100644 --- a/server/application/application.go +++ b/server/application/application.go @@ -5,7 +5,6 @@ import ( "encoding/json" "errors" "fmt" - "github.com/argoproj/argo-cd/v2/util/app/path" "math" "reflect" "sort" @@ -13,6 +12,10 @@ import ( "strings" "time" + "github.com/argoproj/argo-cd/v2/util/app/path" + + "github.com/argoproj/argo-cd/v2/util/app/path" + kubecache "github.com/argoproj/gitops-engine/pkg/cache" "github.com/argoproj/gitops-engine/pkg/diff" "github.com/argoproj/gitops-engine/pkg/sync/common"