Skip to content

Commit

Permalink
Merge pull request #315 from openconfig/go1.21-dev-wenovus
Browse files Browse the repository at this point in the history
Move to Go 1.21 and update deps
  • Loading branch information
wenovus authored Oct 26, 2023
2 parents 87d5fd1 + e6e82e9 commit e244193
Show file tree
Hide file tree
Showing 157 changed files with 139,505 additions and 121,578 deletions.
2 changes: 1 addition & 1 deletion .bazelversion
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6.1.2
6.4.0
2 changes: 1 addition & 1 deletion .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
steps:
- uses: actions/setup-go@v4
with:
go-version: 1.20.x
go-version: stable
cache: false
- uses: actions/checkout@v3
- name: golangci-lint
Expand Down
2 changes: 2 additions & 0 deletions BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
load("@bazel_gazelle//:def.bzl", "gazelle")

# gazelle:prefix github.com/openconfig/lemming
# gazelle:resolve proto proto google/rpc/status.proto @googleapis//google/rpc:status_proto
# gazelle:resolve proto go google/rpc/status.proto @org_golang_google_genproto_googleapis_rpc//status
# gazelle:resolve go github.com/p4lang/p4runtime/go/p4/v1 @com_github_p4lang_p4runtime//:p4runtime_go_proto
# gazelle:build_file_name BUILD
gazelle(
Expand Down
35 changes: 24 additions & 11 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ http_archive(

http_archive(
name = "io_bazel_rules_go",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
sha256 = "91585017debb61982f7054c9688857a2ad1fd823fc3f9cb05048b0025c47d023",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.42.0/rules_go-v0.42.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
sha256 = "29218f8e0cebe583643cbf93cae6f971be8a2484cdcfa1e45057658df8d54002",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.32.0/bazel-gazelle-v0.32.0.tar.gz",
],
)

Expand All @@ -52,6 +52,15 @@ http_archive(
],
)

http_archive(
name = "googleapis",
sha256 = "9d1a930e767c93c825398b8f8692eca3fe353b9aaadedfbcf1fca2282c85df88",
strip_prefix = "googleapis-64926d52febbf298cb82a8f472ade4a3969ba922",
urls = [
"https://github.com/googleapis/googleapis/archive/64926d52febbf298cb82a8f472ade4a3969ba922.zip",
],
)

load("@bazel_skylib//:workspace.bzl", "bazel_skylib_workspace")

bazel_skylib_workspace()
Expand All @@ -60,15 +69,18 @@ bazel_skylib_workspace()

load("@io_bazel_rules_go//go:deps.bzl", "go_register_toolchains", "go_rules_dependencies")
load("@bazel_gazelle//:deps.bzl", "gazelle_dependencies")

go_rules_dependencies()

go_register_toolchains(version = "1.21.3")

# go_repositories

load("//:repositories.bzl", "go_repositories")

# gazelle:repository_macro repositories.bzl%go_repositories
go_repositories()

go_rules_dependencies()

go_register_toolchains(version = "1.20.2")

gazelle_dependencies()

# Protobuf and gRPC
Expand All @@ -93,7 +105,8 @@ load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps")

protobuf_deps()

load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
#load("@com_google_googleapis//:repository_rules.bzl", "switched_rules_by_language")
load("@googleapis//:repository_rules.bzl", "switched_rules_by_language")

