Skip to content

Commit

Permalink
refactor: replace deprecated grpc.WithInsecure
Browse files Browse the repository at this point in the history
ref: 7291

Signed-off-by: Chin-Ya Huang <chin-ya.huang@suse.com>
  • Loading branch information
c3y1huang authored and David Ko committed Dec 13, 2023
1 parent 5b3fa35 commit c6cc6d2
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions pkg/client/manager_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/protobuf/types/known/emptypb"

"github.com/longhorn/backing-image-manager/api"
Expand All @@ -29,7 +30,7 @@ func (cli *BackingImageManagerClient) Sync(name, uuid, checksum, fromAddress str
return nil, fmt.Errorf("failed to sync backing image: missing required parameter")
}

conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand Down Expand Up @@ -59,7 +60,7 @@ func (cli *BackingImageManagerClient) Send(name, uuid, toAddress string) error {
return fmt.Errorf("failed to send backing image: missing required parameter")
}

conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand All @@ -82,7 +83,7 @@ func (cli *BackingImageManagerClient) Delete(name, uuid string) error {
return fmt.Errorf("failed to delete backing image: missing required parameter")
}

conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand All @@ -104,7 +105,7 @@ func (cli *BackingImageManagerClient) Get(name, uuid string) (*api.BackingImage,
return nil, fmt.Errorf("failed to get backing image: missing required parameter")
}

conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand All @@ -125,7 +126,7 @@ func (cli *BackingImageManagerClient) Get(name, uuid string) (*api.BackingImage,
}

func (cli *BackingImageManagerClient) List() (map[string]*api.BackingImage, error) {
conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand All @@ -147,7 +148,7 @@ func (cli *BackingImageManagerClient) Fetch(name, uuid, checksum, dataSourceAddr
return nil, fmt.Errorf("failed to fetch backing image: missing required parameter")
}

conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand Down Expand Up @@ -177,7 +178,7 @@ func (cli *BackingImageManagerClient) PrepareDownload(name, uuid string) (string
return "", "", fmt.Errorf("failed to get backing image: missing required parameter")
}

conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return "", "", fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand All @@ -198,7 +199,7 @@ func (cli *BackingImageManagerClient) PrepareDownload(name, uuid string) (string
}

func (cli *BackingImageManagerClient) VersionGet() (*meta.VersionOutput, error) {
conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand All @@ -223,7 +224,7 @@ func (cli *BackingImageManagerClient) VersionGet() (*meta.VersionOutput, error)
}

func (cli *BackingImageManagerClient) Watch() (*api.BackingImageStream, error) {
conn, err := grpc.Dial(cli.Address, grpc.WithInsecure())
conn, err := grpc.Dial(cli.Address, grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
return nil, fmt.Errorf("cannot connect backing image manager service to %v: %v", cli.Address, err)
}
Expand Down

0 comments on commit c6cc6d2

Please sign in to comment.