Skip to content

Commit

Permalink
Merge pull request #37 from whalecold/chore/depen
Browse files Browse the repository at this point in the history
chore: remove deprecated dependence
  • Loading branch information
GuangmingLuo authored Dec 2, 2024
2 parents 7feebcf + 8b1729f commit c9100af
Show file tree
Hide file tree
Showing 15 changed files with 63 additions and 66 deletions.
2 changes: 1 addition & 1 deletion core/manager/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import (

"github.com/cloudwego/kitex/pkg/klog"
v3core "github.com/envoyproxy/go-control-plane/envoy/config/core/v3"
structpb "github.com/golang/protobuf/ptypes/struct"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/types/known/structpb"
)

const (
Expand Down
22 changes: 11 additions & 11 deletions core/manager/mock/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package mock

import (
discoveryv3 "github.com/envoyproxy/go-control-plane/envoy/service/discovery/v3"
"github.com/golang/protobuf/ptypes/any"
"google.golang.org/protobuf/types/known/anypb"

"github.com/kitex-contrib/xds/core/xdsresource"
)
Expand All @@ -36,7 +36,7 @@ var (

LdsInbound = &discoveryv3.DiscoveryResponse{
VersionInfo: LDSVersion1,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.InboundListener1),
},
Canary: false,
Expand All @@ -47,7 +47,7 @@ var (

LdsResp1 = &discoveryv3.DiscoveryResponse{
VersionInfo: LDSVersion1,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.Listener1),
xdsresource.MarshalAny(xdsresource.Listener2),
},
Expand All @@ -58,7 +58,7 @@ var (
}
LdsResp2 = &discoveryv3.DiscoveryResponse{
VersionInfo: LDSVersion2,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.Listener2),
},
Canary: false,
Expand All @@ -84,7 +84,7 @@ var (

RdsResp1 = &discoveryv3.DiscoveryResponse{
VersionInfo: RDSVersion1,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.RouteConfig1),
xdsresource.MarshalAny(xdsresource.RouteConfig2),
},
Expand All @@ -95,7 +95,7 @@ var (
}
RdsResp2 = &discoveryv3.DiscoveryResponse{
VersionInfo: RDSVersion2,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.RouteConfig2),
},
Canary: false,
Expand All @@ -114,7 +114,7 @@ var (

CdsResp1 = &discoveryv3.DiscoveryResponse{
VersionInfo: CDSVersion1,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.Cluster1),
xdsresource.MarshalAny(xdsresource.Cluster2),
},
Expand All @@ -125,7 +125,7 @@ var (
}
CdsResp2 = &discoveryv3.DiscoveryResponse{
VersionInfo: CDSVersion2,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.Cluster2),
},
Canary: false,
Expand All @@ -144,7 +144,7 @@ var (

EdsResp1 = &discoveryv3.DiscoveryResponse{
VersionInfo: EDSVersion1,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.Endpoints1),
xdsresource.MarshalAny(xdsresource.Endpoints2),
},
Expand All @@ -155,7 +155,7 @@ var (
}
EdsResp2 = &discoveryv3.DiscoveryResponse{
VersionInfo: EDSVersion2,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.Endpoints2),
},
Canary: false,
Expand All @@ -171,7 +171,7 @@ var (
NDSNonce1 = "nonce1"
NdsResp1 = &discoveryv3.DiscoveryResponse{
VersionInfo: NDSVersion1,
Resources: []*any.Any{
Resources: []*anypb.Any{
xdsresource.MarshalAny(xdsresource.NameTable1),
},
Canary: false,
Expand Down
7 changes: 4 additions & 3 deletions core/xdsresource/cds.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import (
"fmt"

v3clusterpb "github.com/envoyproxy/go-control-plane/envoy/config/cluster/v3"
"github.com/golang/protobuf/ptypes/any"
"google.golang.org/protobuf/types/known/anypb"

"google.golang.org/protobuf/proto"
)

Expand Down Expand Up @@ -91,7 +92,7 @@ func (c *ClusterResource) InlineEDS() *EndpointsResource {
return c.InlineEndpoints
}

func unmarshalCluster(r *any.Any) (string, *ClusterResource, error) {
func unmarshalCluster(r *anypb.Any) (string, *ClusterResource, error) {
if r.GetTypeUrl() != ClusterTypeURL {
return "", nil, fmt.Errorf("invalid cluster resource type: %s", r.GetTypeUrl())
}
Expand Down Expand Up @@ -123,7 +124,7 @@ func unmarshalCluster(r *any.Any) (string, *ClusterResource, error) {
return c.Name, ret, nil
}

func UnmarshalCDS(rawResources []*any.Any) (map[string]Resource, error) {
func UnmarshalCDS(rawResources []*anypb.Any) (map[string]Resource, error) {
ret := make(map[string]Resource, len(rawResources))
errMap := make(map[string]error)
var errSlice []error
Expand Down
8 changes: 4 additions & 4 deletions core/xdsresource/cds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ import (
"reflect"
"testing"

"github.com/golang/protobuf/ptypes/any"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/types/known/anypb"
)

func TestUnmarshalCDSError(t *testing.T) {
tests := []struct {
name string
rawResources []*any.Any
rawResources []*anypb.Any
want map[string]Resource
wantErr bool
}{
Expand All @@ -39,7 +39,7 @@ func TestUnmarshalCDSError(t *testing.T) {
},
{
name: "incorrect resource type url",
rawResources: []*any.Any{
rawResources: []*anypb.Any{
{TypeUrl: ListenerTypeURL, Value: []byte{}},
},
want: map[string]Resource{},
Expand All @@ -61,7 +61,7 @@ func TestUnmarshalCDSError(t *testing.T) {
}

func TestUnmarshalCDSSuccess(t *testing.T) {
rawResources := []*any.Any{
rawResources := []*anypb.Any{
MarshalAny(Cluster1),
}
got, err := UnmarshalCDS(rawResources)
Expand Down
5 changes: 3 additions & 2 deletions core/xdsresource/eds.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import (
"strconv"

v3endpointpb "github.com/envoyproxy/go-control-plane/envoy/config/endpoint/v3"
"github.com/golang/protobuf/ptypes/any"
"google.golang.org/protobuf/types/known/anypb"

"google.golang.org/protobuf/proto"

"github.com/cloudwego/kitex/pkg/utils"
Expand Down Expand Up @@ -100,7 +101,7 @@ func parseClusterLoadAssignment(cla *v3endpointpb.ClusterLoadAssignment) (*Endpo
}, nil
}

func UnmarshalEDS(rawResources []*any.Any) (map[string]Resource, error) {
func UnmarshalEDS(rawResources []*anypb.Any) (map[string]Resource, error) {
ret := make(map[string]Resource, len(rawResources))
errMap := make(map[string]error)
var errSlice []error
Expand Down
8 changes: 4 additions & 4 deletions core/xdsresource/eds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ import (
"strconv"
"testing"

"github.com/golang/protobuf/ptypes/any"
"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/types/known/anypb"
)

func TestUnmarshalEDSError(t *testing.T) {
tests := []struct {
name string
rawResources []*any.Any
rawResources []*anypb.Any
want map[string]Resource
wantErr bool
}{
Expand All @@ -40,7 +40,7 @@ func TestUnmarshalEDSError(t *testing.T) {
},
{
name: "incorrect resource type url",
rawResources: []*any.Any{
rawResources: []*anypb.Any{
{TypeUrl: ListenerTypeURL, Value: []byte{}},
},
want: map[string]Resource{},
Expand All @@ -65,7 +65,7 @@ func TestUnmarshalEDSSuccess(t *testing.T) {
// edsAddr := "127.0.0.1"
// edsPort1, edsPort2 := 8080, 8081
// edsWeight1, edsWeight2 := 50, 50
rawResources := []*any.Any{
rawResources := []*anypb.Any{
MarshalAny(Endpoints1),
}
got, err := UnmarshalEDS(rawResources)
Expand Down
11 changes: 6 additions & 5 deletions core/xdsresource/lds.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,14 @@ package xdsresource
import (
"fmt"

udpatypev1 "github.com/cncf/udpa/go/udpa/type/v1"
udpatypev1 "github.com/cncf/xds/go/udpa/type/v1"
v3listenerpb "github.com/envoyproxy/go-control-plane/envoy/config/listener/v3"
v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
ratelimitv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/local_ratelimit/v3"
v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
v3thrift_proxy "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/thrift_proxy/v3"
"github.com/golang/protobuf/ptypes/any"
"google.golang.org/protobuf/types/known/anypb"

"google.golang.org/protobuf/proto"
)

Expand Down Expand Up @@ -60,7 +61,7 @@ type NetworkFilter struct {
// UnmarshalLDS unmarshalls the LDS Response.
// Only focus on OutboundListener now.
// Get the InlineRouteConfig or RouteConfigName from the listener.
func UnmarshalLDS(rawResources []*any.Any) (map[string]*ListenerResource, error) {
func UnmarshalLDS(rawResources []*anypb.Any) (map[string]*ListenerResource, error) {
ret := make(map[string]*ListenerResource, len(rawResources))
errMap := make(map[string]error)
var errSlice []error
Expand Down Expand Up @@ -150,7 +151,7 @@ func unmarshalFilterChain(fc *v3listenerpb.FilterChain) ([]*NetworkFilter, error
return filters, combineErrors(errSlice)
}

func unmarshalThriftProxy(rawResources *any.Any) (*RouteConfigResource, error) {
func unmarshalThriftProxy(rawResources *anypb.Any) (*RouteConfigResource, error) {
tp := &v3thrift_proxy.ThriftProxy{}
if err := proto.Unmarshal(rawResources.GetValue(), tp); err != nil {
return nil, fmt.Errorf("unmarshal HttpConnectionManager failed: %s", err)
Expand Down Expand Up @@ -201,7 +202,7 @@ func unmarshalThriftProxy(rawResources *any.Any) (*RouteConfigResource, error) {
}, nil
}

func unmarshallHTTPConnectionManager(rawResources *any.Any) (string, *RouteConfigResource, error) {
func unmarshallHTTPConnectionManager(rawResources *anypb.Any) (string, *RouteConfigResource, error) {
httpConnMng := &v3httppb.HttpConnectionManager{}

if err := proto.Unmarshal(rawResources.GetValue(), httpConnMng); err != nil {
Expand Down
20 changes: 10 additions & 10 deletions core/xdsresource/lds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ import (
"reflect"
"testing"

udpatypev1 "github.com/cncf/udpa/go/udpa/type/v1"
udpatypev1 "github.com/cncf/xds/go/udpa/type/v1"
v3routepb "github.com/envoyproxy/go-control-plane/envoy/config/route/v3"
ratelimitv3 "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/http/local_ratelimit/v3"
v3httppb "github.com/envoyproxy/go-control-plane/envoy/extensions/filters/network/http_connection_manager/v3"
v3 "github.com/envoyproxy/go-control-plane/envoy/type/v3"
"github.com/golang/protobuf/ptypes/any"
_struct "github.com/golang/protobuf/ptypes/struct"
wrappers "github.com/golang/protobuf/ptypes/wrappers"
"google.golang.org/protobuf/types/known/anypb"

"github.com/stretchr/testify/assert"
"google.golang.org/protobuf/types/known/structpb"
wrapperspb "google.golang.org/protobuf/types/known/wrapperspb"
)

func TestUnmarshalLDSError(t *testing.T) {
tests := []struct {
name string
rawResources []*any.Any
rawResources []*anypb.Any
want map[string]*ListenerResource
wantErr bool
}{
Expand All @@ -47,7 +47,7 @@ func TestUnmarshalLDSError(t *testing.T) {
},
{
name: "incorrect resource type url",
rawResources: []*any.Any{
rawResources: []*anypb.Any{
{TypeUrl: EndpointTypeURL, Value: []byte{}},
},
want: map[string]*ListenerResource{},
Expand All @@ -69,7 +69,7 @@ func TestUnmarshalLDSError(t *testing.T) {
}

func TestUnmarshalLDSHttpConnectionManager(t *testing.T) {
rawResources := []*any.Any{
rawResources := []*anypb.Any{
MarshalAny(Listener1),
MarshalAny(Listener2),
}
Expand All @@ -96,7 +96,7 @@ func TestUnmarshalLDSHttpConnectionManager(t *testing.T) {
}

func TestUnmarshallLDSThriftProxy(t *testing.T) {
rawResources := []*any.Any{
rawResources := []*anypb.Any{
MarshalAny(Listener3),
}
res, err := UnmarshalLDS(rawResources)
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestGetLocalRateLimitFromHttpConnectionManager(t *testing.T) {
rateLimit := &ratelimitv3.LocalRateLimit{
TokenBucket: &v3.TokenBucket{
MaxTokens: 10,
TokensPerFill: &wrappers.UInt32Value{
TokensPerFill: &wrapperspb.UInt32Value{
Value: 10,
},
},
Expand All @@ -174,7 +174,7 @@ func TestGetLocalRateLimitFromHttpConnectionManager(t *testing.T) {
// ---------------------------------- struct ratelimit ------------------------------------
structLimit := &udpatypev1.TypedStruct{
TypeUrl: RateLimitTypeURL,
Value: &_struct.Struct{
Value: &structpb.Struct{
Fields: map[string]*structpb.Value{
"token_bucket": {
Kind: &structpb.Value_StructValue{
Expand Down
4 changes: 2 additions & 2 deletions core/xdsresource/nds.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package xdsresource
import (
"fmt"

"github.com/golang/protobuf/ptypes/any"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/anypb"

dnsProto "github.com/kitex-contrib/xds/core/api/kitex_gen/istio.io/istio/pkg/dns/proto/istio_networking_nds_v1"
)
Expand All @@ -29,7 +29,7 @@ type NDSResource struct {
NameTable map[string][]string
}

func UnmarshalNDS(rawResources []*any.Any) (*NDSResource, error) {
func UnmarshalNDS(rawResources []*anypb.Any) (*NDSResource, error) {
if len(rawResources) < 1 {
return nil, fmt.Errorf("no NDS resource found in the response")
}
Expand Down
8 changes: 4 additions & 4 deletions core/xdsresource/nds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@ import (

"github.com/stretchr/testify/assert"

"github.com/golang/protobuf/ptypes/any"
"google.golang.org/protobuf/types/known/anypb"

dnsProto "github.com/kitex-contrib/xds/core/api/kitex_gen/istio.io/istio/pkg/dns/proto/istio_networking_nds_v1"
)

func TestUnmarshalNDSError(t *testing.T) {
type args struct {
rawResources []*any.Any
rawResources []*anypb.Any
}
tests := []struct {
name string
Expand All @@ -48,7 +48,7 @@ func TestUnmarshalNDSError(t *testing.T) {
{
name: "incorrect resource type url",
args: args{
[]*any.Any{
[]*anypb.Any{
{TypeUrl: ListenerTypeURL, Value: []byte{}},
},
},
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestUnmarshalNDSSuccess(t *testing.T) {
},
},
}
rawResources := []*any.Any{
rawResources := []*anypb.Any{
MarshalAny(nt),
}
res, err := UnmarshalNDS(rawResources)
Expand Down
Loading

0 comments on commit c9100af

Please sign in to comment.