pkg/certificate: properly close certificateclient.Client (#2986)
This commit is contained in:
parent
2fc4d61610
commit
7cf5650560
@ -149,10 +149,10 @@ func cmdNewService(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func cmdAuthorize(cmd *cobra.Command, args []string) error {
|
||||
func cmdAuthorize(cmd *cobra.Command, args []string) (err error) {
|
||||
ctx := process.Ctx(cmd)
|
||||
|
||||
err := version.CheckProcessVersion(ctx, zap.L(), config.Version, version.Build, "Identity")
|
||||
err = version.CheckProcessVersion(ctx, zap.L(), config.Version, version.Build, "Identity")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@ -204,6 +204,9 @@ func cmdAuthorize(cmd *cobra.Command, args []string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
err = errs.Combine(err, client.Close())
|
||||
}()
|
||||
|
||||
signedChainBytes, err := client.Sign(ctx, authToken)
|
||||
if err != nil {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"github.com/zeebo/errs"
|
||||
"google.golang.org/grpc"
|
||||
"gopkg.in/spacemonkeygo/monkit.v2"
|
||||
|
||||
@ -65,6 +66,9 @@ func (config Config) Sign(ctx context.Context, ident *identity.FullIdentity, aut
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer func() {
|
||||
err = errs.Combine(err, client.Close())
|
||||
}()
|
||||
|
||||
return client.Sign(ctx, authToken)
|
||||
}
|
||||
|
@ -92,6 +92,7 @@ func TestCertificateSigner_Sign_E2E(t *testing.T) {
|
||||
client, err := certificateclient.New(ctx, clientTransport, peer.Server.Addr().String())
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, client)
|
||||
defer ctx.Check(client.Close)
|
||||
|
||||
signedChainBytes, err := client.Sign(ctx, auths[0].Token.String())
|
||||
require.NoError(t, err)
|
||||
|
Loading…
Reference in New Issue
Block a user