From 1986c558a8042665eefb3111460bdd5443126dd6 Mon Sep 17 00:00:00 2001 From: "R.B. Boyer" <4903+rboyer@users.noreply.github.com> Date: Mon, 23 Sep 2024 15:14:39 -0500 Subject: [PATCH] api: remove dependency on proto-public, protobuf, and grpc (#21780) --- .changelog/21780.txt | 3 ++ api/go.mod | 11 +------ api/go.sum | 10 ------- api/raw_test.go | 65 +++++++++++++++--------------------------- envoyextensions/go.sum | 2 -- 5 files changed, 27 insertions(+), 64 deletions(-) create mode 100644 .changelog/21780.txt diff --git a/.changelog/21780.txt b/.changelog/21780.txt new file mode 100644 index 0000000000..72550e549a --- /dev/null +++ b/.changelog/21780.txt @@ -0,0 +1,3 @@ +```release-note:improvement +api: remove dependency on proto-public, protobuf, and grpc +``` diff --git a/api/go.mod b/api/go.mod index e4de0fa6c1..715a594dcf 100644 --- a/api/go.mod +++ b/api/go.mod @@ -2,10 +2,7 @@ module github.com/hashicorp/consul/api go 1.19 -replace ( - github.com/hashicorp/consul/proto-public => ../proto-public - github.com/hashicorp/consul/sdk => ../sdk -) +replace github.com/hashicorp/consul/sdk => ../sdk retract ( v1.28.0 // tag was mutated @@ -15,7 +12,6 @@ retract ( require ( github.com/google/go-cmp v0.5.9 - github.com/hashicorp/consul/proto-public v0.6.2 github.com/hashicorp/consul/sdk v0.16.1 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/hashicorp/go-hclog v1.5.0 @@ -26,14 +22,12 @@ require ( github.com/mitchellh/mapstructure v1.5.0 github.com/stretchr/testify v1.8.4 golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 - google.golang.org/protobuf v1.33.0 ) require ( github.com/armon/go-metrics v0.4.1 // indirect github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect github.com/fatih/color v1.16.0 // indirect - github.com/golang/protobuf v1.5.4 // indirect github.com/google/btree v1.0.1 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-immutable-radix v1.3.1 // indirect @@ -53,8 +47,5 @@ require ( golang.org/x/net v0.24.0 // indirect golang.org/x/sync v0.2.0 // indirect golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/api/go.sum b/api/go.sum index a11d687004..de53ac240d 100644 --- a/api/go.sum +++ b/api/go.sum @@ -34,8 +34,6 @@ github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7a github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= @@ -219,18 +217,10 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/api/raw_test.go b/api/raw_test.go index 1f75b8f3e2..3f48dfb736 100644 --- a/api/raw_test.go +++ b/api/raw_test.go @@ -4,34 +4,24 @@ package api import ( - "encoding/json" "fmt" "strings" "testing" "github.com/stretchr/testify/require" - "google.golang.org/protobuf/encoding/protojson" - - pbmulticluster "github.com/hashicorp/consul/proto-public/pbmulticluster/v2" - "github.com/hashicorp/consul/proto-public/pbresource" "github.com/hashicorp/consul/sdk/testutil" ) type V2WriteRequest struct { - Metadata map[string]string `json:"metadata"` - Data map[string]any `json:"data"` - Owner *pbresource.ID `json:"owner"` + Data map[string]any `json:"data"` } type V2WriteResponse struct { - Metadata map[string]string `json:"metadata"` - Data map[string]any `json:"data"` - Owner *pbresource.ID `json:"owner,omitempty"` - ID *pbresource.ID `json:"id"` - Version string `json:"version"` - Generation string `json:"generation"` - Status map[string]any `json:"status"` + ID struct { + Name string `json:"name"` + } `json:"id"` + Data map[string]any `json:"data"` } // We are testing a v2 endpoint here in the v1 api module as a temporary measure to @@ -47,43 +37,34 @@ func TestAPI_RawV2ExportedServices(t *testing.T) { endpoint := strings.ToLower(fmt.Sprintf("/api/multicluster/v2/exportedservices/e1")) wResp := &V2WriteResponse{} - var consumers []map[string]any - consumers = append(consumers, map[string]any{"peer": "p1"}) - data := map[string]any{"consumers": consumers} - data["services"] = []string{"s1"} wReq := &V2WriteRequest{ - Metadata: nil, - Data: data, - Owner: nil, + Data: map[string]any{ + "consumers": []map[string]any{ + {"peer": "p1"}, + }, + "services": []string{"s1"}, + }, } _, err := c.Raw().Write(endpoint, wReq, wResp, &WriteOptions{Datacenter: "dc1"}) - if err != nil { - t.Fatalf("err: %v", err) - } - if wResp.ID.Name == "" { - t.Fatalf("no write response") - } + require.NoError(t, err) + require.NotEmpty(t, wResp.ID.Name) qOpts := &QueryOptions{Datacenter: "dc1"} + var out map[string]interface{} _, err = c.Raw().Query(endpoint, &out, qOpts) - if err != nil { - t.Fatalf("err: %v", err) - } - respData, _ := json.Marshal(out["data"]) - readData := &pbmulticluster.ExportedServices{} - if err = protojson.Unmarshal(respData, readData); err != nil { - t.Fatalf("invalid read response") - } - if len(readData.Services) != 1 { - t.Fatalf("incorrect resource data") - } + require.NoError(t, err) + + require.Equal(t, map[string]any{ + "consumers": []any{ + map[string]any{"peer": "p1"}, + }, + "services": []any{"s1"}, + }, out["data"]) _, err = c.Raw().Delete(endpoint, qOpts) - if err != nil { - t.Fatalf("err: %v", err) - } + require.NoError(t, err) out = make(map[string]interface{}) _, err = c.Raw().Query(endpoint, &out, qOpts) diff --git a/envoyextensions/go.sum b/envoyextensions/go.sum index b215d64921..d29e39ebe8 100644 --- a/envoyextensions/go.sum +++ b/envoyextensions/go.sum @@ -235,7 +235,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= @@ -255,7 +254,6 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98/go. google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.58.3 h1:BjnpXut1btbtgN/6sp+brB2Kbm2LjNXnidYujAVbSoQ= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=