Skip to content

Commit

Permalink
fix(gencli): don't generate grpc.WithInsecure (#1503)
Browse files Browse the repository at this point in the history
grpc.WithInsecure is deprecated
  • Loading branch information
egonelbre committed May 6, 2024
1 parent 70d7d39 commit 27f02ea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion internal/gencli/service_file.go
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/spf13/viper"
"google.golang.org/api/option"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"golang.org/x/oauth2"
{{ range $key, $pkg := .Imports}}
{{ $pkg.Name }} "{{ $pkg.Path }}"
Expand Down Expand Up @@ -89,7 +90,7 @@ var {{ $serviceCmdVar }} = &cobra.Command{
return fmt.Errorf("Missing address to use with insecure connection")
}
conn, err := grpc.Dial(address, grpc.WithInsecure())
conn, err := grpc.Dial(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion internal/gencli/testdata/service_file.want
Expand Up @@ -10,6 +10,7 @@ import (
"golang.org/x/oauth2"
"google.golang.org/api/option"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

proto "github.com/golang/protobuf/proto"
)
Expand Down Expand Up @@ -63,7 +64,7 @@ var TodoServiceCmd = &cobra.Command{
return fmt.Errorf("Missing address to use with insecure connection")
}

conn, err := grpc.Dial(address, grpc.WithInsecure())
conn, err := grpc.Dial(address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return err
}
Expand Down
3 changes: 2 additions & 1 deletion showcase/main_test.go
Expand Up @@ -24,6 +24,7 @@ import (
showcase "github.com/googleapis/gapic-showcase/client"
"google.golang.org/api/option"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
)

func init() {
Expand All @@ -47,7 +48,7 @@ var restClientOpts = []option.ClientOption{
func TestMain(m *testing.M) {
flag.Parse()

conn, err := grpc.Dial("localhost:7469", grpc.WithInsecure())
conn, err := grpc.Dial("localhost:7469", grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
log.Fatal(err)
}
Expand Down

0 comments on commit 27f02ea

Please sign in to comment.