chore(lint): enable ptrToRefParam rule from go-critic (#23424)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2025-06-16 21:28:57 +02:00
committed by GitHub
parent 061d5992da
commit ede2b32aea
5 changed files with 9 additions and 21 deletions

View File

@@ -64,7 +64,6 @@ linters:
- hugeParam
- importShadow
- paramTypeCombine
- ptrToRefParam
- rangeValCopy
- sloppyReassign
- tooManyResultsChecker

View File

@@ -34,7 +34,7 @@ func NewNotificationsCommand() *cobra.Command {
"notifications",
"argocd admin notifications",
applications,
settings.GetFactorySettingsForCLI(&argocdService, "argocd-notifications-secret", "argocd-notifications-cm", false),
settings.GetFactorySettingsForCLI(argocdService, "argocd-notifications-secret", "argocd-notifications-cm", false),
func(clientConfig clientcmd.ClientConfig) {
k8sCfg, err := clientConfig.ClientConfig()
if err != nil {

View File

@@ -28,19 +28,19 @@ func GetFactorySettings(argocdService service.Service, secretName, configMapName
}
// GetFactorySettingsForCLI allows the initialization of argocdService to be deferred until it is used, when InitGetVars is called.
func GetFactorySettingsForCLI(argocdService *service.Service, secretName, configMapName string, selfServiceNotificationEnabled bool) api.Settings {
func GetFactorySettingsForCLI(argocdService service.Service, secretName, configMapName string, selfServiceNotificationEnabled bool) api.Settings {
return api.Settings{
SecretName: secretName,
ConfigMapName: configMapName,
InitGetVars: func(cfg *api.Config, configMap *corev1.ConfigMap, secret *corev1.Secret) (api.GetVars, error) {
if *argocdService == nil {
if argocdService == nil {
return nil, errors.New("argocdService is not initialized")
}
if selfServiceNotificationEnabled {
return initGetVarsWithoutSecret(*argocdService, cfg, configMap, secret)
return initGetVarsWithoutSecret(argocdService, cfg, configMap, secret)
}
return initGetVars(*argocdService, cfg, configMap, secret)
return initGetVars(argocdService, cfg, configMap, secret)
},
}
}

View File

@@ -24,7 +24,6 @@ import (
"github.com/argoproj/argo-cd/v3/common"
"github.com/argoproj/argo-cd/v3/pkg/client/listers/application/v1alpha1"
"github.com/argoproj/argo-cd/v3/util/cache/appstate"
"github.com/argoproj/argo-cd/v3/util/dex"
"github.com/argoproj/argo-cd/v3/util/env"
httputil "github.com/argoproj/argo-cd/v3/util/http"
@@ -286,16 +285,7 @@ func (mgr *SessionManager) Parse(tokenString string) (jwt.Claims, string, error)
// GetLoginFailures retrieves the login failure information from the cache. Any modifications to the LoginAttemps map must be done in a thread-safe manner.
func (mgr *SessionManager) GetLoginFailures() map[string]LoginAttempts {
// Get failures from the cache
var failures map[string]LoginAttempts
err := mgr.storage.GetLoginAttempts(&failures)
if err != nil {
if !errors.Is(err, appstate.ErrCacheMiss) {
log.Errorf("Could not retrieve login attempts: %v", err)
}
failures = make(map[string]LoginAttempts)
}
return failures
return mgr.storage.GetLoginAttempts()
}
func expireOldFailedAttempts(maxAge time.Duration, failures map[string]LoginAttempts) int {

View File

@@ -110,9 +110,8 @@ func (storage *userStateStorage) loadRevokedTokens() error {
return nil
}
func (storage *userStateStorage) GetLoginAttempts(attempts *map[string]LoginAttempts) error {
*attempts = storage.attempts
return nil
func (storage *userStateStorage) GetLoginAttempts() map[string]LoginAttempts {
return storage.attempts
}
func (storage *userStateStorage) SetLoginAttempts(attempts map[string]LoginAttempts) error {
@@ -144,7 +143,7 @@ func (storage *userStateStorage) GetLockObject() *sync.RWMutex {
type UserStateStorage interface {
Init(ctx context.Context)
// GetLoginAttempts return number of concurrent login attempts
GetLoginAttempts(attempts *map[string]LoginAttempts) error
GetLoginAttempts() map[string]LoginAttempts
// SetLoginAttempts sets number of concurrent login attempts
SetLoginAttempts(attempts map[string]LoginAttempts) error
// RevokeToken revokes token with given id (information about revocation expires after specified timeout)