WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 9d6e388

Browse files
committed
strings.Sort() --> slices.Sort()
Signed-off-by: Dale Haiducek <[email protected]>
1 parent 055eeff commit 9d6e388

File tree

5 files changed

+13
-13
lines changed

5 files changed

+13
-13
lines changed

controllers/configurationpolicy_utils.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package controllers
66
import (
77
"fmt"
88
"reflect"
9+
"slices"
910
"sort"
1011
"strconv"
1112
"strings"
@@ -441,7 +442,7 @@ func fmtMetadataForCompare(
441442

442443
// Format name of resource with its namespace (if it has one)
443444
func identifierStr(names []string, namespace string) (nameStr string) {
444-
sort.Strings(names)
445+
slices.Sort(names)
445446

446447
nameStr = "["
447448

@@ -535,7 +536,7 @@ func createStatus(
535536
}
536537
}
537538

538-
sort.Strings(otherReasons)
539+
slices.Sort(otherReasons)
539540
orderedReasons = append(orderedReasons, otherReasons...)
540541

541542
// The "reason" is more specific in the compliancyDetails section than in the relatedObjects section.
@@ -552,7 +553,7 @@ func createStatus(
552553
sortedNamespaces = append(sortedNamespaces, ns)
553554
}
554555

555-
sort.Strings(sortedNamespaces)
556+
slices.Sort(sortedNamespaces)
556557

557558
// If the object template was unnamed, then the object names can be different per namespace. If it was named,
558559
// all will be the same, but this accounts for both.
@@ -574,7 +575,7 @@ func createStatus(
574575
objectNameStrsToNamespaces[namesStr] = append(objectNameStrsToNamespaces[namesStr], ns)
575576
}
576577

577-
sort.Strings(sortedObjectNamesStrs)
578+
slices.Sort(sortedObjectNamesStrs)
578579

579580
// Process the object name strings in order to ensure a deterministic reason and message.
580581
for i, namesStr := range sortedObjectNamesStrs {

controllers/operatorpolicy_controller.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"reflect"
1313
"regexp"
1414
"slices"
15-
"sort"
1615
"strconv"
1716
"strings"
1817
"time"
@@ -1851,7 +1850,7 @@ func (r *OperatorPolicyReconciler) getRemainingCSVApprovals(
18511850

18521851
unapprovedCSVs := requiredCSVs.Difference(approvedCSVs).UnsortedList()
18531852

1854-
sort.Strings(unapprovedCSVs)
1853+
slices.Sort(unapprovedCSVs)
18551854

18561855
return unapprovedCSVs, nil
18571856
}

controllers/operatorpolicy_status.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package controllers
33
import (
44
"context"
55
"fmt"
6+
"slices"
67
"sort"
78
"strings"
89
"time"
@@ -701,13 +702,13 @@ func installPlanUpgradeCond(
701702
Reason: "InstallPlanRequiresApproval",
702703
}
703704

704-
sort.Strings(csvsInInstallPlan)
705+
slices.Sort(csvsInInstallPlan)
705706
cond.Message = fmt.Sprintf(
706707
"an InstallPlan to update to [%s] is available for approval", strings.Join(csvsInInstallPlan, ", "),
707708
)
708709

709710
if len(remainingCSVsToApprove) > 0 {
710-
sort.Strings(remainingCSVsToApprove)
711+
slices.Sort(remainingCSVsToApprove)
711712

712713
cond.Message += fmt.Sprintf(
713714
" but approval for [%v] is required", strings.Join(remainingCSVsToApprove, ", "),

pkg/common/namespace_selection.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"context"
88
"fmt"
99
"reflect"
10-
"sort"
10+
"slices"
1111
"strings"
1212
"sync"
1313

@@ -254,7 +254,7 @@ func (r *NamespaceSelectorReconciler) Get(objNS string, objName string, t policy
254254
}
255255

256256
selected, err := Matches(nsToMatch, t.Include, t.Exclude)
257-
sort.Strings(selected)
257+
slices.Sort(selected)
258258

259259
log.V(2).Info("Updating selection from Reconcile with matches",
260260
"namespace", objNS, "policy", objName, "selection", selected, "error", err)
@@ -345,7 +345,7 @@ func filter(allNSList corev1.NamespaceList, t policyv1.Target) ([]string, error)
345345
}
346346

347347
namespaces, err := Matches(nsToFilter, t.Include, t.Exclude)
348-
sort.Strings(namespaces)
348+
slices.Sort(namespaces)
349349

350350
return namespaces, err
351351
}

test/e2e/case38_install_operator_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"reflect"
88
"regexp"
99
"slices"
10-
"sort"
1110
"strconv"
1211
"strings"
1312
"time"
@@ -3593,7 +3592,7 @@ var _ = Describe("Testing OperatorPolicy", Ordered, Label("supports-hosted"), fu
35933592
installPlan.Object, "spec", "clusterServiceVersionNames",
35943593
)
35953594

3596-
sort.Strings(csvNames)
3595+
slices.Sort(csvNames)
35973596

35983597
if !reflect.DeepEqual(
35993598
csvNames, []string{"argocd-operator.v0.9.1", "strimzi-cluster-operator.v0.35.0"},

0 commit comments

Comments
 (0)