Skip to content

Commit

Permalink
rework
Browse files Browse the repository at this point in the history
  • Loading branch information
tanjinx committed Jan 22, 2024
1 parent 95c480c commit 5acdcc3
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions go/vt/grpcclient/client_auth_static.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,25 +65,23 @@ func AppendStaticAuth(opts []grpc.DialOption) ([]grpc.DialOption, error) {
return opts, nil
}

if clientCreds == nil {
var err error
once.Do(func() {
var credsData []byte
credsData, err = os.ReadFile(*credsFile)
if err != nil {
return
}

clientCreds = &StaticAuthClientCreds{}
err = json.Unmarshal(credsData, clientCreds)
if err != nil {
return
}
})
var err error
once.Do(func() {
var credsData []byte
credsData, err = os.ReadFile(*credsFile)
if err != nil {
return
}

clientCreds = &StaticAuthClientCreds{}
err = json.Unmarshal(credsData, clientCreds)
if err != nil {
return nil, err
return
}
})

if clientCreds == nil || err != nil {
return nil, err
}

creds := grpc.WithPerRPCCredentials(clientCreds)
Expand Down

0 comments on commit 5acdcc3

Please sign in to comment.