mirror of
https://github.com/argoproj/argo-cd.git
synced 2026-02-20 01:28:45 +01:00
chore(util): Fix modernize linter (#26316)
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com> Co-authored-by: Blake Pettersson <blake.pettersson@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package diff
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
|
||||
"github.com/argoproj/argo-cd/v3/util/glob"
|
||||
@@ -89,27 +90,18 @@ func resourceToIgnoreDifference(resource v1alpha1.ResourceIgnoreDifferences) *Ig
|
||||
// skipping repeated configs.
|
||||
func mergeIgnoreDifferences(from *IgnoreDifference, target *IgnoreDifference) {
|
||||
for _, jqPath := range from.JQPathExpressions {
|
||||
if !contains(target.JQPathExpressions, jqPath) {
|
||||
if !slices.Contains(target.JQPathExpressions, jqPath) {
|
||||
target.JQPathExpressions = append(target.JQPathExpressions, jqPath)
|
||||
}
|
||||
}
|
||||
for _, jsonPointer := range from.JSONPointers {
|
||||
if !contains(target.JSONPointers, jsonPointer) {
|
||||
if !slices.Contains(target.JSONPointers, jsonPointer) {
|
||||
target.JSONPointers = append(target.JSONPointers, jsonPointer)
|
||||
}
|
||||
}
|
||||
for _, manager := range from.ManagedFieldsManagers {
|
||||
if !contains(target.ManagedFieldsManagers, manager) {
|
||||
if !slices.Contains(target.ManagedFieldsManagers, manager) {
|
||||
target.ManagedFieldsManagers = append(target.ManagedFieldsManagers, manager)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func contains(slice []string, e string) bool {
|
||||
for _, s := range slice {
|
||||
if s == e {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -731,8 +731,8 @@ func ExtractOrgFromRepoURL(repoURL string) (string, error) {
|
||||
// We distinguish this from the valid ssh://git@host:22/org/repo (with port number).
|
||||
if strings.HasPrefix(repoURL, "ssh://git@") {
|
||||
remainder := strings.TrimPrefix(repoURL, "ssh://")
|
||||
if colonIdx := strings.Index(remainder, ":"); colonIdx != -1 {
|
||||
afterColon := remainder[colonIdx+1:]
|
||||
if _, after, ok := strings.Cut(remainder, ":"); ok {
|
||||
afterColon := after
|
||||
slashIdx := strings.Index(afterColon, "/")
|
||||
|
||||
// Check if what follows the colon is a port number
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io
|
||||
|
||||
import (
|
||||
"maps"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
|
||||
@@ -65,8 +66,6 @@ func (p *RandomizedTempPaths) GetPaths() map[string]string {
|
||||
p.lock.RLock()
|
||||
defer p.lock.RUnlock()
|
||||
paths := map[string]string{}
|
||||
for k, v := range p.paths {
|
||||
paths[k] = v
|
||||
}
|
||||
maps.Copy(paths, p.paths)
|
||||
return paths
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
@@ -77,12 +78,7 @@ var KustomizationNames = []string{"kustomization.yaml", "kustomization.yml", "Ku
|
||||
|
||||
// IsKustomization checks if the given file name matches any known kustomization file names.
|
||||
func IsKustomization(path string) bool {
|
||||
for _, kustomization := range KustomizationNames {
|
||||
if path == kustomization {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(KustomizationNames, path)
|
||||
}
|
||||
|
||||
// findKustomizeFile looks for any known kustomization file in the path
|
||||
|
||||
@@ -3,6 +3,7 @@ package settings
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"maps"
|
||||
"strings"
|
||||
|
||||
"github.com/argoproj/notifications-engine/pkg/api"
|
||||
@@ -229,8 +230,6 @@ func injectLegacyVar(ctx map[string]string, serviceType string) map[string]strin
|
||||
res := map[string]string{
|
||||
"notificationType": serviceType,
|
||||
}
|
||||
for k, v := range ctx {
|
||||
res[k] = v
|
||||
}
|
||||
maps.Copy(res, ctx)
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -627,7 +627,7 @@ func Test_azureApp_getFederatedServiceAccountToken(t *testing.T) {
|
||||
var wg sync.WaitGroup
|
||||
numGoroutines := 10
|
||||
wg.Add(numGoroutines)
|
||||
for i := 0; i < numGoroutines; i++ {
|
||||
for range numGoroutines {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
_, err := app.getFederatedServiceAccountToken(t.Context())
|
||||
@@ -647,7 +647,7 @@ func Test_azureApp_getFederatedServiceAccountToken(t *testing.T) {
|
||||
app.expires = time.Now()
|
||||
numGoroutines := 10
|
||||
wg.Add(numGoroutines)
|
||||
for i := 0; i < numGoroutines; i++ {
|
||||
for range numGoroutines {
|
||||
go func() {
|
||||
defer wg.Done()
|
||||
_, err := app.getFederatedServiceAccountToken(t.Context())
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"fmt"
|
||||
"maps"
|
||||
"net/http"
|
||||
"os"
|
||||
"sort"
|
||||
@@ -135,7 +136,6 @@ func TestGetExtensionConfigs(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
// When
|
||||
output := getExtensionConfigs(tc.input)
|
||||
@@ -545,9 +545,7 @@ func TestGetResourceOverrides_with_splitted_keys(t *testing.T) {
|
||||
}
|
||||
|
||||
func mergemaps(mapA map[string]string, mapB map[string]string) map[string]string {
|
||||
for k, v := range mapA {
|
||||
mapB[k] = v
|
||||
}
|
||||
maps.Copy(mapB, mapA)
|
||||
return mapB
|
||||
}
|
||||
|
||||
@@ -1873,8 +1871,6 @@ rootCA: "invalid"`},
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
if testCase.expectNilTLSConfig {
|
||||
assert.Nil(t, testCase.settings.OIDCTLSConfig())
|
||||
|
||||
Reference in New Issue
Block a user