Skip to content

Commit

Permalink
Update slices.SortFunc to Go 1.21 signature
Browse files Browse the repository at this point in the history
  • Loading branch information
orishoshan committed Jul 25, 2024
1 parent f3817c8 commit 619cf21
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-fork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
go-version: 1.22

- name: Install dependencies
if: matrix.os == 'macos-latest'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: '1.21.0'
go-version: 1.22

- name: Install dependencies
if: matrix.os == 'macos-latest'
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

- uses: actions/setup-go@v3
with:
go-version: 1.21
go-version: 1.22
cache: true


Expand Down Expand Up @@ -85,7 +85,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@v3
with:
go-version: 1.19
go-version: 1.22
cache: true

- name: GCP auth
Expand Down
2 changes: 1 addition & 1 deletion go.mod

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 8 additions & 7 deletions src/pkg/intentsoutput/transform.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package intentsoutput

import (
"cmp"
"fmt"
"github.com/amit7itz/goset"
"github.com/otterize/intents-operator/src/operator/api/v1alpha3"
"github.com/otterize/otterize-cli/src/pkg/consts"
"github.com/otterize/otterize-cli/src/pkg/mapperclient"
"github.com/samber/lo"
"golang.org/x/exp/slices"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"slices"
)

type ServiceKey struct {
Expand Down Expand Up @@ -62,27 +63,27 @@ func removeUntypedIntentsIfTypedIntentExistsForServer(intents map[ServiceKey]v1a
}

func sortIntents(intents []v1alpha3.ClientIntents) {
slices.SortFunc(intents, func(intenta, intentb v1alpha3.ClientIntents) bool {
slices.SortFunc(intents, func(intenta, intentb v1alpha3.ClientIntents) int {
namea, nameb := intenta.Name, intentb.Name
namespacea, namespaceb := intenta.Namespace, intentb.Namespace

if namea != nameb {
return namea < nameb
return cmp.Compare(namea, nameb)
}

return namespacea < namespaceb
return cmp.Compare(namespacea, namespaceb)
})

for _, clientIntents := range intents {
slices.SortFunc(clientIntents.Spec.Calls, func(intenta, intentb v1alpha3.Intent) bool {
slices.SortFunc(clientIntents.Spec.Calls, func(intenta, intentb v1alpha3.Intent) int {
namea, nameb := intenta.GetTargetServerName(), intentb.GetTargetServerName()
namespacea, namespaceb := intenta.GetTargetServerNamespace(clientIntents.Namespace), intentb.GetTargetServerNamespace(clientIntents.Namespace)

if namea != nameb {
return namea < nameb
return cmp.Compare(namea, nameb)
}

return namespacea < namespaceb
return cmp.Compare(namespacea, namespaceb)
})
}
}
Expand Down

0 comments on commit 619cf21

Please sign in to comment.