chore(lint): enable typeDefFirst rule from go-critic (#23414)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-06-16 18:09:08 +02:00
committed by GitHub
parent 114693dcc2
commit 6b24fcb32c
4 changed files with 30 additions and 31 deletions

View File

@@ -69,7 +69,6 @@ linters:
- rangeValCopy - rangeValCopy
- sloppyReassign - sloppyReassign
- tooManyResultsChecker - tooManyResultsChecker
- typeDefFirst
- unnamedResult - unnamedResult
- whyNoLint - whyNoLint

View File

@@ -20,6 +20,15 @@ import (
argov1alpha1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1" argov1alpha1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
) )
type mockAddRateLimitingInterface struct {
addedItems []reconcile.Request
}
// Add checks the type, and adds it to the internal list of received additions
func (obj *mockAddRateLimitingInterface) Add(item reconcile.Request) {
obj.addedItems = append(obj.addedItems, item)
}
func TestClusterEventHandler(t *testing.T) { func TestClusterEventHandler(t *testing.T) {
scheme := runtime.NewScheme() scheme := runtime.NewScheme()
err := argov1alpha1.AddToScheme(scheme) err := argov1alpha1.AddToScheme(scheme)
@@ -556,15 +565,6 @@ func TestClusterEventHandler(t *testing.T) {
} }
} }
// Add checks the type, and adds it to the internal list of received additions
func (obj *mockAddRateLimitingInterface) Add(item reconcile.Request) {
obj.addedItems = append(obj.addedItems, item)
}
type mockAddRateLimitingInterface struct {
addedItems []reconcile.Request
}
func TestNestedGeneratorHasClusterGenerator_NestedClusterGenerator(t *testing.T) { func TestNestedGeneratorHasClusterGenerator_NestedClusterGenerator(t *testing.T) {
nested := argov1alpha1.ApplicationSetNestedGenerator{ nested := argov1alpha1.ApplicationSetNestedGenerator{
Clusters: &argov1alpha1.ClusterGenerator{}, Clusters: &argov1alpha1.ClusterGenerator{},

View File

@@ -54,6 +54,14 @@ type NotificationController interface {
Init(ctx context.Context) error Init(ctx context.Context) error
} }
type notificationController struct {
ctrl controller.NotificationController
appInformer cache.SharedIndexInformer
appProjInformer cache.SharedIndexInformer
secretInformer cache.SharedIndexInformer
configMapInformer cache.SharedIndexInformer
}
func NewController( func NewController(
k8sClient kubernetes.Interface, k8sClient kubernetes.Interface,
client dynamic.Interface, client dynamic.Interface,
@@ -171,14 +179,6 @@ func newInformer(resClient dynamic.ResourceInterface, controllerNamespace string
return informer return informer
} }
type notificationController struct {
ctrl controller.NotificationController
appInformer cache.SharedIndexInformer
appProjInformer cache.SharedIndexInformer
secretInformer cache.SharedIndexInformer
configMapInformer cache.SharedIndexInformer
}
func (c *notificationController) Init(ctx context.Context) error { func (c *notificationController) Init(ctx context.Context) error {
// resolve certificates using injected "argocd-tls-certs-cm" ConfigMap // resolve certificates using injected "argocd-tls-certs-cm" ConfigMap
httputil.SetCertResolver(argocert.GetCertificateForConnect) httputil.SetCertResolver(argocert.GetCertificateForConnect)

View File

@@ -43,6 +43,19 @@ type ClusterRuntimeInfo interface {
GetKubeVersion() string GetKubeVersion() string
} }
// CachedManifestResponse represents a cached result of a previous manifest generation operation, including the caching
// of a manifest generation error, plus additional information on previous failures
type CachedManifestResponse struct {
// NOTE: When adding fields to this struct, you MUST also update shallowCopy()
CacheEntryHash string `json:"cacheEntryHash"`
ManifestResponse *apiclient.ManifestResponse `json:"manifestResponse"`
MostRecentError string `json:"mostRecentError"`
FirstFailureTimestamp int64 `json:"firstFailureTimestamp"`
NumberOfConsecutiveFailures int `json:"numberOfConsecutiveFailures"`
NumberOfCachedResponsesReturned int `json:"numberOfCachedResponsesReturned"`
}
func NewCache(cache *cacheutil.Cache, repoCacheExpiration time.Duration, revisionCacheExpiration time.Duration, revisionCacheLockTimeout time.Duration) *Cache { func NewCache(cache *cacheutil.Cache, repoCacheExpiration time.Duration, revisionCacheExpiration time.Duration, revisionCacheLockTimeout time.Duration) *Cache {
return &Cache{cache, repoCacheExpiration, revisionCacheExpiration, revisionCacheLockTimeout} return &Cache{cache, repoCacheExpiration, revisionCacheExpiration, revisionCacheLockTimeout}
} }
@@ -535,16 +548,3 @@ func (cmr *CachedManifestResponse) generateCacheEntryHash() (string, error) {
fnvHash := h.Sum(nil) fnvHash := h.Sum(nil)
return base64.URLEncoding.EncodeToString(fnvHash), nil return base64.URLEncoding.EncodeToString(fnvHash), nil
} }
// CachedManifestResponse represents a cached result of a previous manifest generation operation, including the caching
// of a manifest generation error, plus additional information on previous failures
type CachedManifestResponse struct {
// NOTE: When adding fields to this struct, you MUST also update shallowCopy()
CacheEntryHash string `json:"cacheEntryHash"`
ManifestResponse *apiclient.ManifestResponse `json:"manifestResponse"`
MostRecentError string `json:"mostRecentError"`
FirstFailureTimestamp int64 `json:"firstFailureTimestamp"`
NumberOfConsecutiveFailures int `json:"numberOfConsecutiveFailures"`
NumberOfCachedResponsesReturned int `json:"numberOfCachedResponsesReturned"`
}