Skip to content

Commit

Permalink
fix: make it go1.21 and linter compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
antiphp committed Dec 10, 2024
1 parent 17f5491 commit 2a5fde7
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 3 deletions.
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0
golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4=
golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM=
golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e h1:+WEEuIdZHnUeJJmEUjyYC2gfUMj69yZXw17EnHg/otA=
golang.org/x/exp v0.0.0-20220722155223-a9213eeb770e/go.mod h1:Kr81I6Kryrl9sr8s2FK3vxD90NdsKWRuOIl2O4CvYbA=
golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js=
golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
Expand Down
2 changes: 1 addition & 1 deletion pkg/sdkserver/localsdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ func TestLocalSDKServerSetAnnotations(t *testing.T) {
assertInitialWatchUpdate(t, stream)

// make sure length of l.updateObservers is at least 1
err = wait.PollImmediate(time.Second, 10*time.Second, func() (bool, error) {
err = wait.PollUntilContextTimeout(context.Background(), time.Second, 10*time.Second, true, func(ctx context.Context) (bool, error) {
ret := false
l.updateObservers.Range(func(_, _ interface{}) bool {
ret = true
Expand Down
18 changes: 16 additions & 2 deletions sdks/go/sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"fmt"
"io"
"os"
"sort"
"time"

"github.com/pkg/errors"
"google.golang.org/grpc/credentials/insecure"

"golang.org/x/exp/maps"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

"agones.dev/agones/pkg/sdk"
)
Expand Down Expand Up @@ -139,6 +140,19 @@ func (s *SDK) SetAnnotation(key, value string) error {
return errors.Wrap(err, "could not set annotation")
}

// SetAnnotations sets a metadata annotation on the `GameServer` with the prefix "agones.dev/sdk-".
func (s *SDK) SetAnnotations(keyVals map[string]string) error {
keys := maps.Keys(keyVals)
sort.Strings(keys)

kvs := make([]*sdk.KeyValue, 0, len(keyVals))
for _, key := range keys {
kvs = append(kvs, &sdk.KeyValue{Key: key, Value: keyVals[key]})
}
_, err := s.client.SetAnnotations(s.ctx, &sdk.KeyValues{KeyValues: kvs})
return errors.Wrap(err, "could not set annotations")
}

// GameServer retrieve the GameServer details.
func (s *SDK) GameServer() (*sdk.GameServer, error) {
gs, err := s.client.GetGameServer(s.ctx, &sdk.Empty{})
Expand Down
27 changes: 27 additions & 0 deletions vendor/golang.org/x/exp/LICENSE

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

22 changes: 22 additions & 0 deletions vendor/golang.org/x/exp/PATENTS

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

94 changes: 94 additions & 0 deletions vendor/golang.org/x/exp/maps/maps.go

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

0 comments on commit 2a5fde7

Please sign in to comment.