chore(applicationset): Fix modernize linter (#26320)

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
This commit is contained in:
Matthieu MOREL
2026-02-09 11:48:06 +01:00
committed by GitHub
parent 0cff632502
commit 34ccf865f6
7 changed files with 13 additions and 30 deletions

View File

@@ -4,6 +4,7 @@ import (
"context"
"errors"
"fmt"
"maps"
"strconv"
"strings"
"time"
@@ -115,9 +116,7 @@ func (g *PluginGenerator) generateParams(appSetGenerator *argoprojiov1alpha1.App
params := map[string]any{}
if useGoTemplate {
for k, v := range objectFound {
params[k] = v
}
maps.Copy(params, objectFound)
} else {
flat, err := flatten.Flatten(objectFound, "", flatten.DotStyle)
if err != nil {

View File

@@ -96,15 +96,9 @@ func (g *PullRequestGenerator) GenerateParams(appSetGenerator *argoprojiov1alpha
var shortSHALength int
var shortSHALength7 int
for _, pull := range pulls {
shortSHALength = 8
if len(pull.HeadSHA) < 8 {
shortSHALength = len(pull.HeadSHA)
}
shortSHALength = min(len(pull.HeadSHA), 8)
shortSHALength7 = 7
if len(pull.HeadSHA) < 7 {
shortSHALength7 = len(pull.HeadSHA)
}
shortSHALength7 = min(len(pull.HeadSHA), 7)
paramMap := map[string]any{
"number": strconv.FormatInt(pull.Number, 10),

View File

@@ -2,6 +2,7 @@ package generators
import (
"fmt"
"maps"
)
func appendTemplatedValues(values map[string]string, params map[string]any, useGoTemplate bool, goTemplateOptions []string) error {
@@ -26,9 +27,7 @@ func appendTemplatedValues(values map[string]string, params map[string]any, useG
}
}
for key, value := range tmp {
params[key] = value
}
maps.Copy(params, tmp)
return nil
}

View File

@@ -151,9 +151,9 @@ spec:
func newFakeAppsets(fakeAppsetYAML string) []argoappv1.ApplicationSet {
var results []argoappv1.ApplicationSet
appsetRawYamls := strings.Split(fakeAppsetYAML, "---")
appsetRawYamls := strings.SplitSeq(fakeAppsetYAML, "---")
for _, appsetRawYaml := range appsetRawYamls {
for appsetRawYaml := range appsetRawYamls {
var appset argoappv1.ApplicationSet
err := yaml.Unmarshal([]byte(appsetRawYaml), &appset)
if err != nil {

View File

@@ -83,7 +83,7 @@ func (g *GiteaService) List(ctx context.Context) ([]*PullRequest, error) {
// containLabels returns true if gotLabels contains expectedLabels
func giteaContainLabels(expectedLabels []string, gotLabels []*gitea.Label) bool {
gotLabelNamesMap := make(map[string]bool)
for i := 0; i < len(gotLabels); i++ {
for i := range gotLabels {
gotLabelNamesMap[gotLabels[i].Name] = true
}
for _, expected := range expectedLabels {

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"regexp"
"slices"
"strings"
argoprojiov1alpha1 "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
@@ -58,13 +59,7 @@ func matchFilter(ctx context.Context, provider SCMProviderService, repo *Reposit
}
if filter.LabelMatch != nil {
found := false
for _, label := range repo.Labels {
if filter.LabelMatch.MatchString(label) {
found = true
break
}
}
found := slices.ContainsFunc(repo.Labels, filter.LabelMatch.MatchString)
if !found {
return false, nil
}

View File

@@ -2,6 +2,7 @@ package utils
import (
"fmt"
"slices"
"sort"
"strconv"
"strings"
@@ -207,12 +208,7 @@ type Requirement struct {
}
func (r *Requirement) hasValue(value string) bool {
for i := range r.strValues {
if r.strValues[i] == value {
return true
}
}
return false
return slices.Contains(r.strValues, value)
}
func (r *Requirement) Matches(ls labels.Labels) bool {