Skip to content

Commit

Permalink
Update slices.SortFunc to Go 1.21 signature (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
orishoshan authored Jul 25, 2024
1 parent a1f6411 commit f285129
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/lint.yml
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

- name: go vet
run: go vet ./...
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 f285129

Please sign in to comment.