switched_rules_by_language(
name = "com_google_googleapis_imports",
Expand Down
3 changes: 1 addition & 2 deletions bgp/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ go_library(
"//gnmi/oc",
"//gnmi/oc/ocpath",
"//gnmi/reconciler",
"//internal/lemmingutil",
"@com_github_golang_glog//:glog",
"@com_github_openconfig_ygnmi//ygnmi",
"@com_github_openconfig_ygot//ygot",
Expand All @@ -24,8 +25,6 @@ go_library(
"@com_github_wenovus_gobgp_v3//pkg/config/oc",
"@com_github_wenovus_gobgp_v3//pkg/server",
"@com_github_wenovus_gobgp_v3//pkg/zebra",
"@org_golang_x_exp//maps",
"@org_golang_x_exp//slices",
],
)

Expand Down
7 changes: 3 additions & 4 deletions bgp/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package bgp

import (
"net/netip"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"
"slices"

log "github.com/golang/glog"
"github.com/openconfig/lemming/gnmi/oc"
"github.com/openconfig/lemming/internal/lemmingutil"
gobgpoc "github.com/wenovus/gobgp/v3/pkg/config/oc"
"github.com/wenovus/gobgp/v3/pkg/zebra"
)
Expand Down Expand Up @@ -97,7 +96,7 @@ func intendedToGoBGPPolicies(bgpoc *oc.NetworkInstance_Protocol_Bgp, policyoc *o
// AS Path Sets
bgpConfig.DefinedSets.BgpDefinedSets.AsPathSets = convertASPathSets(policyoc.GetOrCreateDefinedSets().GetOrCreateBgpDefinedSets().AsPathSet)

neighAddrs := maps.Keys(bgpoc.Neighbor)
neighAddrs := lemmingutil.Mapkeys(bgpoc.Neighbor)
slices.Sort(neighAddrs)

// Neighbours, global policy definitions, and global apply policy list.
Expand Down
9 changes: 4 additions & 5 deletions bgp/ocgobgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ package bgp

import (
"fmt"
"slices"
"strconv"
"strings"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

log "github.com/golang/glog"
"github.com/openconfig/lemming/gnmi/oc"
"github.com/openconfig/lemming/internal/lemmingutil"
gobgpoc "github.com/wenovus/gobgp/v3/pkg/config/oc"
)

Expand Down Expand Up @@ -216,7 +215,7 @@ func convertCommunity(community any) string {
func convertCommunitySet(occommset map[string]*oc.RoutingPolicy_DefinedSets_BgpDefinedSets_CommunitySet) ([]gobgpoc.CommunitySet, map[string]int) {
indexMap := map[string]int{}
var commsets []gobgpoc.CommunitySet
commNames := maps.Keys(occommset)
commNames := lemmingutil.Mapkeys(occommset)
slices.Sort(commNames)
for _, communitySetName := range commNames {
var communityList []string
Expand Down Expand Up @@ -252,7 +251,7 @@ func communitiesToOC(communities []uint32) []oc.NetworkInstance_Protocol_Bgp_Rib

func convertPrefixSets(ocprefixsets map[string]*oc.RoutingPolicy_DefinedSets_PrefixSet) []gobgpoc.PrefixSet {
var prefixSets []gobgpoc.PrefixSet
prefixSetNames := maps.Keys(ocprefixsets)
prefixSetNames := lemmingutil.Mapkeys(ocprefixsets)
slices.Sort(prefixSetNames)
for _, prefixSetName := range prefixSetNames {
var prefixList []gobgpoc.Prefix
Expand Down
3 changes: 1 addition & 2 deletions dataplane/standalone/apigen/protogen/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ go_library(
deps = [
"//dataplane/standalone/apigen/docparser",
"//dataplane/standalone/apigen/saiast",
"//internal/lemmingutil",
"@com_github_golang_glog//:glog",
"@com_github_stoewer_go_strcase//:go-strcase",
"@org_golang_x_exp//maps",
"@org_golang_x_exp//slices",
],
)

Expand Down
7 changes: 3 additions & 4 deletions dataplane/standalone/apigen/protogen/protogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@ package protogen

import (
"fmt"
"slices"
"strings"
"text/template"
"unicode"

"golang.org/x/exp/maps"
"golang.org/x/exp/slices"

"github.com/openconfig/lemming/dataplane/standalone/apigen/docparser"
"github.com/openconfig/lemming/dataplane/standalone/apigen/saiast"
"github.com/openconfig/lemming/internal/lemmingutil"

log "github.com/golang/glog"
strcase "github.com/stoewer/go-strcase"
Expand Down Expand Up @@ -59,7 +58,7 @@ func Generate(doc *docparser.SAIInfo, sai *saiast.SAIAPI) (map[string]string, er
}

func rangeInOrder[T any](m map[string]T, pred func(key string, val T) error) error {
keys := maps.Keys(m)
keys := lemmingutil.Mapkeys(m)
slices.Sort(keys)
for _, key := range keys {
if err := pred(key, m[key]); err != nil {
Expand Down
1 change: 0 additions & 1 deletion gnmi/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ go_library(
"@org_golang_google_grpc//status",
"@org_golang_google_protobuf//encoding/prototext",
"@org_golang_google_protobuf//proto",
"@org_golang_x_exp//slices",
],
)

Expand Down
2 changes: 1 addition & 1 deletion gnmi/gnmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"fmt"
"runtime/debug"
"slices"
"strconv"
"strings"
"sync"
Expand All @@ -29,7 +30,6 @@ import (
"github.com/openconfig/ygot/util"
"github.com/openconfig/ygot/ygot"
"github.com/openconfig/ygot/ytypes"
"golang.org/x/exp/slices"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"
Expand Down
Loading

0 comments on commit e244193

Please sign in to comment.